Helm 3 install for resouces that exist

Jhon D picture Jhon D · Dec 22, 2019 · Viewed 16.1k times · Source

when running helm install (helm 3.0.2)

I got the following error: Error: rendered manifests contain a resource that already exists. Unable to continue with install: existing resource conflict: kind: PodSecurityPolicy, namespace: , name: po-kube-state-metrics

But I don't find it and also In the error im not getting the ns, How can I remove it ?

when running kubectl get all --all-namespaces I see all the resources but not the po-kub-state-metrics ... it also happen to other resources, any idea?

I got the same error to: monitoring-grafana entity and the result of kubectl get PodSecurityPolicy --all-namespaces is:

monitoring-grafana false RunAsAny RunAsAny RunAsAny RunAsAny false configMap,emptyDir,projected,secret,do

Answer

Kamol Hasan picture Kamol Hasan · Dec 23, 2019

First of all you need to make sure you've successfully uninstalled the helm release, before reinstalling.

To list all the releases, use:

$ helm list --all --all-namespaces

To uninstall a release, use:

$ helm uninstall <release-name> -n <namespace>

You can also use --no-hooks to skip running hooks for the command:

$ helm uninstall <release-name> -n <namespace> --no-hooks

If uninstalling doesn't solve your problem, you can try the following command to cleanup:

$ helm template <NAME> <CHART> --namespace <NAMESPACE> | kubectl delete -f - 

Sample:

$ helm template happy-panda stable/mariadb --namespace kube-system | kubectl delete -f -

Now, try installing again.

Update:

Let's consider that your chart name is mon and your release name is po. Since you are in the charts directory (.) like below:

.
├── mon
│   ├── Chart.yaml
│   ├── README.md
│   ├── templates
│   │   ├── one.yaml
│   │   ├── two.yaml
│   │   ├── three.yaml
│   │   ├── _helpers.tpl
│   │   ├── NOTES.txt
│   └── values.yaml

Then you can skip the helm repo name (i.e. stable) in the helm template command. Helm will use your mon chart from the directory.

$ helm template po mon --namespace mon | kubectl delete -f -