0

我正在调试集群中的一个问题,似乎kubectlkube-addon-manager pod 内的命令超时,而等效的 curl 命令工作正常。

bash-4.3# kubectl get node --v 10
I1119 16:35:55.506867      54 round_trippers.go:386] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.10.5 (linux/amd64) kubernetes/32ac1c9" http://localhost:8080/api
I1119 16:36:25.507550      54 round_trippers.go:405] GET http://localhost:8080/api  in 30000 milliseconds
I1119 16:36:25.507959      54 round_trippers.go:411] Response Headers:
I1119 16:36:25.508122      54 cached_discovery.go:124] skipped caching discovery info due to Get http://localhost:8080/api: dial tcp: i/o timeout

等效 curl 命令输出

bash-4.3# curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.10.5 (linux/amd64) kubernetes/32ac1c9" http://localhost:8080/api
Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /api HTTP/1.1
> Host: localhost:8080
> Accept: application/json, */*
> User-Agent: kubectl/v1.10.5 (linux/amd64) kubernetes/32ac1c9
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Mon, 19 Nov 2018 16:43:00 GMT
< Content-Length: 134
<
{"kind":"APIVersions","versions":["v1"],"serverAddressByClientCIDRs":[{"clientCIDR":"0.0.0.0/0","serverAddress":"172.16.1.13:6443"}]}
* Connection #0 to host localhost left intact

还尝试使用主机网络模式运行 docker 容器,kubectl 命令仍然超时。

kube-addon-manager.yaml

apiVersion: v1
kind: Pod
metadata:
  name: kube-addon-manager
  namespace: kube-system
  annotations:
    scheduler.alpha.kubernetes.io/critical-pod: ''
  labels:
    component: kube-addon-manager
spec:
  hostNetwork: true
  containers:
  - name: kube-addon-manager
    image: gcr.io/google-containers/kube-addon-manager:v8.6
    imagePullPolicy: IfNotPresent
    command:
    - /bin/bash
    - -c
    - /opt/kube-addons.sh
    resources:
      requests:
        cpu: 5m
        memory: 50Mi
    volumeMounts:
    - mountPath: /etc/kubernetes/
      name: addons
      readOnly: true
  volumes:
  - name: addons
    hostPath:
      path: /etc/kubernetes/
4

1 回答 1

1

似乎在您的配置中,您正在尝试与8080kube-apiserver 中不安全的端口通信。

您可以尝试使用以下选项启动 kube-apiserver:

--insecure-port

不安全端口的默认值为8080. 请注意,将来可能会弃用此选项。

另外,请记住kube-addon-manager旧附加组件的一部分。

于 2018-11-20T02:20:30.277 回答