码迷,mamicode.com
首页 > 其他好文 > 详细

部署node节点组件

时间:2019-09-09 19:47:40      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:auth   domain   require   trapper   network   created   systemctl   targe   environ   

部署node节点组件

mv kubelet kube-proxy /opt/kubernetes/bin
chmod +x /opt/kubernetes/bin/* && chmod +x *.sh
./kubelet.sh 172.16.163.130 10.10.10.2
./proxy.sh 172.16.163.130

kubelet.sh

[root@node1 ~]# cat kubelet.sh 
#!/bin/bash

NODE_ADDRESS=${1:-"192.168.1.196"}
DNS_SERVER_IP=${2:-"10.10.10.2"}

cat <<EOF >/opt/kubernetes/cfg/kubelet

KUBELET_OPTS="--logtostderr=true \--v=4 \--address=${NODE_ADDRESS} \--hostname-override=${NODE_ADDRESS} \--kubeconfig=/opt/kubernetes/cfg/kubelet.kubeconfig \--experimental-bootstrap-kubeconfig=/opt/kubernetes/cfg/bootstrap.kubeconfig \--cert-dir=/opt/kubernetes/ssl \--allow-privileged=true \--cluster-dns=${DNS_SERVER_IP} \--cluster-domain=cluster.local \--fail-swap-on=false \--pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0"

EOF

cat <<EOF >/usr/lib/systemd/system/kubelet.service
[Unit]
Description=Kubernetes Kubelet
After=docker.service
Requires=docker.service

[Service]
EnvironmentFile=-/opt/kubernetes/cfg/kubelet
ExecStart=/opt/kubernetes/bin/kubelet \$KUBELET_OPTS
Restart=on-failure
KillMode=process

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable kubelet
systemctl restart kubelet

kubelet.service

[root@node1 ~]# cat  /usr/lib/systemd/system/kubelet.service
[Unit]
Description=Kubernetes Kubelet
After=docker.service
Requires=docker.service

[Service]
EnvironmentFile=-/opt/kubernetes/cfg/kubelet
ExecStart=/opt/kubernetes/bin/kubelet $KUBELET_OPTS
Restart=on-failure
KillMode=process

[Install]
WantedBy=multi-user.target

proxy.sh

[root@node1 ~]# cat proxy.sh 
#!/bin/bash

NODE_ADDRESS=${1:-"192.168.1.200"}

cat <<EOF >/opt/kubernetes/cfg/kube-proxy

KUBE_PROXY_OPTS="--logtostderr=true --v=4 --hostname-override=${NODE_ADDRESS} --kubeconfig=/opt/kubernetes/cfg/kube-proxy.kubeconfig"

EOF

cat <<EOF >/usr/lib/systemd/system/kube-proxy.service
[Unit]
Description=Kubernetes Proxy
After=network.target

[Service]
EnvironmentFile=-/opt/kubernetes/cfg/kube-proxy
ExecStart=/opt/kubernetes/bin/kube-proxy \$KUBE_PROXY_OPTS
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable kube-proxy
systemctl restart kube-proxy

kube-proxy.service

[root@node1 ~]# cat /usr/lib/systemd/system/kube-proxy.service 
[Unit]
Description=Kubernetes Proxy
After=network.target

[Service]
EnvironmentFile=-/opt/kubernetes/cfg/kube-proxy
ExecStart=/opt/kubernetes/bin/kube-proxy $KUBE_PROXY_OPTS
Restart=on-failure

[Install]
WantedBy=multi-user.target

执行完成之后需要添加角色权限

kubectl create clusterrolebinding kubelet-bootstrap   --clusterrole=system:node-bootstrapper   --user=kubelet-bootstrap
  
  clusterrolebinding.rbac.authorization.k8s.io/kubelet-bootstrap created

查看csr列表

  kubectl get csr
[root@master ~]# kubectl get csr
NAME                                                   AGE     REQUESTOR           CONDITION
node-csr-81F5uBehyEyLWco5qavBsxc1GzFcZk3aFM3XW5rT3mw   5m52s   kubelet-bootstrap   Pending
node-csr-Ed0kbFhc_q7qx14H3QpqLIUs0uKo036O2SnFpIheM18   6m56s   kubelet-bootstrap   Pending

授权

[root@master ~]# kubectl  certificate approve node-csr-81F5uBehyEyLWco5qavBsxc1GzFcZk3aFM3XW5rT3mw node-csr-Ed0kbFhc_q7qx14H3QpqLIUs0uKo036O2SnFpIheM18
certificatesigningrequest.certificates.k8s.io/node-csr-81F5uBehyEyLWco5qavBsxc1GzFcZk3aFM3XW5rT3mw approved
certificatesigningrequest.certificates.k8s.io/node-csr-Ed0kbFhc_q7qx14H3QpqLIUs0uKo036O2SnFpIheM18 approved

查看node集群节点信息

[root@master ~]# kubectl get nodes
NAME             STATUS   ROLES    AGE   VERSION
172.16.163.129   Ready    <none>   18s   v1.9.0
172.16.163.130   Ready    <none>   19s   v1.9.0

部署node节点组件

标签:auth   domain   require   trapper   network   created   systemctl   targe   environ   

原文地址:https://www.cnblogs.com/jasonboren/p/11493248.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!