k8s常用命令整理
用途命令(带颜色的都是可变的)查看节点kubectl get nodes查看节点更多信息kubectl get nodes -o wide标志一个节点不可调度kubectl cordon -nodeName标志一个节点可调度kubectl uncordon -nodeName查看token列表kubeadm token ...
·
用途 | 命令(带颜色的都是可变的) |
---|---|
查看节点 | kubectl get nodes |
查看节点更多信息 | kubectl get nodes -o wide |
标志一个节点不可调度 | kubectl cordon -nodeName |
标志一个节点可调度 | kubectl uncordon -nodeName |
查看token列表 | kubeadm token list |
创建token | kubeadm token create |
删除节点 | kubectl drain <node name> --delete-local-data --force --ignore-daemonsets kubectl delete node <node name> |
创建一个deployment | kubectl create deployment nginx --image=nginx |
查看deployments | kubectl get deployment(deployments) |
创建一个service | kubectl create service nodeport nginx --tcp 80:80 |
查看services | kubectl get svc(service/services) |
删除一个deployment | kubectl delete deployments/nginx |
删除一个service | kubectl delete services/nginx |
同时删除deployment和service | kubectl delete deployments/nginx services/nginx |
从yaml文件创建deployment | kubectl create -f deployment.yaml |
查看pods | kubectl get pods(pod) |
查看pod更多信息 | kubectl get pods -o wide |
查看具体pod信息 | kubectl describe pods/kube-node-59bf664cbf-2qzgd |
修改deployment | kubectl 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 |
查看namespace | kubectl get namespace |
创建namespace | kubectl create namespace -name |
删除namespace | kubectl 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 |
从字符串创建configmap | kubectl create configmap my-config --from-literal=key1=config1 --from-literal=key2=config2 |
从env文件创建configmap | kubectl 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.spec | kubectl explain pod.spec |
持续更新ing
以上都是亲自用过的,没用过的自己查表,附上kubectl命令表
更多推荐
已为社区贡献17条内容
所有评论(0)