Kubernetes
这份快速指南将引导你如何使用Kubernetes。
安装
kubernetes.repo
1vi /etc/yum.repos.d/kubernetes.repo
/etc/yum.repos.d/kubernetes.repo
1[kubernetes]
2name=Kubernetes
3baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
4enabled=1
5gpgcheck=0
kubeadm kubelet
1# yum --showduplicates list kubelet
2yum remove kubelet
3yum remove kubelet
4yum install kubeadm
5kubeadm version
6kuberlet --version
惯用法
查看Kubeadm所需镜像
1kubeadm config images list
2
检查Kubelet
1检查Kubelet
打开监控
1wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
2docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server:v0.6.4
3#vi components.yaml 更改image等
4k apply -f components.yaml
设置监控
1spec:
2 containers:
3 - args:
4 - --cert-dir=/tmp
5 - --secure-port=4443
6 command:
7 - /metrics-server
8 - --kubelet-insecure-tls=true
9 - --kubelet-preferred-address-types=InternalIP
10 image: registry.k8s.io/metrics-server/metrics-server:v0.3.7
设置监控
1args:
2- --cert-dir=/tmp
3- --secure-port=4443
4- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
5- --kubelet-use-node-status-port
6- --kubelet-insecure-tls # Add this line (New Version).
查看资源
1kubectl describe node
2kubectl describe node |grep -E '((Name|Roles):\s{6,})|(\s+(memory|cpu)\s+[0-9]+\w{0,2}.+%\))
3kubectl top node
4kubectl top pod
清理Calico
1modprobe -r ipip
2cd /etc/cni/net.d/
3kubectl delete -f calico.yaml
清理CNI
1cd /var/lib/cni
2rm <config file>
3cd /etc/cni/net.d
4rm <config file>
5ip link delete cni0 #Sandbox
清理节点
1kubectl drain <node name> --delete-local-data --force --ignore-daemonsets
2kubeadm reset
3cd /etc/cni/net.d/
4rm <config file>
5lsof -i :6443|grep -v "PID"|awk "{print "kill -9",$2}"|sh
6iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X
7ipvsadm -C
8kubectl delete node <node name>
容许主节点部署
1kubectl taint nodes --all node-role.kubernetes.io/master-
证书
1kubeadm certs check-expiration
2kubeadm certs renew all