Cannot re-deploy kubernetes solution via HELM

6/3/2019

I have a working Azure DevOps pipeline that uses HELM to deploy my images to a Kubernetes cluster. This pipeline successfully executes when there are no resources in the cluster (the first time it is deployed). On subsequent deployments where the resources already exist, the HELM INSTALL command results in the following exception.

services "myservice-lb" already exists

Now I understand that this is due to the resource already existing, but my question relates to how to configure the chart so that changes can be deployed to the cluster.

Previously I would just run KUBECTL APPLY which is smart enough to update the pod and service if there are changes and ignore if there is nothing different. I assume HELM would have the same type of functionality, but I'm not seeing how this would be achieved.

Presently I'm using the HELM INSTALL pipeline task which points to the chart in my solution. I'm happy to post the generated YAML but I feel it's probably a command that needs to be ran in my DevOps pipeline.

enter image description here

enter image description here

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
  labels:
    name: myapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      terminationGracePeriodSeconds: 30
      containers:
      - name: myapp
        image: mycontainers.azurecr.io/myapp:latest
        imagePullPolicy: "Always"
        args: ["-w", "-e"]
        ports:
        - containerPort: 5000
        resources:
          limits:
            cpu: 500m
          requests:
            cpu: 250m
      imagePullSecrets:
      - name: acr-auth     

---
apiVersion: v1
kind: Service
metadata:
  name: myservice-lb
spec:
  type: LoadBalancer
  ports:
  - protocol: TCP
    port: 80
    targetPort: 5000
  selector:
    app: myapp
-- Geekn
azure-devops
kubernetes-helm

2 Answers

6/4/2019

Not sure if this is the case, but maybe this helps:

1 - If you have more than one tiller (helm server) installed in your cluster, the upgrade must be done with the same one used to installed it the first time. If not, the tiller will not find the package in its cache, (so the release is not installed), but will find the resource in the namespace (so will launch an error). It will happends also if the helm's cache is destroyed/erased

2 - It is a known bug for helm that if the first deploy fails, it can’t deploy it correctly for the next tries

You can check if there is a previous release with:

helm list

You can select the tiller to work with:

helm list --tiller-namespace=<namespace>

And if you find a failed release, you will need to delete the helm’s release manually:

helm delete --purge <release-name>
-- Chus
Source: StackOverflow

6/3/2019

Fairly certain you'd need to use helm upgrade to update it. To make it work if it didnt exist you can add --install switch

-- 4c74356b41
Source: StackOverflow