yum方式安裝kubernetes

環境準備 master01 node01 node02,連通網絡,修改hosts文件,確認3臺主機相互解析node

vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.201 master01
192.168.1.202 node01
192.168.1.203 node02

主機配置阿里YUM源docker

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup && curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

 

開始部署kubernetesvim

1.在master01安裝etcdapi

yum install etcd -y

安裝完成,修改etcd配置文件/etc/etcd/etcd.conf網絡

vim /etc/etcd/etcd.conf

ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379" #修改監聽地址
ETCD_LISTEN_CLIENT_URLS="http://192.168.1.201:2379"    #修改etcd地址爲本機地址

設置服務啓動dom

systemctl start etcd && systemctl enable etcd

2.在全部主機安裝kubernetescurl

yum install kubernetes -y

3.配置masteride

vim /etc/kubernetes/config

KUBE_MASTER="--master=http://192.168.1.201:8080"    #修改kube_master地址
vim /etc/kubernetes/apiserver

KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0" #修改監聽地址
KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.1.201:2379" #修改etcd地址
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"    #刪除認證參數ServiceAccount

設置服務啓動,啓動順序apiserver>scheduler=controller-manageratom

systemctl start docker && systemctl enable docker
systemctl start kube-apiserver && systemctl enable kube-apiserver
systemctl start kube-scheduler && systemctl enable kube-scheduler
systemctl start kube-controller-manager && systemctl enable kube-controller-manager

4.配置nodeurl

vim /etc/kubernetes/config

KUBE_MASTER="--master=http://192.168.1.201:8080"    #修改master地址
vim /etc/kubernetes/kubelet

KUBELET_ADDRESS="--address=192.168.1.202" #修改kubelet地址
KUBELET_HOSTNAME="--hostname-override=192.168.1.202" #修改kubelet主機名
KUBELET_API_SERVER="--api-servers=http://192.168.1.201:8080"    #修改apiserver地址

設置服務啓動

systemctl start docker && systemctl enable docker
systemctl start kubelet && systemctl enable kubelet
systemctl start kube-proxy && systemctl enable kube-proxy

5.部署完成,查看集羣狀態

kubectl get nodes
[root@node02 kubernetes]# kubectl -s http://192.168.1.201:8080 get nodes -o wide
NAME            STATUS    AGE       EXTERNAL-IP
192.168.1.202   Ready     29s       <none>
192.168.1.203   Ready     16m       <none>

 6.在全部主機安裝flannel

yum install flannel -y
vim /etc/sysconfig/flanneld

FLANNEL_ETCD_ENDPOINTS="http://192.168.1.201:2379"    #修改etcd地址
etcdctl mk /atomic.io/network/config '{ "Network": "172.16.0.0/16" }'    #在etcd主機設置容器網絡

master主機重啓服務

systemctl start flanneld && systemctl enable flanneld
systemctl restart docker
systemctl restart kube-apiserver
systemctl restart kube-scheduler
systemctl restart kube-controller-manager

node主機重啓服務

systemctl start flanneld && systemctl enable flanneld
systemctl restart docker
systemctl restart kubelet
systemctl restart kube-proxy
相關文章
相關標籤/搜索