kubectl 使用案例
时间: 2023-09-04 13:14:39 浏览: 110
kubectl wordpress.zip
kubectl是Kubernetes的命令行工具,用于与Kubernetes集群进行交互。以下是一些kubectl的使用案例:
1. 获取集群信息:kubectl cluster-info
2. 查看节点信息:kubectl get nodes
3. 查看Pod信息:kubectl get pods
4. 查看服务信息:kubectl get services
5. 查看命名空间信息:kubectl get namespaces
6. 创建Deployment:kubectl create deployment <deployment-name> --image=<image-name>
7. 扩容Deployment:kubectl scale deployment <deployment-name> --replicas=<replica-count>
8. 滚动升级Deployment:kubectl set image deployment/<deployment-name> <container-name>=<new-image>
9. 删除Deployment:kubectl delete deployment <deployment-name>
10. 创建Service:kubectl expose deployment <deployment-name> --port=<port-number> --type=<service-type>
11. 删除Service:kubectl delete service <service-name>
12. 查看日志:kubectl logs <pod-name>
13. 进入容器:kubectl exec -it <pod-name> -- /bin/bash
14. 导出Deployment的YAML文件:kubectl get deployment <deployment-name> -o yaml > deployment.yaml
15. 应用Deployment的YAML文件:kubectl apply -f deployment.yaml
阅读全文