helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

The first installation prompts that crd resources already exist

Open czhfe opened this issue 3 years ago • 5 comments

In a new kubernetes cluster, the first installation of victoria-metrics-k8s-stack prompts that a crd resource already exists and cannot continue with the installation

helm install victoria-metrics-k8s-stack vm/victoria-metrics-k8s-stack -f values-local-test.yaml -n monitoring --create-namespace
Error: INSTALLATION FAILED: rendered manifests contain a resource that already exists. Unable to continue with install: CustomResourceDefinition "vmagents.operator.victoriametrics.com" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "victoria-metrics-k8s-stack"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "monitoring"

czhfe avatar Mar 14 '22 08:03 czhfe

I have the same problem. W0401 11:15:34.308771 581303 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+ Error: INSTALLATION FAILED: rendered manifests contain a resource that already exists. Unable to continue with install: CustomResourceDefinition "vmagents.operator.victoriametrics.com" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "vmstack"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "monitoring" helm.go:84: [debug] CustomResourceDefinition "vmagents.operator.victoriametrics.com" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "vmstack"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "monitoring" rendered manifests contain a resource that already exists. Unable to continue with install helm.sh/helm/v3/pkg/action.(*Install).RunWithContext helm.sh/helm/v3/pkg/action/install.go:295 main.runInstall helm.sh/helm/v3/cmd/helm/install.go:264

andlf avatar Apr 01 '22 08:04 andlf

Have the same problem. Have anyone found a solution?

notz avatar Jun 20 '22 23:06 notz

The name of the helm release is the problem. You have to use a very short one like "vm" otherwise the config names are truncated and then there are two with the same truncated name.

notz avatar Jun 21 '22 00:06 notz

you can disable CRDs for victoria-metrics-operator in the values.yaml:

victoria-metrics-operator:
  createCRD: false

they will be created here https://github.com/VictoriaMetrics/helm-charts/blob/master/charts/victoria-metrics-k8s-stack/crds/crd.yaml

sydorovdmytro avatar Jun 21 '22 14:06 sydorovdmytro

kubectl get crd

Find the CRD name you just added and delete it,eg:

kubectl delete crd xxx

ximon8 avatar Jul 08 '22 08:07 ximon8

Hello all! It will be a problem when you already have k8s chart installed under one namespace, and reinstalled under other namespace. Because helm will add key "meta.helm.sh/release-name" and "meta.helm.sh/release-namespace" to resources and check them. Try uninstall and clean the crds first or use createCRD: false.

Close this now, feel free to reopen if you got further question)

Haleygo avatar Jul 20 '23 06:07 Haleygo