psmdb-operator-crds
by Percona
A Helm chart for Percona Server for MongoDB Operator Custom Resource Definitions (CRDs).
About this chart
psmdb-operator-crds
A Helm chart for Percona Server for MongoDB Operator Custom Resource Definitions (CRDs).
Overview
This chart contains the CRDs required by the Percona Operator for MongoDB:
PerconaServerMongoDB- defines a MongoDB cluster managed by the operatorPerconaServerMongoDBBackup- defines a backup for a MongoDB clusterPerconaServerMongoDBClusterSync- defines a Percona ClusterSync for MongoDB (PCSM) replication job for migrating data into an operator-managed clusterPerconaServerMongoDBRestore- defines a restore operation for a MongoDB cluster
Why a Separate CRD Chart?
Helm has a limitation where CRDs placed in the crds/ directory of a chart are only installed during helm install but are never updated during helm upgrade. This is by design to prevent accidental data loss.
This separate CRD chart allows you to:
- Install CRDs independently - Deploy CRDs before installing the operator
- Upgrade CRDs - Use
helm upgradeto update CRDs when new versions are released
Installation
Install the CRD chart first:
helm repo add percona https://percona.github.io/percona-helm-charts/
helm install psmdb-operator-crds percona/psmdb-operator-crds --version 1.23.1 --namespace psmdb --create-namespace
Note: Deleting CRD chart will trigger deletion of all the custom resources created using the CRDs thus deleting all clusters. Uninstalling percona/psmdb-operator-crds chart should be approached with caution. By default the chart protects against this (
preserveCrds: true, see Protecting CRDs from Deletion).
Then install the operator:
helm install psmdb-operator percona/psmdb-operator --namespace psmdb
Protecting CRDs from Deletion
Deleting these CRDs deletes every custom resource stored under them, i.e. all your MongoDB clusters. A GitOps tool (Flux, Argo CD, etc.) can trigger this accidentally by pruning or reinstalling the chart.
To guard against that, the chart sets preserveCrds: true by default, which adds the
helm.sh/resource-policy: keep
annotation to the CRDs. Helm then leaves the CRDs in place on helm uninstall
instead of deleting them.
If you deliberately want helm uninstall to remove the CRDs (for example, in an
ephemeral test cluster), opt out with preserveCrds: false:
helm install psmdb-operator-crds percona/psmdb-operator-crds --version 1.23.1 --namespace psmdb --create-namespace --set preserveCrds=false
| Value | Default | Description |
|---|---|---|
preserveCrds | true | Add helm.sh/resource-policy: keep to the CRDs so they survive helm uninstall. Set to false to let uninstall remove them. |
Note: With the default
preserveCrds: truethe CRDs are intentionally left behind on uninstall and must be removed manually (kubectl delete crd ...) if you truly want them gone.
Upgrading CRDs
When upgrading to a new version of the operator, upgrade the CRDs first:
helm repo update
helm upgrade psmdb-operator-crds percona/psmdb-operator-crds --version 1.23.1 --namespace psmdb
Note: If you're using Helm 3.17.0 or later, you can use the
--take-ownershipflag when upgrading CRDs that were initially installed via thecrds/directory:helm upgrade --install psmdb-operator-crds percona/psmdb-operator-crds --namespace psmdb --take-ownership
Then upgrade the operator:
helm upgrade psmdb-operator percona/psmdb-operator --version 1.23.2 --namespace psmdb
Taking Ownership of Existing CRDs
If you have CRDs that were previously installed via the crds/ directory and want to manage them with this chart, you need to add Helm labels and annotations. This is required because CRDs installed via the crds/ directory don't have Helm ownership metadata, which prevents this chart from managing them.
Taking Ownership Manually
If you want to take ownership of existing CRDs to manage them with this chart:
CRDS=(perconaservermongodbs.psmdb.percona.com perconaservermongodbbackups.psmdb.percona.com perconaservermongodbclustersyncs.psmdb.percona.com perconaservermongodbrestores.psmdb.percona.com)
kubectl label crds "${CRDS[@]}" app.kubernetes.io/managed-by=Helm --overwrite
kubectl annotate crds "${CRDS[@]}" meta.helm.sh/release-name=psmdb-operator-crds
kubectl annotate crds "${CRDS[@]}" meta.helm.sh/release-namespace=psmdb
Or use Helm 3.17.0+ with --take-ownership:
helm upgrade --install psmdb-operator-crds percona/psmdb-operator-crds --version 1.23.1 --namespace psmdb --take-ownership
Troubleshooting
Error: "invalid ownership metadata" when installing CRD chart
If you see an error like:
Error: invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by"
This means CRDs were previously installed via the crds/ directory and lack Helm ownership metadata. To fix this:
-
Use
--take-ownershipflag (Helm 3.17.0+):helm install psmdb-operator-crds percona/psmdb-operator-crds --namespace psmdb --take-ownership -
Or manually add ownership metadata (see Taking Ownership section above)
Deploy psmdb-operator-crds with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has psmdb-operator-crds on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartpsmdb-operator-crds is pinned at v1.23.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply