准备工作
安装系统

wget --no-check-certificate -qO InstallNET.sh 'https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/InstallNET.sh' && chmod a+x InstallNET.sh

bash InstallNET.sh -alpine

reboot

22 root LeitboGi0ro

挂载模式配置且开机启动

rc-update add local default

rc-update show | grep local

cat < /etc/local.d/mount-rshared.start

!/bin/sh

mount --make-rshared /

EOF

chmod +x /etc/local.d/mount-rshared.start

/etc/local.d/mount-rshared.start

修改主机名,主机解析

hostname_use=k8s-master

ipv4_address=$(curl -s ipv4.ip.sb)

echo "$hostname_use" > /etc/hostname

hostname "$hostname_use"

cat > /etc/hosts << EOF

127.0.0.1 localhost

$ipv4_address $hostname_use

EOF

调整内核网桥参数加载生效

cat < /etc/sysctl.d/k8s.conf

net.bridge.bridge-nf-call-ip6tables = 1

net.bridge.bridge-nf-call-iptables = 1

net.ipv4.ip_forward=1

vm.max_map_count=262144

EOF

modprobe br_netfilter

sysctl -p /etc/sysctl.d/k8s.conf

设置K8S解析范围

cat < /var/lib/kubelet/kubeadm-flags.env

KUBELET_KUBEADM_ARGS="--container-runtime-endpoint=unix:///var/run/containerd/containerd.sock --pod-infra-container-image=registry.k8s.io/pause:3.9 --cluster-dns=10.96.0.10,8.8.8.8,1.1.1.1 --cluster-domain=cluster.local"

EOF

cat < /etc/resolv.conf

nameserver 8.8.8.8

nameserver 1.1.1.1

EOF

service kubelet restart

alpine安装containerd和安装k8s部署工具

apk update && apk upgrade

apk add containerd kubelet kubeadm kubectl

rc-update add containerd default

service containerd start

rc-update add kubelet default

service kubelet start

KBS使用
初始化集群

kubeadm init

配置containerd

containerd config default > /etc/containerd/config.toml

service containerd restart

配置kubectl

mkdir -p $HOME/.kube

cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

chown $(id -u):$(id -g) $HOME/.kube/config

安装calico网络cni插件

kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml

查看pod列表信息

kubectl get pods -A

kubectl get pods -A -o wide

查看单个pod信息

kubectl describe pod coredns -n kube-system

查看日志

kubectl logs coredns -n kube-system

删除pod

kubectl delete pod calico-node-4rxkf -n kube-system

kubectl delete pods --all -n kube-system

查看node节点信息

kubectl get nodes

删除node节点

kubectl delete nodes k8s-node1

查看集群状态

kubectl get componentstatuses

生成加入命令

kubeadm token create --print-join-command

重启K8S

service kubelet restart

K8S一键脚本

curl -sS -O https://kejilion.pro/k8s.sh && chmod +x k8s.sh && ./k8s.sh