kubernetes集群部署 Debug 官方文档中有Troubleshooting这个主题,包含以下内容:
Debug Pods
Debug Services
Debug a StatefulSet
Debug Init Containers
Debug Running Pods
Determine the Reason for Pod Failure
Get a Shell to a Running Container
里面有常见问题的排查方法介绍
常见套路 1. 使用 busybox 方法一:kubectl run curl --image=radial/busyboxplus:curl -i --tty 方法二:kubectl debug targetPod -it --image=busybox 2. 使用 initContainer 给Pod、Deployment增加 initContainer,在其中添加debug操作。 推荐阅读文档: 链接 查看 initContainer 日志: kubectl logs pod_name -c initContainerName 3....
1. 概念入门 master节点 worker节点 Pod Kubernetes最小管理单位,一个节点可以拥有多个Pod,一个Pod可以拥有多个容器 2. 安装 2.1 minikube 安装教程: https://minikube.sigs.k8s.io/docs/start/
2.2 腾讯云集群 按步骤很容易起一个Kubernetes集群
3. 常用命令 1 2 3 4 5 6 7 8 9 10 11 12 kubectl apply -f app.yaml # 部署应用 kubectl get deployment # 查看 deployment kubectl get pod -o wide # 查看 pod kubectl describe pod pod-name # 查看 pod 详情 kubectl logs pod-name # 查看 log kubectl exec -it pod-name -- bash # 进入 Pod 容器终端, -c container-name 可以指定进入哪个容器。 kubectl scale deployment test-k8s --replicas=5 # 伸缩扩展副本 kubectl port-forward pod-name 8090:8080 # 把集群内端口映射到节点 kubectl rollout history deployment test-k8s # 查看历史 kubectl rollout undo deployment test-k8s # 回到上个版本 kubectl rollout undo deployment test-k8s --to-revision=2 # 回到指定版本 kubectl delete deployment test-k8s # 删除部署 4....