kubernetes - 调试缓慢的 Kubernetes 部署
问题描述
我们在托管的 Azure 环境中使用 K8S,在 Ubuntu 中使用 Minikube 以及在本地机器上构建的 Rancher 集群,通常,我们的部署需要大约 30 秒来拉取容器、运行并准备好。但是,我最近一次尝试创建部署(本地)需要一分钟以上,有时甚至更长时间。它是一个小型 Web 服务,与我们的其他部署非常相似。唯一(明显)的区别是使用启动探针和活跃度探针,尽管我们的其他一些服务确实有探针,但它们是不同的。
在通过提取它正在运行的 yaml 并使用 kubectl 从等式中删除 Octopus deploy 之后,一旦(单个)pod 启动,我就开始读取日志,并且正如预期的那样,启动和 liveness 探针被非常快速地调用。启动成功,集群开始调用 live probe,也成功了。但是,如果我kubectl describe
在 pod 上使用,它会显示 Initialized 和 PodScheduled 为 True,但 ContainersReady(有一个容器)和 Ready 在大约一分钟内都是错误的。除了探测失败之外,我看不到会导致此问题的原因,但这些都被记录为成功。
他们最终开始工作并正常工作,但我不知道他们为什么要花这么长时间。
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
解决方案
所以原因是启动和/或活性探测。当我删除它们时,部署时间从一分钟多到 18 秒,尽管日志证明在容器启动后很快就成功调用了探测器。
至少我现在有更具体的东西要寻找。
推荐阅读
- css - 背景不占整个页面 Angular CSS
- c++ - 有没有办法像 python:np.concatenate([x,y,z], axis=1) 那样在 C++ 中沿 Column 连接三个二维向量?
- mysql - MySQL,按组分组并在组内执行 SUM
- visual-studio - 我可以在没有 .NET 的情况下在 VS 中创建一个简单的网站项目吗?
- python - 为什么我在 python 中收到此程序的内存错误?
- database - 如何使用 edmx 将 asp net core 应用程序连接到 .net 类库
- php - Laravel 5.7 自定义登录不起作用 - 全新安装
- html - 如何连接我的登录/注册与 MySQL 数据库?
- javascript - 如何扫描两个不同变量中的值,并在它们满足条件时切换它们
- javascript - 反应中的异步红化