我们有一个包含4个部署/pod的GKE集群,需要在部署新代码时进行更新。我知道最佳实践是使用我们正在部署的映像的最新摘要来部署映像,但我想知道是否有人知道使用该摘要更新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: {}
发布于 2019-03-31 23:19:35
有许多工具可以监视您的Docker存储库,并在新镜像可用时进行更新。最常用的可能是https://github.com/weaveworks/flux/。Kubernetes本身不提供此功能,因为它可能是非收敛的。
也就是说,您可以在pod规范中使用:latest
。避免它的原因是Kubernetes不会知道在镜像更改时重新启动pods (也存在缓存问题,但您可以避免spec中具有镜像拉取策略的问题)。如果你实际上不想自动部署新的镜像,那么你所拥有的就足够了。
https://stackoverflow.com/questions/55444415
复制相似问题