应用 pod network (calico) 以“无法识别..”“没有匹配的种类”结尾

Mic*_*wly 3 kubernetes

我正在尝试在 ubuntu 上构建本地裸机 kubernetes 集群。

按照分步指南(https://www.youtube.com/watch?v=UWg3ORRRF60)我已经成功安装了 kubernetes master 并收到了成功消息“您的 Kubernetes master 已成功初始化!” 使用 'kubeadm init --pod-network-cidr=10.0.0.0/16 --apiserver-advertise-address=10.0.0.20' 命令初始化集群后。

现在下一步是部署一个 pod 网络,所以我使用了 calico,运行以下命令:

kubectl apply -f https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml --validate=false
Run Code Online (Sandbox Code Playgroud)

我得到输出:

unable to recognize "https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml": no matches for kind "ConfigMap" in version "v1"
unable to recognize "https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml": no matches for kind "DaemonSet" in version "extensions/v1beta1"
unable to recognize "https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml": no matches for kind "Service" in version "v1"
unable to recognize "https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml": no matches for kind "DaemonSet" in version "extensions/v1beta1"
unable to recognize "https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml": no matches for kind "Deployment" in version "extensions/v1beta1"
unable to recognize "https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml": no matches for kind "ServiceAccount" in version "v1"
unable to recognize "https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml": no matches for kind "ServiceAccount" in version "v1"
Run Code Online (Sandbox Code Playgroud)

我的 kubectl 版本输出是:

Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.1", GitCommit:"b1b29978270dc22fecc592ac55d903350454310a", GitTreeState:"clean", BuildDate:"2018-07-17T18:53:20Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
Error from server (NotFound): the server could not find the requested resource
Run Code Online (Sandbox Code Playgroud)

将不胜感激任何帮助,甚至一些自我调试的建议。谢谢。

Sha*_*ain 6

如果 kubernete 版本高于 1.16,请使用以下链接安装 calico。

kubectl apply -f https://docs.projectcalico.org/v3.9/manifests/calico.yaml
Run Code Online (Sandbox Code Playgroud)

请检查节点状态以确认 calico 是否安装成功。 在此处输入图片说明

coredns 和 calico 应该处于运行状态。

在此处输入图片说明


aur*_*ius 5

正如本文所述,您必须为 pod-network-cidr 和 apiserver-advertise-address 使用不同的范围 请尝试删除集群并使用不同的网络配置重新启动它:

从...开始:

运行此命令以还原“kubeadm init”或“kubeadm join”对此主机所做的任何更改。

kubeadm reset       
Run Code Online (Sandbox Code Playgroud)

然后再次初始化集群(IP 地址是一个安全的例子)。

kubeadm init --pod-network-cidr=192.168.0.0/16 --apiserver-advertise-address=10.0.0.20 
Run Code Online (Sandbox Code Playgroud)

此外,如果您像在主节点上链接的教程中那样运行它,您可以跳过 --apiserver-advertise-address 因为它使用当前机器的默认网关。

运行 kubeadm文档中的标准命令

要使 kubectl 为您的非 root 用户工作,请运行这些命令,它们也是kubeadm init 输出的一部分 :

mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config

或者,如果您是 root 用户,则可以运行:

export KUBECONFIG=/etc/kubernetes/admin.conf

之后安装网络附加组件: 对于Calico

为了使网络策略正常工作,您需要传递 --pod-network-cidr=192.168.0.0/16kubeadm init. 请注意,Calicoamd64 仅适用于 。

kubectl apply -f https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml kubectl apply -f https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubernetes-datastore/calico-networking/1.7/calico.yaml 您还可以从Kubernetes官方文档开始,了解如何安装 kubeadm。