K8s Master当作Node使用的方法

1、使用下面的命令操作使得master 可以作为node使用 承载pod

kubectl taint nodes --all node-role.kubernetes.io/master-

可能会出现下面的结果 因为taint(master标记的污点已经被去掉了)没有关系

taint "node-role.kubernetes.io/master" not found
taint "node-role.kubernetes.io/master" not found

2、可以用下面的

kubectl describe nodes master1 |grep Taint

命令确认一下taint已经没有了

[root@master1 ~]# kubectl describe nodes master1 |grep Taint
Taints: <none>
[root@master1 ~]#

3、创建一个应用

kubectl create deployment --image=nginx --replicas=2 http

但是副本数量少的情况下有可能不会落在master机器上 这是k8s自己的策略 可以把

--replicas=20  改大一些  这样才会很明显的 看到pod分配到master和node节点了
注:如果想只起两个副本且必须分配到两个机器上 请参考nodeSelector以及亲和性和反亲和性的的用法,以后后续会写文章说明
[root@master1 ~]# kubectl get pods -o wide |grep http-54
http-54cc68bd9b-62gmc        1/1     Running   0          142m   10.130.209.203   node1     <none>           <none>
http-54cc68bd9b-7zkxj        1/1     Running   0          106m   10.130.209.208   node1     <none>           <none>
http-54cc68bd9b-95f74        1/1     Running   0          106m   10.129.40.90     master1   <none>           <none>
http-54cc68bd9b-9ntxh        1/1     Running   0          142m   10.130.209.201   node1     <none>           <none>
http-54cc68bd9b-b7q7l        1/1     Running   0          142m   10.130.209.202   node1     <none>           <none>
http-54cc68bd9b-bp5z4        1/1     Running   0          106m   10.130.209.211   node1     <none>           <none>
http-54cc68bd9b-fqtbh        1/1     Running   0          143m   10.130.209.200   node1     <none>           <none>
http-54cc68bd9b-g74dt        1/1     Running   0          106m   10.130.209.213   node1     <none>           <none>
http-54cc68bd9b-hj5w8        1/1     Running   0          106m   10.130.209.210   node1     <none>           <none>
http-54cc68bd9b-jtdg5        1/1     Running   0          106m   10.129.40.91     master1   <none>           <none>
http-54cc68bd9b-ktxhp        1/1     Running   0          142m   10.130.209.205   node1     <none>           <none>
http-54cc68bd9b-pxg7s        1/1     Running   0          106m   10.130.209.214   node1     <none>           <none>
http-54cc68bd9b-rbhmh        1/1     Running   0          106m   10.129.40.89     master1   <none>           <none>
http-54cc68bd9b-s7rx7        1/1     Running   0          143m   10.130.209.199   node1     <none>           <none>
http-54cc68bd9b-svsc6        1/1     Running   0          142m   10.130.209.206   node1     <none>           <none>
http-54cc68bd9b-tddbv        1/1     Running   0          106m   10.130.209.209   node1     <none>           <none>
http-54cc68bd9b-tjpdj        1/1     Running   0          106m   10.130.209.212   node1     <none>           <none>
http-54cc68bd9b-vrzv6        1/1     Running   0          106m   10.129.40.92     master1   <none>           <none>
http-54cc68bd9b-vw6wv        1/1     Running   0          142m   10.130.209.204   node1     <none>           <none>
http-54cc68bd9b-x86rz        1/1     Running   0          106m   10.130.209.207   node1     <none>           <none>
[root@master1 ~]#

 

上一篇:kvm虚拟化管理平台WebVirtMgr部署-完整记录(2)


下一篇:AngularJS $injectorMinErr('modulerr' 依赖注入错误