k8s 安装 kubeadmin
安装工具的时候,把 packages.cloud.google.com ,替换为
mirrors.aliyun.com/kubernetes
使用kubeadm创建集群。需要2核CPU,关闭swap
swapoff -a
echo 1 > /proc/sys/net/ipv4/ip_forward
kubuadm init 如果出现:
需要配置CGroup;
如果是containerd 参考 https://kubernetes.io/zh/docs/setup/production-environment/container-runtimes/#containerd
重启containerd 和 kubelet, systemctl status kubelet 看kubelet状态正常 再运行 kubeadm init --image-repository=registry.aliyuncs.com/google_containers --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=Swap
按照上图,运行 那3 条命令,可以运行 kubectl get nodes.
[root@xxxxxx ~]# kubectl get ns
NAME STATUS AGE
default Active 3h30m
kube-node-lease Active 3h30m
kube-public Active 3h30m
kube-system Active 3h30m
按照上图的URL 安装calico
[root@xxxx ~]# kubectl -n kube-system get pod
NAME READY STATUS RESTARTS AGE
calico-kube-controllers-75f8f6cc59-8d4z5 0/1 ContainerCreating 0 17m
calico-node-jc7b5 0/1 PodInitializing 0 17m
calico-typha-569b85fd8c-spfzm 0/1 Pending 0 17m
coredns-7f6cbbb7b8-llwfm 0/1 ContainerCreating 0 3h45m
coredns-7f6cbbb7b8-xf44t 0/1 ContainerCreating 0 3h45m
etcd-caoyuanfeixue 1/1 Running 2 (26m ago) 3h45m
kube-apiserver-caoyuanfeixue 1/1 Running 2 (26m ago) 3h45m
kube-controller-manager-caoyuanfeixue 1/1 Running 2 (26m ago) 3h45m
kube-proxy-g9cpf 1/1 Running 1 (26m ago) 3h45m
kube-scheduler-caoyuanfeixue 1/1 Running 2 (26m ago) 3h45m
[root@xxxxx ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
caoyuanfeixue Ready control-plane,master 3h47m v1.22.2
docker ps 可以看到很多容器再运行: pause,etc,api server...