小白安装K8S Kubernetes集群 一起学
准备工作
安装系统
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
挂载模式配置
mount --make-rshared /
修改主机名,主机解析
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 <<EOF > /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
alpine
安装docker和安装k8s部署工具
apk update && apk upgrade
apk add docker docker-compose kubelet kubeadm kubectl
rc-update add docker default
service docker start
rc-update add kubelet default
service kubelet start
KBS使用
初始化集群
kubeadm init
配置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
安装flannel网络cni插件
kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
atest_version=$(curl -s https://api.github.com/repos/containernetworking/plugins/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
filename="cni-plugins-linux-amd64-${latest_version}.tgz"
curl -O -L "https://github.com/containernetworking/plugins/releases/download/${latest_version}/${filename}"
echo "Downloaded the latest version: ${filename}"
mkdir -p /opt/cni/bin
tar -C /opt/cni/bin -xzf $filename
ls /opt/cni/bin
卸载flannel
kubectl delete -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
rm -rf /etc/cni/net.d/10-flannel.conflist
rm -rf /var/lib/cni/flannel
rm -rf /var/lib/cni/networks
查看单个pod信息
kubectl describe pod coredns -n kube-system
kubectl describe pod calico-node-4rxkf -n kube-system
查看日志
kubectl logs coredns -n kube-system
删除pod
kubectl delete pod calico-node-4rxkf -n kube-system
查看node节点信息
kubectl get nodes
查看集群状态
kubectl get componentstatuses
生成加入命令
kubeadm token create --print-join-command
重启K8S
service kubelet restart
感觉你的视频好多是照葫芦画瓢的,自己也不是很清楚什么原理……
回复删除你觉得是就是呗
删除确实,东凑西凑……
删除