K8S for CentOS 7.6部署
阿新 • • 發佈:2022-05-17
1 環境介紹
作業系統:CentOS 7.6
Docker: 19.03.15
Kubernetes:1.20.0
IP | 主機名 | 角色 |
192.168.1.73 | master | Master |
192.168.1.74 | node1 | Node |
192.168.1.75 | node2 | Node |
2 準備工作
1. 關閉selinux
[root]# setenforce 0
[root]# vi /etc/selinux/config
SELINUX=disabled
2. 關閉firewalld
[root]# systemctl stop firewalld [root]# systemctl disable firewall
3. 關閉swap
[root]# swapoff -a
[root]# vi /etc/fstab
#/dev/mapper/centos-swap swap swap defaults 0 0
4. 修改grub
[root]# vi /etc/default/grub
新增如下部分:
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
5. 配置hosts檔案
[root]# vi /etc/hosts 192.168.1.73 master 192.168.1.74 node1 192.168.1.75 node2
3. 安裝K8S
3.1 安裝Docker
三個節點均安裝Docker
[root]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo [root]# yum install docker-ce-19.03.15 -y [root]# cat > /etc/docker/daemon.json << EOF { "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" }, "storage-driver": "overlay2" } EOF [root]# systemctl enable docker [root]# systemctl start docker
3.2 安裝kubelet、kubeadm
三個節點均需要安裝。
[root]# cat > /etc/yum.repos.d/kubernetes.repo << EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
[root]# yum install -y kubelet-1.20.0 kubeadm-1.20.0
3.3 Master端初始化
Master端進行群集初始化
[root]# kubeadm init --apiserver-advertise-address=192.168.1.73 --pod-network-cidr=192.168.0.0/16 --image-repository registry.aliyuncs.com/google_containers
未完,待更新!!!