Kubernetes在裸机上集群

时间:2020-04-22 08:32:46

标签: kubernetes kubeadm calico bare-metal-server

我正试图在Debian 10上使用Docker作为容器运行时的3个裸机节点(1个主节点和2个工人)上创建带有kubeadm的单个控制平面集群。每个节点都有一个外部IP和内部IP。 我想在内部网络上配置一个群集,并且可以从Internet访问它。 为此使用了此命令(如果出现问题,请纠正我):

NLTK was unable to find the java file!

我知道了

kubeadm init --control-plane-endpoint=10.10.0.1 --apiserver-cert-extra-sans={public_DNS_name},10.10.0.1 --pod-network-cidr=192.168.0.0/16

初始化阶段已成功完成,可以从Internet访问群集。除应在联网后应运行的coredns之外,所有pod均已启动并正在运行。

kubectl get no -o wide
NAME                           STATUS   ROLES    AGE   VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE                       KERNEL-VERSION   CONTAINER-RUNTIME
dev-k8s-master-0.public.dns    Ready    master   16h   v1.18.2   10.10.0.1     <none>        Debian GNU/Linux 10 (buster)   4.19.0-8-amd64   docker://19.3.8

应用网络后,coredns pod仍未准备好:

kubectl apply -f https://docs.projectcalico.org/v3.11/manifests/calico.yaml

来自失败的Pod的一些日志:

kubectl get po -A
NAMESPACE     NAME                                                   READY   STATUS             RESTARTS   AGE
kube-system   calico-kube-controllers-75d56dfc47-g8g9g               0/1     CrashLoopBackOff   192        16h
kube-system   calico-node-22gtx                                      1/1     Running            0          16h
kube-system   coredns-66bff467f8-87vd8                               0/1     Running            0          16h
kube-system   coredns-66bff467f8-mv8d9                               0/1     Running            0          16h
kube-system   etcd-dev-k8s-master-0                                  1/1     Running            0          16h
kube-system   kube-apiserver-dev-k8s-master-0                        1/1     Running            0          16h
kube-system   kube-controller-manager-dev-k8s-master-0               1/1     Running            0          16h
kube-system   kube-proxy-lp6b8                                       1/1     Running            0          16h
kube-system   kube-scheduler-dev-k8s-master-0                        1/1     Running            0          16h

coredns:

kubectl -n kube-system logs calico-kube-controllers-75d56dfc47-g8g9g
2020-04-22 08:24:55.853 [INFO][1] main.go 88: Loaded configuration from environment config=&config.Config{LogLevel:"info", ReconcilerPeriod:"5m", CompactionPeriod:"10m", EnabledControllers:"node", WorkloadEndpointWorkers:1, ProfileWorkers:1, PolicyWorkers:1, NodeWorkers:1, Kubeconfig:"", HealthEnabled:true, SyncNodeLabels:true, DatastoreType:"kubernetes"}
2020-04-22 08:24:55.855 [INFO][1] k8s.go 228: Using Calico IPAM
W0422 08:24:55.855525       1 client_config.go:541] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
2020-04-22 08:24:55.856 [INFO][1] main.go 109: Ensuring Calico datastore is initialized
2020-04-22 08:25:05.857 [ERROR][1] client.go 255: Error getting cluster information config ClusterInformation="default" error=Get https://10.96.0.1:443/apis/crd.projectcalico.org/v1/clusterinformations/default: context deadline exceeded
2020-04-22 08:25:05.857 [FATAL][1] main.go 114: Failed to initialize Calico datastore error=Get https://10.96.0.1:443/apis/crd.projectcalico.org/v1/clusterinformations/default: context deadline exceeded

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

这个答案是要引起人们对@florin建议的关注:

当我在节点上有多个公共接口并且calico选择了错误的接口时,我也看到了类似的行为。

我要做的是在印花布配置中设置 IP_AUTODETECT_METHOD

用于自动检测此主机的IPv4地址的方法。仅在自动检测IPv4地址时使用。有关有效方法的详细信息,请参见IP自动检测方法。

在此处了解更多信息:https://docs.projectcalico.org/reference/node/configuration#ip-autodetection-methods