ubuntu16 kubernetes1.6安裝(6、node節點部署)

節點啓動順序爲:一、etcd 二、flannel 三、docker 四、kubelet 和kube-proxy,本文flannel未使用systemd部署,所以寫成腳本添加到rc.local中去。
一、拷貝kubectl安裝中生成的配置文件做爲kubelet的啓動生成文件,這樣就不用再進行csr驗證。
cp ~/.kube/config /etc/kubernetes/kubelet.kubeconfig
二、kubelet以及kube-proxy的systemd文件見下,本文安裝了三個節點,按照具體狀況修改文件。
root@ubuntu133:/etc/systemd/system# cat kubelet.service
[Unit]
Description=Kubernetes Kubelet Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=docker.service
Requires=docker.service
[Service]
WorkingDirectory=/var/lib/kubelet
ExecStart=/usr/local/bin/kubelet \
--logtostderr=false \
--log-dir=/var/log/kubernetes \
--v=2 \
--allow-privileged=true \
--api-servers=http://192.168.15.132:8080 \
--address=192.168.15.133 \
--hostname-override=192.168.15.133 \
--pod-infra-container-image=docker.xxx.com:5000/pod-infrastructure:v2017 \ #該鏡像須要自行下載,放置到私有倉庫中
--cgroup-driver=cgroupfs \
--cluster-dns=10.254.0.2 \
--experimental-bootstrap-kubeconfig=/etc/kubernetes/bootstrap.kubeconfig \
--kubeconfig=/etc/kubernetes/kubelet.kubeconfig \
--require-kubeconfig \
--cert-dir=/etc/kubernetes/ssl \
--cluster-domain=cluster.local \ #此處應注意,後面dns配置文件中會遇到
--hairpin-mode promiscuous-bridge \
--serialize-image-pulls=false
Restart=on-failure
[Install]
WantedBy=multi-user.targetnode

root@ubuntu133:/etc/systemd/system# cat kube-proxy.service
[Unit]
Description=Kubernetes Kube-Proxy Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network.target
[Service]
ExecStart=/usr/local/bin/kube-proxy \
--logtostderr=false \
--log-dir=/var/log/kubernetes \
--master=http://192.168.15.132:8080 \
--bind-address=192.168.15.133 \
--hostname-override=192.168.15.133 \
--kubeconfig=/etc/kubernetes/kube-proxy.kubeconfig \
--cluster-cidr=10.254.0.0/16
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.targetnginx

systemctl daemon-reload
systemctl enable kubelet
systemctl start kubelet
systemctl status kubelet
systemctl enable kube-proxy
systemctl start kube-proxy
systemctl status kube-proxygit

三、驗證
root@ubuntu132:/etc/systemd/system# kubectl get node
NAME STATUS AGE VERSION
192.168.15.132 Ready 7d v1.6.0
192.168.15.133 Ready 9d v1.6.0
192.168.15.134 Ready 9d v1.6.0github

四、測試集羣,跑一個容器並建立一個svc
root@ubuntu132:~/dnsyaml# kubectl run nginx --replicas=2 --labels="run=load-balancer-example" --image=docker.xxx.com:5000/nginx1.9:v2017 --port=80
deployment "nginx" created
root@ubuntu132:~/dnsyaml# kubectl expose deployment nginx --type=NodePort --name=test
service "test" exposeddocker

oot@ubuntu132:~/dnsyaml# kubectl get svc test
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
test 10.254.238.72 <nodes> 80:8455/TCP 17bootstrap

在節點上測試,kubelet節點上,service僅僅能在node節點上進行測試,如需其餘非kubelet測試就是用nodeport進行驗證 curl http://192.168.15.132:8455
root@ubuntu132:~/dnsyaml# curl "10.254.238.72 80"
顯示nginx網頁內容!ubuntu

相關文章
相關標籤/搜索