1、k8s的token实效后解决办法
①创建新token
kubeadm token create
②查看新token
kubeadm token list
③查看token-ca-cert-hash
openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
④添加新节点
kubeadm join 192.168.0.210:6443 --token wxrztl.r5k7jck1xzxouakf \
--discovery-token-ca-cert-hash sha256:37235cd7cf0efc8c995516f525903c79daff51ea173cbc68fda7d3bc5e01042b
2、常用命令
创建对象
$ kubectl create -f ./my-manifest.yaml
$ kubectl create -f ./my1.yaml -f ./my2.yaml
$ kubectl create -f ./dir
$ kubectl create -f https://git.io/vPieo
$ kubectl run nginx --image=nginx
$ kubectl explain pods,svc
显示和查找资源
$ kubectl get services
$ kubectl get pods --all-namespaces
$ kubectl get pods -o wide
$ kubectl get deployment my-dep
$ kubectl get pods --include-uninitialized
更新资源
$ kubectl rolling-update frontend-v1 -f frontend-v2.json
$ kubectl rolling-update frontend-v1 frontend-v2 --image=image:v2
$ kubectl rolling-update frontend --image=image:v2
$ kubectl rolling-update frontend-v1 frontend-v2 --rollback
$ kubectl label pods my-pod new-label=awesome
$ kubectl annotate pods my-pod icon-url=http://goo.gl/XXBTWq
删除资源
$ kubectl delete -f ./pod.json
$ kubectl delete pod,service baz foo
$ kubectl delete pods,services -l name=myLabel
$ kubectl delete pods,services -l name=myLabel --include-uninitialized
$ kubectl -n my-ns delete po,svc --all
与运行中的 Pod 交互
$ kubectl logs my-pod
$ kubectl logs my-pod -c my-container
$ kubectl logs -f my-pod
$ kubectl logs -f my-pod -c my-container
$ kubectl run -i --tty busybox --image=busybox -- sh
$ kubectl attach my-pod -i
$ kubectl port-forward my-pod 5000:6000
$ kubectl exec my-pod -- ls /
$ kubectl exec my-pod -c my-container -- ls /
$ kubectl top pod POD_NAME --containers