按照文档 http://timd.cn/k8s/creating-test-cluster/ 执行 1 至 4 步。
在 /etc/hosts
中添加:
192.168.56.101 k8s-101
192.168.56.102 k8s-102
192.168.56.103 k8s-103
注意:
- 按需调整 IP 和 Host
crictl
设置代理crictl
crictl config runtime-endpoint unix:///run/containerd/containerd.sock
mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml
# 搜索 SystemdCgroup,将其值改为 true
mkdir /etc/systemd/system/containerd.service.d
cat > /etc/systemd/system/containerd.service.d/http_proxy.conf << EOF
[Service]
Environment="HTTP_PROXY=http://10.1.1.32:7890"
Environment="HTTPS_PROXY=http://10.1.1.32:7890"
Environment="NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,10.244.0.0/16"
EOF
注意:
- 修改代理服务器地址
- NO_PROXY 需要加入 serviceSubnet 和 podSubnet
重启 containerd:
systemctl daemon-reload && systemctl restart containerd && systemctl enable containerd
crictl pull registry.k8s.io/pause:3.9
kubeadm config print init-defaults >kubeadm-config.yaml
kubeadm-config.yaml:
apiVersion: kubeadm.k8s.io/v1beta3
bootstrapTokens:
- groups:
- system:bootstrappers:kubeadm:default-node-token
token: abcdef.0123456789abcdef
ttl: 24h0m0s
usages:
- signing
- authentication
kind: InitConfiguration
localAPIEndpoint:
advertiseAddress: 192.168.56.101
bindPort: 6443
nodeRegistration:
criSocket: unix:///var/run/containerd/containerd.sock
imagePullPolicy: IfNotPresent
name: k8s-101
taints: null
---
apiServer:
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta3
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns: {}
etcd:
local:
dataDir: /var/lib/etcd
imageRepository: registry.k8s.io
kind: ClusterConfiguration
kubernetesVersion: 1.28.0
networking:
dnsDomain: cluster.local
serviceSubnet: 10.96.0.0/12
podSubnet: 10.244.0.0/16
scheduler: {}