Use Helm 3 for existing resources deployed with kubectl

4/12/2020

We used to deploy kubernetes resources using the normal kubectl command for services, deployments, configmap...etc. Now we need to start using Helm 3 and integrate it to our pipelines, but when I try to run the helm upgrade command, it's giving the below error: Error: rendered manifests contain a resource that already exists. Unable to continue with install: existing resource conflict: namespace: default

So, these resources were never created with helm as it was created normally with kubcetl apply command.

Just need to know how to used Helm in the pipeline without re-create the k8s resources. As the only workaround I found to get it working was to delete the resources and re-deploy them using Helm.

Below is the command I tried: helm upgrade --atomic --debug --install --force test .

Thanks, Aly

-- user10479125
aws-eks
eks
kubernetes
kubernetes-helm

2 Answers

4/12/2020

You could add all helm labels/annotations. You can check all helm labels and anther components with helm template. Then you could use kubectl label or kubectl annotate to add missing labels/annotations.

I personally never tried it, because is too much work and in the end, you have to recreate pods with new labels if they are managed by deployment/statefulset.

-- FL3SH
Source: StackOverflow

4/12/2020

Honestly while FL3SH's answer is what you are looking for... the best choice would be to just delete your k8s resources. There are some exceptions to this:

  1. Your helm chart is trying to create a namespace (e.g. default)
  2. Your deployments cannot be down for any time
  3. Your helm chart has persistent volume claims
-- user2869522
Source: StackOverflow