我正在尝试在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
然后我得到输出:
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"
我的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
非常感谢您的帮助,甚至提供一些有关自调试的建议。谢谢。
答案 0 :(得分:6)
如果kubernete版本高于1.16,请使用以下链接安装calico。
kubectl apply -f https://docs.projectcalico.org/v3.9/manifests/calico.yaml
coredns和calico应该处于运行状态。
答案 1 :(得分:1)
您必须按照post.中所述,为pod-network-cidr和apiserver-advertise-address使用单独的范围 请尝试删除群集,然后使用其他网络配置再次重新初始化它:
开始于:
运行此命令以还原通过“ kubeadm init”对该主机所做的任何更改,或者 “ kubeadm加入”。
kubeadm reset
然后再次初始化群集(IP地址是一个安全的示例)。
kubeadm init --pod-network-cidr=192.168.0.0/16 --apiserver-advertise-address=10.0.0.20
此外,如果您按照在教程中所链接的主节点上的方式运行它,则可以跳过--apiserver-advertise-address,因为它使用当前计算机的默认网关。
从kubeadm documentation
中运行标准命令要使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/16
至kubeadm init
。注意 印花布仅在amd64
上工作。
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 documentation官方网站开始重新安装kubeadm。