Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Helm upgrade --install isn't picking up new changes

I'm using the command below in my build CI such that the deployments to helm happen on each build. However, I'm noticing that the changes aren't being deployed.

              helm upgrade --install --force \
              --namespace=default \
              --values=kubernetes/values.yaml \
              --set image.tag=latest \
              --set service.name=my-service \
              --set image.pullPolicy=Always \
              myService kubernetes/myservice

Do I need to tag the image each time? Does helm not do the install if the same version exists?

like image 977
Anthony Avatar asked Nov 23 '18 17:11

Anthony


People also ask

How would we override values in a chart during helm install upgrade?

You can use a --values flag in your Helm commands to override the values in a chart and pass in a new file. Specify the name of the new file after the --values flag in the Helm command. Example: helm upgrade --install <service> -f values.

Does helm upgrade restart all pods?

helm upgrade --install (as stated in the doc) doesn't restart the pod (or redeploy) a version that already exists.

What happens during helm upgrade?

When a new version of a chart is released, or when you want to change the configuration of your release, you can use the helm upgrade command. An upgrade takes an existing release and upgrades it according to the information you provide.

Does helm upgrade install?

There are two ways to install Helm charts using the Helm CLI: helm install and helm upgrade --install . The install sub-command always installs a brand new chart, while the upgrade sub-command can upgrade an existing chart and install a new one, if the chart hasn't been installed before.


1 Answers

You don't have to tag the image each time with a new tag. Just add

date: "{{ now | unixEpoch }}"

under spec/template/metadata/labels and set imagePullPolicy: Always. Helm will detect the changes in the deployment object and will pull the latest image each time:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: "{{ .Release.Name }}-{{ .Values.app.frontendName }}-deployment"
  labels:
    app.kubernetes.io/name: {{ .Values.app.frontendName }}
    app.kubernetes.io/instance: {{ .Release.Name }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ .Values.app.frontendName }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app.kubernetes.io/name: {{ .Values.app.frontendName }}
        app.kubernetes.io/instance: {{ .Release.Name }}
        date: "{{ now | unixEpoch }}"
    spec:
      containers:
        - name: {{ .Values.app.frontendName }}
          image: "rajesh12/myimage:latest"
          imagePullPolicy: Always

Run helm upgrade releaseName ./my-chart to upgrade your release

like image 132
rajesh-nitc Avatar answered Nov 15 '22 10:11

rajesh-nitc