安装 Kubernetes v1.28.2
按照文档 http://timd.cn/k8s/creating-test-cluster/ 执行 1 至 4 步。
在 /etc/hosts 中添加:
x
192.168.56.101 k8s-101
192.168.56.102 k8s-102
192.168.56.103 k8s-103
注意:
按需调整 IP 和 Host
crictl
设置代理crictl
x
crictl config runtime-endpoint unix:///run/containerd/containerd.sock
mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml
# 搜索 SystemdCgroup,将其值改为 true
x
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:
x
systemctl daemon-reload && systemctl restart containerd && systemctl enable containerd
x
crictl pull registry.k8s.io/pause:3.9
x
kubeadm config print init-defaults >kubeadm-config.yaml
修改 localAPIEndpoint.advertiseAddress
修改 nodeRegistration.name
添加 networking.pubSubnet
kubeadm-config.yaml:
x
apiVersion kubeadm.k8s.io/v1beta3
bootstrapTokens
groups
system:bootstrappers:kubeadm:default-node-token
token abcdef.0123456789abcdef
ttl 24h0m0s
usages
signing
authentication
kind InitConfiguration
localAPIEndpoint
advertiseAddress192.168.56.101
bindPort6443
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
kubernetesVersion1.28.0
networking
dnsDomain cluster.local
serviceSubnet 10.96.0.0/12
podSubnet10.244.0.0/16
scheduler
查看 kubelet 日志
journalctl -xeu kubelet