• 欢迎访问运维搬运工网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站。
  • 本站一年会员:100元 ,两年会员:180元 ,永久会员:380元
  • 这世界就是,一些人总在昼夜不停地运转,而另外一些人,起床就发现世界已经变了。
  • 本博客推广的是知识付费,用赞助的方式实现博客维护,不以赚钱为目的的博客

k8s集群node节点的安装

node节点安装如下服务

[root@k8s-master ~]# yum install kubernetes-node.x86_64 -y

[root@k8s-node1 ~]# yum install kubernetes-node.x86_64 -y

[root@k8s-node2 ~]# yum install kubernetes-node.x86_64 -y

安装node节点的时候,系统会自动给你安装上docker

先在master节点上配置node服务

[root@k8s-master ~]# vim /etc/kubernetes/config 

# How the controller-manager, scheduler, and proxy find the apiserver
KUBE_MASTER="--master=http://10.0.0.11:8080"

配置监听地址等信息

[root@k8s-master ~]# vim /etc/kubernetes/kubelet

KUBELET_ADDRESS="--address=10.0.0.11"

监听端口

KUBELET_PORT="--port=10250"

KUBELET_HOSTNAME="--hostname-override=k8s-master"

KUBELET_API_SERVER="--api-servers=http://10.0.0.11:8080"

启动master节点上等node服务

默认情况下docker是没有启动等

[root@k8s-master ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: http://docs.docker.com

启动服务之后就启动了

[root@k8s-master ~]# systemctl start kubelet.service
[root@k8s-master ~]# systemctl status docker 
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2019-08-19 21:15:39 CST; 35s ago
Docs: http://docs.docker.com
Main PID: 2607 (dockerd-current)
Memory: 18.8M
CGroup: /system.slice/docker.service
├─2607 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default...
└─2613 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --...

Aug 19 21:15:38 k8s-master dockerd-current[2607]: time="2019-08-19T21:15:38.624051980+08:00" level=warning msg="D...stem"
Aug 19 21:15:38 k8s-master dockerd-current[2607]: time="2019-08-19T21:15:38.666369118+08:00" level=info msg="Grap...onds"
Aug 19 21:15:38 k8s-master dockerd-current[2607]: time="2019-08-19T21:15:38.667331861+08:00" level=info msg="Load...art."
Aug 19 21:15:38 k8s-master dockerd-current[2607]: time="2019-08-19T21:15:38.818235867+08:00" level=info msg="Fire...alse"
Aug 19 21:15:38 k8s-master dockerd-current[2607]: time="2019-08-19T21:15:38.931095228+08:00" level=info msg="Defa...ress"
Aug 19 21:15:38 k8s-master dockerd-current[2607]: time="2019-08-19T21:15:38.973522094+08:00" level=info msg="Load...one."
Aug 19 21:15:38 k8s-master dockerd-current[2607]: time="2019-08-19T21:15:38.991848845+08:00" level=info msg="Daem...tion"
Aug 19 21:15:38 k8s-master dockerd-current[2607]: time="2019-08-19T21:15:38.991912921+08:00" level=info msg="Dock....13.1
Aug 19 21:15:39 k8s-master dockerd-current[2607]: time="2019-08-19T21:15:39.004770430+08:00" level=info msg="API ...sock"
Aug 19 21:15:39 k8s-master systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.

设置成开机启动

[root@k8s-master ~]# systemctl enable kubelet.service
Created symlink from /etc/systemd/system/multi-user.target.wants/kubelet.service to /usr/lib/systemd/system/kubelet.service.

启动kube-proxy

[root@k8s-master ~]# systemctl start kube-proxy.service
[root@k8s-master ~]# systemctl enable kube-proxy.service
Created symlink from /etc/systemd/system/multi-user.target.wants/kube-proxy.service to /usr/lib/systemd/system/kube-proxy.service.

查看有没有node节点已启动

[root@k8s-master ~]# kubectl get nodes
NAME STATUS AGE
k8s-master Ready 4m

配置node1和node2

[root@k8s-node1 ~]# vim /etc/kubernetes/config 

KUBE_MASTER="--master=http://10.0.0.11:8080"

[root@k8s-node1 ~]# vim /etc/kubernetes/kubelet 

KUBELET_ADDRESS="--address=10.0.0.12"


KUBELET_PORT="--port=10250"

KUBELET_HOSTNAME="--hostname-override=k8s-node1"

KUBELET_API_SERVER="--api-servers=http://10.0.0.11:8080"

启动node1服务

[root@k8s-node1 ~]# systemctl start kubelet.service
[root@k8s-node1 ~]# systemctl enable kubelet.service
Created symlink from /etc/systemd/system/multi-user.target.wants/kubelet.service to /usr/lib/systemd/system/kubelet.service.
[root@k8s-node1 ~]# systemctl start kube-proxy.service
[root@k8s-node1 ~]# systemctl enable kube-proxy.service
Created symlink from /etc/systemd/system/multi-user.target.wants/kube-proxy.service to /usr/lib/systemd/system/kube-proxy.service.

再次在master上检测node服务

[root@k8s-master ~]# kubectl get nodes
NAME STATUS AGE
k8s-master Ready 11m
k8s-node1 Ready 1m

配置node2

[root@k8s-node2 ~]# vim /etc/kubernetes/config

KUBE_MASTER="--master=http://10.0.0.11:8080"

[root@k8s-node2 ~]# vim /etc/kubernetes/kubelet 

KUBELET_ADDRESS="--address=10.0.0.13"

KUBELET_HOSTNAME="--hostname-override=k8s-node2"

KUBELET_API_SERVER="--api-servers=http://10.0.0.11:8080"

启动node2

[root@k8s-node2 ~]# systemctl start kubelet.service
[root@k8s-node2 ~]# systemctl enable kubelet.service
Created symlink from /etc/systemd/system/multi-user.target.wants/kubelet.service to /usr/lib/systemd/system/kubelet.service.
[root@k8s-node2 ~]# systemctl start kube-proxy.service
[root@k8s-node2 ~]# systemctl enable kube-proxy.service
Created symlink from /etc/systemd/system/multi-user.target.wants/kube-proxy.service to /usr/lib/systemd/system/kube-proxy.service.

master上查看节点

[root@k8s-master ~]# kubectl get nodes
NAME STATUS AGE
k8s-master Ready 3h
k8s-node1 Ready 3h
k8s-node2 Ready 55s

删除节点用如下命令

[root@k8s-master ~]# kubectl delete node k8s-node2

运维搬运工 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:k8s集群node节点的安装
喜欢 (0)
[扫描二维码]
分享 (0)
大自然搬运工
关于作者:
不是路不平,而是你不行。到底行不行,看你停不停。只要你不停,早晚都能行。
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址