1. Ubuntu Static IP address settings
Edit /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto ens33
iface ens33 inet static
address 172.16.7.10/24
gateway 172.16.7.2
dns-nameserver 114.114.114.114
~
After cloning the VM, after changing the IP address, the original address is still there, and the new address becomes the secondary IP address.
Solution:
ip addr flush dev ens33
ifdown etns33
ifup ens33
2. kubeadm installation
Reference official website:
https://kubernetes.io/zh/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
Note that firewall/selinux and swap are disabled (swapoff -a)
The kernel enables ipv4 forwarding
vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
Images used for installation, download the specified version:
-rw-r--r-- 1 root root 19377756 Mar 2 20:23 containerd.io_1.2.13-1_amd64.deb
-rw-r--r-- 1 root root 22841888 Mar 11 12:46 docker-ce_19.03.8~3-0~ubuntu-xenial_amd64.deb
-rw-r--r-- 1 root root 42514382 Mar 11 12:46 docker-ce-cli_19.03.8~3-0~ubuntu-xenial_amd64.deb
-rw-r--r-- 1 root root 8776166 Jul 9 2019 cri-tools_1.13.0-00_amd64_6930e446a683884314deef354fbd8a7c5fc2be5c69c58903ad83b69b42529da4.deb
-rw-r--r-- 1 root root 8163348 Mar 26 08:05 kubeadm_1.18.0-00_amd64_7931ad3141d9e137be4cd8e2c8ab680a2b98bd1ed6e8d4145e35d547fd0ad709.deb
-rw-r--r-- 1 root root 8822028 Mar 26 08:06 kubectl_1.18.0-00_amd64_265ff656100b82f5f3d80f5c8ab12f8a8c1c54c72e509e4d2612dec464eb64f6.deb
-rw-r--r-- 1 root root 19431624 Mar 26 08:08 kubelet_1.18.0-00_amd64_22b5dc9edb80f7791036fb47223c1cbbeb7685f332cdcbf9cfa12b858f9d19bb.deb
-rw-r--r-- 1 root root 6473084 Mar 26 2019 kubernetes-cni_0.7.5-00_amd64_b38a324bb34f923d353203adf0e048f3b911f49fa32f1d82051a71ecfe2cd184.deb
-rw-r--r-- 1 root root 107078660 Mar 5 2018 rkt_1.29.0-1_amd64_ea87d719359030f33fd48890875c934135c62eccda72c37d79ff604307b905b5.deb
When installing docker/kubernetes, the system will report missing components. Follow the prompts to install.
apt install ebtables socat ethtool conntrack libnetfilter-conntrack3
Use the configuration file to specify the domestic kubernetes version and source
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
mode: "ipvs"
---
apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration
kubernetesVersion: v1.18.1
apiServer:
certSANs:
- "172.16.7.10"
extraArgs:
allow-privileged: "true"
feature-gates: "VolumeSnapshotDataSource=true,CSINodeInfo=true,CSIDriverRegistry=true"
controlPlaneEndpoint: "172.16.7.10:6443"
etcd:
local:
dataDir: /var/lib/etcd
networking:
# This CIDR is a Canal default. Substitute or remove for your CNI provider.
podSubnet: "10.244.0.0/16"
controllerManager:
extraArgs:
address: 0.0.0.0
scheduler:
extraArgs:
address: 0.0.0.0
imageRepository: gcr.azk8s.cn/google-containers
kubeadm init
Add parameters: --ignore-preflight-errors=all, including work node join
CNI simply choose flannel
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml
3. Complete
root@master:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 24h v1.18.0
node1 Ready <none> 24h v1.18.0
node2 Ready <none> 24h v1.18.0
```