douzhongqiu5032 2018-01-19 10:24
浏览 193
已采纳

如何设置“ KUBERNETES_PORT_443_TCP_ADDR”? 是否有指向Kubernetes源代码的指针?

When I run an image in Kubernetes with kubectl run, environment variables are injected into the container.

My problem is that the values are wrong. I do not have anything running at 10.0.0.1. I believe the correct value there would be 10.1.0.1. This misconfiguration causes, as far as I know, among other things, the error from kube-dns reproduced below.

I would like to ask how are these variables injected into the container, preferably for a link into the code which takes care of this (I could not find anything). Also, some hints where the value 10.0.0.1 could be coming from.

pod variables:

$ kubectl run -i --image=busybox --restart=Never -t busybox
If you don't see a command prompt, try pressing enter.
/ # env
KUBERNETES_SERVICE_PORT=443
KUBERNETES_PORT=tcp://10.0.0.1:443
HOSTNAME=busybox
SHLVL=1
HOME=/root
TERM=xterm
KUBERNETES_PORT_443_TCP_ADDR=10.0.0.1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP_PROTO=tcp
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_PORT_443_TCP=tcp://10.0.0.1:443
KUBERNETES_SERVICE_HOST=10.0.0.1
PWD=/

kube-dns error:

$ kubectl --namespace kube-system logs kube-dns-2190035132-gxf80 kubedns
[...]
E0119 10:04:05.271499      55 reflector.go:199] k8s.io/dns/vendor/k8s.io/client-go/tools/cache/reflector.go:94: Failed to list *v1.Service: Get https://10.0.0.1:443/api/v1/services?resourceVersion=0: dial tcp 10.0.0.1:443: i/o timeout
I0119 10:04:05.771477      55 dns.go:174] Waiting for services and endpoints to be initialized from apiserver...

The closest thing to 10.0.0.1 that I have in my config is --service-cluster-ip-range=10.0.0.0/24 parameter I am giving to kube-apiserver.

I have the IP 10.0.0.1 in my etcd, in

# ETCDCTL_API=3 etcdctl get "" --from-key
[...]
/registry/services/specs/default/kubernetes
k8s

v1Service


kubernetes▒default"*$b198bc22-fcff-11e7-83a9-185e0fec8ce528B
                                                           Z
        component       apiserverZ
provider
kuberneteszC
▒
httpsTCP▒▒(10.0.0.1"    ClusterIPClientIPBRZ`▒
▒"
/registry/services/specs/kube-system/kubernetes-dashboard
k8s

v1Service

kubernetes-dashboard▒
                     kube-system"*$b9f0daef-fcff-11e7-83a9-185e0fec8ce528B
                                                                         ԾZ,
addonmanager.kubernetes.io/mode ReconcileZ
ppkubernetes-dashboardZ*
kubernetes.io/minikube-addons   dashboardZ3
&kubernetes.io/minikube-addons-endpoint dashboardb
0kubectl.kubernetes.io/last-applied-configuration{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"addonmanager.kubernetes.io/mode":"Reconcile","app":"kubernetes-dashboard","kubernetes.io/minikube-addons":"dashboard","kubernetes.io/minikube-addons-endpoint":"dashboard"},"name":"kubernetes-dashboard","namespace":"kube-system"},"spec":{"ports":[{"nodePort":30000,"port":80,"targetPort":9090}],"selector":{"app":"kubernetes-dashboard"},"type":"NodePort"}}
z_

TCP▒PG▒(
ppkubernetes-dashboard▒ 10.0.0.82NodePort:NoneBRZCluster`▒
▒"
  • 写回答

1条回答 默认 最新

  • duannuan0074 2018-01-20 05:55
    关注

    https://github.com/kubernetes/kubernetes/blob/v1.9.0/pkg/kubelet/envvars/envvars.go#L45-L48 which I found via git grep SERVICE_PORT

    It's possible that if your kubernetes.default.svc.cluster.local is pointing to the wrong IP, then kubectl --namespace=kube-system edit svc kubernetes and changing the ClusterIP would sort that out; I don't have a cluster in front of me to test it, though

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名