标签:wap flannel ber cidr net document track disco print
主机 192.168.254.10 k8s-master
192.168.254.20 k8s-node1
192.168.254.21 k8s-node2
所有节点都要执行
关闭swap
swapoff -a
# 注释掉/etc/fstab文件swap的行
cat <<EOF>> /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
vm.swappiness=0
EOF
sysctl --system
systemctl stop firewalld
systemctl disable firewalld
1. 临时 setenforce 0
2. 永久关闭
vim /etc/sysconfig/selinux
SELINUX=enforcing
替换为
SELINUX=disabled
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://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
EOF
wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
三个节点上执行,实际搭建中使用的是最新的docker-ce
yum install kubeadm
systemctl enable docker
systemctl start docker
systemctl enable kubelet
# master上不安装kubelet,不能完成init
三个节点都要执行
将docker-ce的cgroup驱动改为systemd
cat <<EOF>> /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
在多网卡的情况需要设置kubelet的ip
所节点都要配置,其它两个节点上将192.168.254.10替换为相应的ip
cat <<EOF>> /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS=--node-ip=192.168.254.10
EOF
所有节点上都要做
cat <<EOF>> /etc/modules-load.d/lvs.conf
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
nf_conntrack_ipv4
EOF
# kubeadm config images list
kubeadm config images list \
--image-repository registry.aliyuncs.com/google_containers
* 生成配置文件
```bash
kubeadm config print init-defaults >kubeadmin-config.yml
cat kubeadmin-config.yml
...
localAPIEndpoint:
advertiseAddress: 192.168.254.10
bindPort: 6443
...
imageRepository: registry.aliyuncs.com/google_containers
...
kubernetesVersion: v1.19.2
networking:
dnsDomain: cluster.local
podSubnet: 10.244.0.0/16
serviceSubnet: 10.96.0.0/12
scheduler: {}
---
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
mode: "ipvs"
kubeadm init --config kubeadmin-config.yml --upload-certs | tee kubeadmin-init.log
也可以使用下面的命令安装
kubeadm init --kubernetes-version=1.19.2 --apiserver-advertise-address=192.168.254.10 --image-repository registry.aliyuncs.com/google_containers --service-cidr=10.64.0.0/24 --pod-network-cidr=10.244.0.0/24
# - --port=0
然后重启kubelet
service kubelet restart
kubeadm join 192.168.254.10:6443 --token 1ijhgv.xgkkjhz2xu1lsm48 --discovery-token-ca-cert-hash sha256:55c9fd837cc2419e57045d16d52097dda4438347d35ef961bab845dda3782288
不安装各node会noready,kube-flannel.yml可以下载后apply,可以在任何节点执行,执行中每个节点都会去pull image
ubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
标签:wap flannel ber cidr net document track disco print
原文地址:https://blog.51cto.com/penguintux/2540346