Home > OS >  Updating kubernetes pod
Updating kubernetes pod

Time:12-09

I have this deployment.yaml for kubernetes

---
apiVersion: v1
kind: Service
metadata:
  name: smart-flats
  labels:
    app: smart-flats
spec:
  type: NodePort
  selector:
    app: smart-flats
  ports:
  - protocol: TCP
    port: 5000
    name: http
    
---
apiVersion: v1
kind: ReplicationController
metadata:
  name: smart-flats
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: smart-flats
    spec:
      containers:
      - name: smart-flats
        image: sleezy/go-hello-world:<VERSION>
        env:
        - name: SECRETKEY
          value: "${CONFIG_SECRETKEY}"
        ports:
        - containerPort: 5000
        livenessProbe:
          httpGet:
            path: /health
            port: 5000
          initialDelaySeconds: 30
          timeoutSeconds: 1

but when i try to push new version of app, kubectl get pods still show the first one and no updated version, what should i do? i need update pod everytime i push new version. Thanks!

CodePudding user response:

First off kind: Deployment is recommended instead of kind: ReplicationController, see here for details. Once you have updated the spec, you can update image version with kubectl set image deployment smart-flats smart-flats=sleezy/go-hello-world:<new version>. Your pods will automatic restart with the new image version.

CodePudding user response:

  • A ReplicationController ensures that a specified number of pod replicas are running at any one time. They do not support a rolling update directly.In simpler terms they will just looking mainting a specified number of pods and will not be monitoring image versions of the pod.

  • easier way to get the pod running with modified/new image , after pushing the change to replication controller just delete the existing/old pod. new pod will get created with new image. [or]

  • as @gohm'c suggested deployment instead of replicaset or replicationcontroller will be a better option.

  • Related