Kubernetes 解决spec.template.spec.containers[0].securityContext.privileged: Forbidden: disallowed by policy问题

系统:CentOS7

在master结点和Node1、Node2结点上分别通过vi /etc/kubernetes/config修改其中的KUBE_APISERVER_OPTS,改成如下形式:

KUBE_APISERVER_OPTS='--allow_privileged=true'

注意:在三个系统中都需要使用

在Master结点中使用如下的方式重启api-server并且观察是否处于active状态。

systemctl daemon-reload

systemctl restart kube-apiserver

systemctl status -l kube-apiserver

在Node1、Node2结点上使用如下指令,重启并且观察kubelet是否是active状态

systemctl daemon-reload

systemctl restart kubelet

systemctl status -l kubelet

然后,将自己创建的守护进程启动,观察在每个计算机结点上pod的部署情况。

[root@localhost ~]# kubectl create -f node-exporter-daemonset.yml

查看守护进程的部署情况和监控情况:

[root@localhost ~]# kubectl get pods --namespace=monitoring -o wide
NAME READY STATUS RESTARTS AGE IP NODE
node-exporter-04xz1 1/1 Running 0 13m 192.168.196.10 192.168.196.10
node-exporter-wdx07 1/1 Running 0 13m 192.168.196.20 192.168.196.20

可见在每个结点上都部署了守护进程,并且仅一个,IP绑定了宿主机的IP。

猜你喜欢

转载自www.cnblogs.com/randy-lo/p/13371328.html