如何强制Kubernetes重新拉动一个镜像?

识趣 发表于: 2021-12-05   最后更新时间: 2021-12-05 00:48:42   1,116 游览

我的Kubernetes项目yaml如下:

apiVersion: v1
kind: ReplicationController
metadata:
  name: myapp
  labels:
    app: myapp
spec:
  replicas: 2
  selector:
    app: myapp
    deployment: initial
  template:
    metadata:
      labels:
        app: myapp
        deployment: initial
    spec:
      containers:
      - name: myapp
        image: kubebiz.com/myapp:5c3dda6b
        ports:
        - containerPort: 80
      imagePullPolicy: Always
      imagePullSecrets:
        - name: myregistry.com-registry-key

我执行

kubectl rolling-update myapp --image=us.gcr.io/project-107012/myapp:5c3dda6b

我执行了滚动更新,但不重新拉。为什么?

发表于 2021-12-05
添加评论

有2种方式可以做到镜像每次都重新拉取:

  • 镜像版本是:latest
  • imagePullPolicy: Always

方法一:

image: kubebiz.com/myapp:latest

方法二,设置拉取策略为Always

spec:
  containers:
  - name: myapp
    image: kubebiz.com/myapp:5c3dda6b
    imagePullPolicy: Always

参考来自:imagePullPolicy拉取策略

你的答案

查看kubernetes相关的其他问题或提一个您自己的问题