用途命令(带颜色的都是可变的)
查看节点kubectl get nodes
查看节点更多信息kubectl get nodes -o wide
标志一个节点不可调度kubectl cordon -nodeName
标志一个节点可调度kubectl uncordon -nodeName
查看token列表kubeadm token list
创建tokenkubeadm token create
删除节点

kubectl drain <node name> --delete-local-data --force --ignore-daemonsets

kubectl delete node <node name>

创建一个deploymentkubectl create deployment nginx --image=nginx
查看deploymentskubectl get deployment(deployments)
创建一个servicekubectl create service nodeport nginx --tcp 80:80
查看serviceskubectl get svc(service/services)
删除一个deploymentkubectl delete deployments/nginx
删除一个servicekubectl delete services/nginx
同时删除deployment和service

kubectl delete deployments/nginx services/nginx

从yaml文件创建deploymentkubectl create -f deployment.yaml
查看podskubectl get pods(pod)
查看pod更多信息kubectl get pods -o wide
查看具体pod信息kubectl describe pods/kube-node-59bf664cbf-2qzgd
修改deploymentkubectl edit deployments/test
从yaml创建service

kubectl create -f service.yaml

快捷创建service(expose)kubectl expose deployment kube-node --type=NodePort
查看service具体信息kubectl describe services/kube-node
查看namespacekubectl get namespace
创建namespacekubectl create namespace -name
删除namespacekubectl delete namespace -name
根据配置文件创建configmap

kubectl create configmap my-config --from-file=path/to/bar

kubectl create configmap my-config --from-file=key1=/path/file1.txt --from-file=key2=/path/to/bar/file2.txt

从字符串创建configmapkubectl create configmap my-config --from-literal=key1=config1 --from-literal=key2=config2
从env文件创建configmapkubectl create configmap my-config --from-env-file=path/to/bar.env
扩容kubectl scale deployment nginx-deployment --replicas 10
自动扩容kubectl autoscale deployment nginx-deployment --min=10 --max=15 --cpu-percent=80
更新镜像kubectl set image deployment/nginx-deployment nginx=nginx:1.9.1
回滚kubectl rollout undo deployment/nginx-deployment
查看默认配置项,如pod.speckubectl explain pod.spec

持续更新ing

以上都是亲自用过的,没用过的自己查表,附上kubectl命令表

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐