我正在尝试使用 Kubernetes 实现零停机部署。但是每次我使用新映像升级部署时,我都会看到 2-3 秒的停机时间。我正在使用 Hello-World 类型的应用程序对此进行测试,但仍然无法实现。我正在使用 Helm 图表部署我的应用程序。
根据在线博客和资源,我在 Deployment.yaml 文件中使用了就绪探测和滚动更新策略。但这没有给我任何成功。我创建了一个/health端点,它简单地返回200状态代码作为准备探测的检查。我希望在 Kubernetes 中使用就绪探针和 RollingUpdate 策略后,当我升级容器的映像时,我将能够实现服务的零停机。对我的服务的请求通过 Amazon ELB。
Deployment.yaml 文件如下:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: wine-deployment
labels:
app: wine-store
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
selector:
matchLabels:
app: wine-store
replicas: 2
template:
metadata:
labels:
app: wine-store
spec:
containers:
- name: {{ .Chart.Name }}
resources: …Run Code Online (Sandbox Code Playgroud) kubernetes ×1