【发布时间】:2019-08-21 23:42:04
【问题描述】:
我们有一个 GKE 集群,其中包含 4 个部署/pod,当我们部署新代码时需要更新这些部署/pod。我知道使用我们正在部署的图像的最新摘要部署图像是最佳实践,但我想知道是否有人知道使用该摘要更新 yaml 文件的更好方法,而不是手动更新它。我可以使用以下方法获得fully_qualified_digest:
gcloud container images describe gcr.io/xxxx/uwsgi
每次部署时都必须使用最新的摘要哈希手动更新 yaml 文件,这真的很糟糕。如果有人知道更好的方法,我很乐意听到。
旁注:现在是 2019 年,Kubernetes 应该能够获取摘要哈希形式 /latest 而无需明确定义它。
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
creationTimestamp: null
labels:
io.kompose.service: uwsgi
name: uwsgi
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
minReadySeconds: 5
template:
metadata:
labels:
io.kompose.service: uwsgi
spec:
containers:
- env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: certs/gcp.json
- name: ENV
value: prod
image: gcr.io/xxxx/uwsgi:latest <------ needs to be fully_qualified_digest
name: uwsgi
ports:
- containerPort: 9040
readinessProbe:
httpGet:
path: /health/
port: 9040
initialDelaySeconds: 5
timeoutSeconds: 1
periodSeconds: 15
livenessProbe:
httpGet:
path: /health/
port: 9040
initialDelaySeconds: 60
timeoutSeconds: 1
periodSeconds: 15
resources:
requests:
memory: "1000Mi"
cpu: "1800m"
limits:
memory: "1200Mi"
cpu: "2000m"
hostname: uwsgi
restartPolicy: Always
terminationGracePeriodSeconds: 60
status: {}
【问题讨论】:
-
是什么阻止你用 Python 编写一个小程序来检索完全限定的摘要并在使用之前更新 YAML 文件?
-
我现在实际上正在这样做。
标签: kubernetes yaml google-kubernetes-engine digest