1. 简介
kubernates version : v1.19.0
2. 搭建过程
2.1 设置yum源
vim /etc/yum.repos.d/kubernates.repo
[kubernate]
name=Kubernates Repository
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
2.2 基础组件安装
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernates
yum -y install docker
systemctl enable docker && systemctl start docker
systemctl enable kubelet
2.3 服务器环境设置
关闭 selinux
临时关闭命令
setenforce 0
永久关闭
vim /etc/selinux/config
SELINUX=disabled
关闭防火墙
systemctl stop firewalld
删除 swap
swapoff -a && sysctl -w vm.swappiness=0
2.4 kubeadm 安装
获取默认配置信息
kubeadm config print init-defaults > init.default.yaml
networking:
dnsDomain: cluster.local
serviceSubnet: 10.96.0.0/12
podSubnet: 10.244.0.0/16
修改配置
vim init.default.yaml
拉取所需镜像
kubeadm config images pull --config=init.default.yaml
初始化master
kubeadm init --config=init.default.yaml
2.5 CNI 插件安装
flannel
kubectl apply -f http://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml