kubectl命令行管理工具
1、创建
kubectl run nginx --replicas=3 --image=nginx:1.14 --port=80 kubectl get deploy,pods
2、发布
kubectl expose deployment nginx --port=80 --type=NodePort --target-port=80 --name=nginx-service
kubectl get service
3、更新(升级)
kubectl set image deployment/nginx nginx=nginx:1.15
#查看升级状态
kubectl rollout status deployment/nginx-deployment
#kubectl apply -f nginx.yaml
4、回滚
kubectl rollout history deployment/nginx
kubectl rollout undo deployment/nginx
kubectl rollout undo deployment/nginx --revision=2
5、删除
kubectl delete deploy/nginx
kubectl delete svc/nginx-service
------------------------------------------------------------------------------------------------
YAML配置文件管理资源
用run命令生成
kubectl run --image=nginx my-deploy -o yaml --dry-run > my-deploy.yaml
用get命令导出
kubectl get my-deploy/nginx -o=yaml --export > my-deploy.yaml
Pod容器的字段拼写忘记了
kubectl explain pods.spec.containers
----------------------------------------------------------------------------------
排查故障
kubectl describe TYPE/NAME
kubectl logs TYPE/NAME [-c CONTAINER]
kubectl exec POD [-c CONTAINER] -- COMMAND [args...]
----------------------------------------------------------------------------------------------
service常用命令