在Kubernetes集群上应用Calico网络时出错

时间:2019-11-22 16:37:43

标签: kubernetes kubectl kubeadm

我使用以下命令进行了kubeinit(我正在尝试在RHEL 7.6上设置Kubernetes)

kubeadm init --apiserver-advertise-address=15.217.230.99 --pod-network-cidr=15.232.10.195/27

我想使用印花布网络。由于我无法使用192.168.0.0/16网络,因此不得不从https://docs.projectcalico.org/v3.9/manifests/calico.yaml中获取calico.yaml,然后将CALICO_IPV4POOL_CIDR修改为值15.232.10.195/27(第一件事是,我不知道如果我在这里做的正确的话。我是Kubernetes的新手,正在尝试设置我的第一个集群) 当我尝试使用命令(以sudo用户身份)应用文件时:

kubectl apply -f ./calico.yaml

我收到以下错误:

unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./calico.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused

我的api服务器运行在端口6443上。这是我在kubeadm init生成的kubeadm连接令牌中看到的。

有人可以纠正我在哪里出错吗? 除192.168.0.0/16外,还可以在印花布网络上使用其他任何面具吗?我无法使用它,因为它已在我们的网络中使用。

除了集群上的Linux节点外,我还想加入Windows节点。 Calico网络是正确的方法还是推荐?我想知道在初始化群集上的网络之前,我可以执行正确的操作

谢谢

2 个答案:

答案 0 :(得分:1)

在奋斗了几个小时之后,我发现kubectl apply命令需要以普通用户而不是root用户身份运行。确保您正在为我们在其中复制.kube / config文件的用户执行命令,否则它将不起作用 之后,我看到我的主人已经准备好了。

答案 1 :(得分:0)

请按照以下步骤解决此问题:

mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

sudo chown $(id -u):$(id -g) $HOME/.kube/config