调试缓慢的 Kubernetes 部署
Debugging slow Kubernetes deployment
我们在托管 Azure 环境中使用 K8S,在 Ubuntu 中使用 Minikube,在本地机器上构建 Rancher 集群,一般来说,我们的部署需要大约 30 秒来拉取容器,运行 准备好。但是,我最近尝试创建部署(本地)需要一分钟以上,有时甚至更长。它是一个小型 Web 服务,与我们的其他部署非常相似。唯一(明显)的区别是启动探测器和活性探测器的使用,虽然我们的一些其他服务确实有探测器,但它们是不同的。
通过提取 运行ning 的 yaml 并使用 kubectl 从等式中删除 Octopus 部署后,(单个)pod 启动后,我开始阅读日志,正如预期的那样,启动和liveness 探测器被调用得非常快。启动成功,集群开始调用 live probe,也成功。但是,如果我在 pod 上使用 kubectl describe
,它会显示 Initialized 和 PodScheduled 为 True,但 ContainersReady(有一个容器)和 Ready 都为 false 大约一分钟。除了探测失败之外,我看不出是什么导致了这种情况,但这些都被记录为成功。
他们最终开始并工作正常,但我不知道为什么他们花了这么长时间。
kind: Deployment
apiVersion: apps/v1
metadata:
name: 'redirect-files-deployments-28775'
labels:
Octopus.Kubernetes.SelectionStrategyVersion: "SelectionStrategyVersion2"
OtherOctopusLabels
spec:
replicas: 1
selector:
matchLabels:
Octopus.Kubernetes.DeploymentName: 'redirect-files-deployments-28775'
template:
metadata:
labels:
Octopus.Kubernetes.SelectionStrategyVersion: "SelectionStrategyVersion2"
OtherOctopusLabels
spec:
containers:
- name: redirect-files
image: ourregistry.azurecr.io/microservices.redirectfiles:1.0.34
ports:
- name: http
containerPort: 80
protocol: TCP
env:
- removed connection strings etc
livenessProbe:
httpGet:
path: /api/version
port: 80
scheme: HTTP
successThreshold: 1
startupProbe:
httpGet:
path: /healthcheck
port: 80
scheme: HTTP
httpHeaders:
- name: X-SS-Authorisation
value: asdkjlkwe098sad0akkrweklkrew
initialDelaySeconds: 5
timeoutSeconds: 5
imagePullSecrets:
- name: octopus-feedcred-feeds-azure-container-registry
所以原因是启动 and/or 活性探测器。当我删除它们时,部署时间从一分多钟变成了 18 秒,尽管日志证明在容器启动后很快就成功调用了探测器。
至少我现在有更具体的东西要找了。
我们在托管 Azure 环境中使用 K8S,在 Ubuntu 中使用 Minikube,在本地机器上构建 Rancher 集群,一般来说,我们的部署需要大约 30 秒来拉取容器,运行 准备好。但是,我最近尝试创建部署(本地)需要一分钟以上,有时甚至更长。它是一个小型 Web 服务,与我们的其他部署非常相似。唯一(明显)的区别是启动探测器和活性探测器的使用,虽然我们的一些其他服务确实有探测器,但它们是不同的。
通过提取 运行ning 的 yaml 并使用 kubectl 从等式中删除 Octopus 部署后,(单个)pod 启动后,我开始阅读日志,正如预期的那样,启动和liveness 探测器被调用得非常快。启动成功,集群开始调用 live probe,也成功。但是,如果我在 pod 上使用 kubectl describe
,它会显示 Initialized 和 PodScheduled 为 True,但 ContainersReady(有一个容器)和 Ready 都为 false 大约一分钟。除了探测失败之外,我看不出是什么导致了这种情况,但这些都被记录为成功。
他们最终开始并工作正常,但我不知道为什么他们花了这么长时间。
kind: Deployment
apiVersion: apps/v1
metadata:
name: 'redirect-files-deployments-28775'
labels:
Octopus.Kubernetes.SelectionStrategyVersion: "SelectionStrategyVersion2"
OtherOctopusLabels
spec:
replicas: 1
selector:
matchLabels:
Octopus.Kubernetes.DeploymentName: 'redirect-files-deployments-28775'
template:
metadata:
labels:
Octopus.Kubernetes.SelectionStrategyVersion: "SelectionStrategyVersion2"
OtherOctopusLabels
spec:
containers:
- name: redirect-files
image: ourregistry.azurecr.io/microservices.redirectfiles:1.0.34
ports:
- name: http
containerPort: 80
protocol: TCP
env:
- removed connection strings etc
livenessProbe:
httpGet:
path: /api/version
port: 80
scheme: HTTP
successThreshold: 1
startupProbe:
httpGet:
path: /healthcheck
port: 80
scheme: HTTP
httpHeaders:
- name: X-SS-Authorisation
value: asdkjlkwe098sad0akkrweklkrew
initialDelaySeconds: 5
timeoutSeconds: 5
imagePullSecrets:
- name: octopus-feedcred-feeds-azure-container-registry
所以原因是启动 and/or 活性探测器。当我删除它们时,部署时间从一分多钟变成了 18 秒,尽管日志证明在容器启动后很快就成功调用了探测器。
至少我现在有更具体的东西要找了。