1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
vi /etc/fstab
reboot
kubeadm init
sudo kubeadm init
kubectl version
kubectl get nodes
su -pumpkin
su - pumpkin
kubectl get nodes
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl get nodes
echo “source <(kubectl completion bash)” >> ~/.zshrc

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

kubectl get pod -o wide
kubectl delete pod avi

kubectl delete pods --all

关机过程

  1. node节点

    1
    2
    systemctl stop kube-proxy
    systemctl stop kubelet
  2. master

    1
    2
    3
    systemctl stop kube-scheduler
    systemctl stop kube-controller-manager
    systemctl stop kube-apiserver.service
  3. 关闭 node节点的flanneld 服务

    1
    systemctl stop flanneld
  4. 全部节点关闭etcd

    1
    2
    systemctl stop etcd
    systemctl stop docker
  5. 全部关机

    1
    init 0

开机过程

1
2
3
4
5
6
7
systemctl start etcd  三节点
systemctl start flanneld (node 节点)
systemctl start kube-apiserver.service (默认设置了开机启动, master 节点)
systemctl start kube-scheduler (默认设置了开机启动, master 节点)
systemctl start kube-controller-manager (默认设置了开机启动, master 节点)
systemctl start kubelet(node 节点)
systemctl stop kube-proxy(node 节点)

k8s卸载

1
2
3
4
5
6
7
8
9
10
sudo kubeadm reset -f
sudo rm -rvf $HOME/.kube
sudo rm -rvf ~/.kube/
sudo rm -rvf /etc/kubernetes
sudo rm -rvf /etc/systemd/system/kubelet.service.d
sudo rm -rvf /usr/bin/kube*
sudo rm -rvf /etc/cni
sudo rm -rvf /opt/cni
sudo rm -rvf /var/lib/etcd
sudo apt-get remove kube*