|
| 1 | +--- |
| 2 | +title: "Updating the Operator" |
| 3 | +date: 2025-12-28T14:26:51+01:00 |
| 4 | +draft: false |
| 5 | +weight: 2100 |
| 6 | +--- |
| 7 | + |
| 8 | +This chapter describes the recommended process for updating the CYBERTEC PostgreSQL Operator (CPO). To ensure a smooth transition and compatibility with new features, updates should be performed using our official Helm repository. |
| 9 | + |
| 10 | +{{< hint type=important >}} CRD Update Requirement: Due to how Helm handles the crds/ directory, helm upgrade will not automatically update or patch existing Custom Resource Definitions (CRDs). You must manually apply the updated CRDs before upgrading the Helm release. {{< /hint >}} |
| 11 | + |
| 12 | +## Using Helm-Chart |
| 13 | + |
| 14 | +1. Update the Helm Repository |
| 15 | + |
| 16 | +First, ensure your local Helm chart cache is up to date with the latest versions from the CYBERTEC repository: |
| 17 | +``` |
| 18 | +helm repo update cpo |
| 19 | +``` |
| 20 | + |
| 21 | +2. Update the Custom Resource Definitions (CRDs) |
| 22 | + |
| 23 | +Before upgrading the Helm release, you must manually apply the latest CRDs from the CYBERTEC-operator-tutorials repository. This is a safety measure because Helm does not touch existing CRDs to prevent accidental data loss. |
| 24 | + |
| 25 | +Apply the definitions for the Postgres clusters and the operator configuration directly from the source: |
| 26 | + |
| 27 | +``` |
| 28 | +# Update the PostgreSQL Cluster CRD |
| 29 | +kubectl apply -f https://raw.githubusercontent.com/cybertec-postgresql/CYBERTEC-operator-tutorials/refs/heads/main/setup/helm/operator/crds/postgresql.crd.yaml |
| 30 | +
|
| 31 | +# Update the Operator Configuration CRD |
| 32 | +kubectl apply -f https://raw.githubusercontent.com/cybertec-postgresql/CYBERTEC-operator-tutorials/refs/heads/main/setup/helm/operator/crds/operatorconfiguration.crd.yaml |
| 33 | +``` |
| 34 | + |
| 35 | +3. Execute the Helm Upgrade |
| 36 | + |
| 37 | +Once the CRDs are up to date, you can upgrade the operator deployment. This process replaces the operator pod with the new version and updates the necessary RBAC roles and service accounts. |
| 38 | +``` |
| 39 | +# Upgrade the CPO release in the 'cpo' namespace |
| 40 | +helm upgrade cpo cpo/cybertec-pg-operator \ |
| 41 | + --namespace cpo \ |
| 42 | + --reuse-values |
| 43 | +``` |
| 44 | + |
| 45 | +## Using CPO-Tutorial-Repository |
| 46 | + |
| 47 | +1. Clone or Update the Tutorial Repo |
| 48 | +``` |
| 49 | +git clone https://github.com/$GITHUB_USER/CYBERTEC-operator-tutorials.git |
| 50 | +cd CYBERTEC-operator-tutorials |
| 51 | +``` |
| 52 | + |
| 53 | +2. Patch CRDS |
| 54 | + |
| 55 | +``` |
| 56 | +# Update the PostgreSQL Cluster CRD |
| 57 | +kubectl apply -f setup/helm/operator/crds/postgresql.crd.yaml |
| 58 | +
|
| 59 | +# Update the Operator Configuration CRD |
| 60 | +kubectl apply -f setup/helm/operator/crds/operatorconfiguration.crd.yaml |
| 61 | +``` |
| 62 | + |
| 63 | +3. Execute the Helm Upgrade |
| 64 | +``` |
| 65 | +# Upgrade the CPO release in the 'cpo' namespace |
| 66 | +helm upgrade cpo setup/helm/operator/. \ |
| 67 | + --namespace cpo \ |
| 68 | + --reuse-values |
| 69 | +``` |
| 70 | + |
| 71 | +## Verification |
| 72 | + |
| 73 | +To ensure the update was successful, perform the following checks: |
| 74 | + |
| 75 | +1. Pod Status: Verify that the new operator pod is running. |
| 76 | +``` |
| 77 | +kubectl get pods -n cpo -l app.kubernetes.io/name=cybertec-pg-operator |
| 78 | +``` |
| 79 | + |
| 80 | +2. Version Check: Check the logs to see the version string during startup. |
| 81 | +``` |
| 82 | +kubectl logs -n cpo deployment/cybertec-pg-operator | grep "Starting operator" |
| 83 | +``` |
| 84 | + |
| 85 | +3. CRD Integrity: Ensure the new CRD fields are recognized by the Kubernetes API. |
| 86 | +``` |
| 87 | +kubectl describe crd postgresqls.cpo.opensource.cybertec.at |
| 88 | +``` |
| 89 | + |
| 90 | +## Why manual CRD patching? ## |
| 91 | + |
| 92 | +The CRDs are located in the helm/operator/crds/ folder. By design, Helm only installs these during the initial helm install. During an upgrade, Helm ignores this folder to protect the cluster from unintended schema changes. Therefore, manual application via kubectl apply is the standard and safest path for CPO updates. |
| 93 | + |
| 94 | +## Compatibility ## |
| 95 | + |
| 96 | +Always ensure that your postgresql manifests are compatible with the new operator version by checking the [Release Notes](release_notes) in the Documentation. |
0 commit comments