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

Error when applying Calico network on Kubernetes cluster

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

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

我想使用 calico 网络。由于我不能使用 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 以外的任何其他掩码与 calico 网络?我不能使用它,因为它已经在我们的网络中使用了。

除了集群上的 linux 个节点外,我还想加入 Windows 个节点。 Calico 网络是一种正确的方法还是建议是其他方法。我想知道在我的集群上初始化网络之前我可以做正确的事

谢谢

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

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

mkdir -p $HOME/.kube

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

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