Kubernetes部署:错误:无法创建部署:

ioekq8ef  于 2022-12-11  发布在  Kubernetes
关注(0)|答案(2)|浏览(452)

Environment Details:

Kubernetes version: `v1.20.2`
Master Node: `Bare Metal/Host OS: CentOS 7`
Worker Node: `VM/Host OS: CentOS 7`

I have installed & configured the Kubernetes cluster, the Master node on the bare metal server & the worker node on windows server 2012 HyperV VM. Both master and worker nodes have the same Kubernetes version ( v1.20.2) & centos7. Successfully joined worker node to master, below is the get nodes status.

$ kubectl get nodes

**NAME             STATUS ROLES               AGE  VERSION

k8s-worker-node1 Ready  <none>              2d2h v1.20.2

master-node      Ready control-plane,master 3d4h v1.20.2**

While creating a deployment on the worker node I am getting the below error message.
On worker node, I issued the following command.

$ kubectl create deployment nginx-depl --image=nginx

Error message is:
error: failed to create deployment: Post “http://localhost:8080/apis/apps/v1/namespaces/default/deployments?fieldManager=kubectl-create”: dial tcp: lookup localhost on 8.8.8.8:53: no such host

please help me to resolve this issue as I am not able to understand what is the problem.

6yt4nkrj

6yt4nkrj1#

您似乎正在工作节点上发出kubectl create deployment命令。这将不起作用,因为kubectl命令与kub-apiserver通信以进行集群通信。由于apiserver不在工作节点上运行,因此在其上执行命令将引发错误。
主节点上以非root用户身份执行相同的kubectl命令,并执行以下附加命令:

$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
$ kubectl create deployment nginx-depl --image=nginx
h5qlskok

h5qlskok2#

可能你以前运行过minikube start。我正在学习,在一个类和另一个类之间,我忘记运行这个命令了。我希望我能帮助一些人。
这对我很有效。

相关问题