0

我按照本指南部署了一个 3 节点 CoreOS Vagrant VM,按照此处所述进行了修改。

虚拟机运行良好;K8s 控制器/工作节点很好;我可以部署 Pod;副本集;等等

但是,DNS 似乎不起作用,当我查看flannelpod 的状态时,它们肯定是不健康的:

$ kubectl get po --all-namespaces                          
NAMESPACE     NAME                                   READY     STATUS             RESTARTS   AGE
apps          frontend-cluster-q4gvm                 1/1       Running            1          1h
apps          frontend-cluster-tl5ts                 1/1       Running            0          1h
apps          frontend-cluster-xgktz                 1/1       Running            1          1h
kube-system   kube-apiserver-172.17.8.101            1/1       Running            2          32d
kube-system   kube-controller-manager-172.17.8.101   1/1       Running            2          32d
kube-system   kube-flannel-ds-6csjl                  0/1       CrashLoopBackOff   46         31d
kube-system   kube-flannel-ds-f8czg                  0/1       CrashLoopBackOff   48         31d
kube-system   kube-flannel-ds-qbtlc                  0/1       CrashLoopBackOff   52         31d
kube-system   kube-proxy-172.17.8.101                1/1       Running            2          32d
kube-system   kube-proxy-172.17.8.102                1/1       Running            0          6m
kube-system   kube-proxy-172.17.8.103                1/1       Running            0          2m
kube-system   kube-scheduler-172.17.8.101            1/1       Running            2          32d

此外,当我尝试kubedns使用相同的故障模式部署这些失败时:

$ kubectl logs kube-flannel-ds-f8czg -n kube-system        
I0608 23:03:32.526331       1 main.go:475] Determining IP address of default interface
I0608 23:03:32.528108       1 main.go:488] Using interface with name eth0 and address 10.0.2.15
I0608 23:03:32.528135       1 main.go:505] Defaulting external address to interface address (10.0.2.15)
E0608 23:04:02.627348       1 main.go:232] Failed to create SubnetManager: error retrieving pod spec for 'kube-system/kube-flannel-ds-f8czg': Get https://10.3.0.1:443/api/v1/namespaces/kube-system/pods/kube-flannel-ds-f8czg: dial tcp 10.3.0.1:443: i/o timeout

因此,似乎10.3.0.1无法从其他 pod 访问通过 IP 运行的控制器服务:

$ kubectl get svc --all-namespaces 
NAMESPACE   NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE
apps        frontend     ClusterIP   10.3.0.170   <none>        80/TCP,443/TCP   1h
default     kubernetes   ClusterIP   10.3.0.1     <none>        443/TCP          32d

我的猜测是围绕 Flannel 的etcd配置。或kube-proxyYAML;所以,我在所有节点中添加了以下内容:

core@core-01 ~ $ etcdctl ls /flannel/network/subnets
/flannel/network/subnets/10.1.80.0-24
/flannel/network/subnets/10.1.76.0-24
/flannel/network/subnets/10.3.0.0-16
/flannel/network/subnets/10.1.34.0-24

core@core-01 ~ $ etcdctl get /flannel/network/subnets/10.3.0.0-16
{"PublicIP": "172.17.8.101"}

并重新启动flanneld

core@core-01 ~ $ sudo systemctl restart flanneld

但是,这似乎没有任何好处;从正在运行的 Pod 中:

# This is expected (no client certs):
root@frontend-cluster-q4gvm:/opt/simple# curl -k https://172.17.8.101/api/v1/pods
{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {

  },
  "status": "Failure",
  "message": "Unauthorized",
  "reason": "Unauthorized",
  "code": 401
}
# But this one just times out:
root@frontend-cluster-q4gvm:/opt/simple# curl -k https://10.3.0.1/api/v1/pods

然后我查看kube-proxy.yaml并怀疑--master配置(对于工作节点)不正确,不知何故?

core@core-02 /etc/kubernetes/manifests $ cat kube-proxy.yaml 
apiVersion: v1
kind: Pod
metadata:
  name: kube-proxy
  namespace: kube-system
spec:
  hostNetwork: true
  containers:
  - name: kube-proxy
    image: quay.io/coreos/hyperkube:v1.10.1_coreos.0
    command:
    - /hyperkube
    - proxy
>>>>> Should it be like this?
    - --master=https://172.17.8.101
>>>>> or like this?
    - --master=http://127.0.0.1:8080

    securityContext:
      privileged: true
    volumeMounts:
    - mountPath: /etc/ssl/certs
      name: ssl-certs-host
      readOnly: true
  volumes:
  - hostPath:
      path: /usr/share/ca-certificates
    name: ssl-certs-host

127.0.0.1:8080配置似乎仅(充其量)对控制器节点起作用,但肯定会在其他节点上无处可去?

--master但是,如上所述修改并重新启动 pod 也没有任何好处。

底线是,如何使控制器 API 可访问10.3.0.1?如何启用 KubeDNS(我尝试了“Hard Way”指南中的说明,但得到的故障模式与上述完全相同)。

提前谢谢了!

更新

这是带有flanneld选项的文件:

$ cat /etc/flannel/options.env 
FLANNELD_IFACE=172.17.8.101
FLANNELD_ETCD_ENDPOINTS=http://172.17.8.102:2379,http://172.17.8.103:2379,http://172.17.8.101:2379

我现在已经删除了 flannel 守护程序集:

kc delete ds kube-flannel-ds -n kube-system

并按照以下说明部署 Kube DNS:服务定义在这里,部署在这里

$ kc -n kube-system get svc
NAME       TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)         AGE
kube-dns   ClusterIP   10.3.0.10    <none>        53/UDP,53/TCP   4d


$ kc get po -n kube-system  
NAME                                   READY     STATUS    RESTARTS   AGE
kube-apiserver-172.17.8.101            1/1       Running   5          36d
kube-controller-manager-172.17.8.101   1/1       Running   5          36d
kube-dns-7868b65c7b-ntc95              3/4       Running   2          3m
kube-proxy-172.17.8.101                1/1       Running   5          36d
kube-proxy-172.17.8.102                1/1       Running   3          4d
kube-proxy-172.17.8.103                1/1       Running   2          4d
kube-scheduler-172.17.8.101            1/1       Running   5          36d

但是,我仍然收到超时错误(实际上是一堆):

E0613 19:02:27.193691       1 sync.go:105] Error getting ConfigMap kube-system:kube-dns err: Get https://10.3.0.1:443/api/v1/namespaces/kube-system/configmaps/kube-dns: dial tcp 10.3.0.1:443: i/o timeout

更新#2

在类似的系统设置上,我具有以下flanneld配置:

core@core-02 ~ $ etcdctl get /flannel/network/config
{ "Network": "10.1.0.0/16" }
core@core-02 ~ $ etcdctl ls /flannel/network/subnets
/flannel/network/subnets/10.1.5.0-24
/flannel/network/subnets/10.1.66.0-24
/flannel/network/subnets/10.1.6.0-24
core@core-02 ~ $ etcdctl get /flannel/network/subnets/10.1.66.0-24
{"PublicIP":"172.17.8.102"}

(对于其他人来说也是如此,指向101and ) -子网103应该有什么东西config吗?此外,控制器 API10.3.0.0/16是否应该有一个条目(指向) ?类似于以下内容:172.17.8.10110.3.0.1

/flannel/network/subnets/10.3.0.0-24
{"PublicIP":"172.17.8.101"}

有谁知道在哪里可以找到好的flanneld文档(CoreOS 文档确实不够用,感觉有点“被遗弃”)?或者其他可以实际使用的东西?

谢谢!

4

0 回答 0