一、机器配置信息
[root@localhost ~]# cat /etc/hosts|grep 192.168.5
192.168.5.200 master
192.168.5.201 node01
192.168.5.202 node02
二、安装docker环境
参考文档《docker安装(阿里云)》
[root@node01 tmp]# wget https://raw.githubusercontent.com/xiangys0134/deploy/master/software_install/docker/docker_install.sh && bash docker_install.sh
[root@master ~]# systemctl stop firewalld.service
三、配置k8s镜像源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vi k8s.repo
[kubernetes]
name=Kubernetes Repo
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
enabled=1
[root@localhost ~]# rpm --import https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg //每个节点均需导入
四、k8s安装
- master安装
[root@master ~]# swapoff -a //关闭虚拟内存
[root@master ~]# echo vm.swappiness = 0 >> /etc/sysctl.conf
[root@master ~]# sysctl -p
[root@master ~]# yum install kubelet-1.14.3 kubeadm-1.14.3 kubectl-1.14.3 -y
[root@master ~]# systemctl start kubelet.service
去docker仓库下载对应镜像
docker pull xiangys0134/kube-apiserver:v1.14.3
docker pull xiangys0134/kube-controller-manager:v1.14.3
docker pull xiangys0134/kube-scheduler:v1.14.3
docker pull xiangys0134/kube-proxy:v1.14.3
docker pull xiangys0134/etcd:3.3.10
docker pull xiangys0134/coredns:1.3.1
docker pull xiangys0134/pause:3.1
提交tag
docker tag xiangys0134/kube-apiserver:v1.14.3 k8s.gcr.io/kube-apiserver:v1.14.3
docker tag xiangys0134/kube-controller-manager:v1.14.3 k8s.gcr.io/kube-controller-manager:v1.14.3
docker tag xiangys0134/kube-scheduler:v1.14.3 k8s.gcr.io/kube-scheduler:v1.14.3
docker tag xiangys0134/kube-proxy:v1.14.3 k8s.gcr.io/kube-proxy:v1.14.3
docker tag xiangys0134/pause:3.1 k8s.gcr.io/pause:3.1
docker tag xiangys0134/etcd:3.3.10 k8s.gcr.io/etcd:3.3.10
docker tag xiangys0134/coredns:1.3.1 k8s.gcr.io/coredns:1.3.1
//记录下join信息
[root@master tmp]# kubeadm init --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=NumCPU --kubernetes-version=v1.14.3
[root@master tmp]# kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
[root@master tmp]# mkdir -p HOME/.kube
[root@master tmp]# sudo cp -i /etc/kubernetes/admin.confHOME/.kube/config
[root@master tmp]# sudo chown (id -u):(id -g) $HOME/.kube/config
[root@master tmp]# kubectl get nodes //查看节点
NAME STATUS ROLES AGE VERSION
master NotReady master 2m22s v1.14.3
- slave节点安装
[root@node01 tmp]# yum install kubelet-1.14.3 kubeadm-1.14.3 kubectl-1.14.3 -y
[root@node01 tmp]# swapoff -a
[root@node01 tmp]# sysctl -p
[root@node01 tmp]# docker pull xiangys0134/kube-proxy:v1.14.3
[root@node01 tmp]# docker pull xiangys0134/pause:3.1
[root@node01 tmp]# docker tag xiangys0134/kube-proxy:v1.14.3 k8s.gcr.io/kube-proxy:v1.14.3
[root@node01 tmp]# docker tag xiangys0134/pause:3.1 k8s.gcr.io/pause:3.1
//节点加集群
kubeadm join 192.168.5.200:6443 --token xfdppl.9a5zh6fmw0bgap2p \
--discovery-token-ca-cert-hash sha256:1816eeb57e99d1acddc9d6f89acfbab9082cd99fa17dbb29293fbc37d9b74704
留言