========== all 所有节点==============
-
停止防火墙 并设置hostname
systemctl stop firewalld
分别在3台服务器上修改hostname
hostnamectl set-hostname master
hostnamectl set-hostname node1
hostnamectl set-hostname node2 -
设置node节点映射
vi /etc/hosts
10.24.192.1 master
10.24.192.2 node1
10.24.192.3 node2
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
vim /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
enabled=1
yum install docker-ce kubelet-1.13.6* kubeadm-1.13.6* kubectl-1.13.6* -y
#修改docker网段,避免与宿主机冲突
vim /etc/docker/daemon.json
{
“bip”:“172.100.0.1/16”
}
========== all 所有节点==============
========== master 节点==============
systemctl start docker.service
docker load node-component-imgs.gz
编辑kubelet的配置文件/etc/sysconfig/kubelet,设置其忽略Swap启用的状态错误,内容如下:
KUBELET_EXTRA_ARGS="–fail-swap-on=false"
KUBE_PROXY_MODE=ipvs
systemctl enable docker kubelet
docker pull mirrorgooglecontainers/kube-apiserver:v1.13.6
docker pull mirrorgooglecontainers/kube-controller-manager:v1.13.6
docker pull mirrorgooglecontainers/kube-scheduler:v1.13.6
docker pull mirrorgooglecontainers/kube-proxy:v1.13.6
docker pull mirrorgooglecontainers/pause:3.1
docker pull mirrorgooglecontainers/etcd:3.2.24
docker pull coredns/coredns:1.2.6
docker tag docker.io/mirrorgooglecontainers/kube-apiserver:v1.13.6 k8s.gcr.io/kube-apiserver:v1.13.6
docker tag docker.io/mirrorgooglecontainers/kube-controller-manager:v1.13.6 k8s.gcr.io/kube-controller-manager:v1.13.6
docker tag docker.io/mirrorgooglecontainers/kube-scheduler:v1.13.6 k8s.gcr.io/kube-scheduler:v1.13.6
docker tag docker.io/mirrorgooglecontainers/kube-proxy:v1.13.6 k8s.gcr.io/kube-proxy:v1.13.6
docker tag docker.io/mirrorgooglecontainers/pause:3.1 k8s.gcr.io/pause:3.1
docker tag docker.io/mirrorgooglecontainers/etcd:3.2.24 k8s.gcr.io/etcd:3.2.24
docker tag docker.io/coredns/coredns:1.2.6 k8s.gcr.io/coredns:1.2.6
kubeadm init --kubernetes-version=v1.13.6 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=Swap
“”“初始化完成记录—重要必须要记录,添加node时使用的
kubeadm join 10.24.192.1:6443 --token 8it2a2.wzq4e99nnx5zf6gg --discovery-token-ca-cert-hash sha256:e656597f21739dc3012573166ee993c3d52b76594a47cf186f08d1d92a4bc5e5
“””
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
安装flannel
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/62e44c867a2846fefb68bd5f178daf4da3095ccb/Documentation/kube-flannel.yml
========== master节点 ==============
========== slave节点 ==============
systemctl start docker.service
编辑kubelet的配置文件/etc/sysconfig/kubelet,设置其忽略Swap启用的状态错误,内容如下:
KUBELET_EXTRA_ARGS="–fail-swap-on=false"
systemctl enable docker kubelet
docker pull mirrorgooglecontainers/kube-proxy:v1.13.6
docker tag docker.io/mirrorgooglecontainers/kube-proxy:v1.13.6 k8s.gcr.io/kube-proxy:v1.13.6
docker pull mirrorgooglecontainers/pause:3.1
docker tag docker.io/mirrorgooglecontainers/pause:3.1 k8s.gcr.io/pause:3.1
kubeadm join 10.24.192.1:6443 --token 8it2a2.wzq4e99nnx5zf6gg --discovery-token-ca-cert-hash sha256:e656597f21739dc3012573166ee993c3d52b76594a47cf186f08d1d92a4bc5e5 --ignore-preflight-errors=Swap
========== slave 节点==============