In a Kubernetes environment, a license key is always required for the operator to function. The only exception is when the operator is run with Community PostgreSQL. In this case, if the license key is unset, a cluster will start with a default trial license that automatically expires after 30 days.
If your license key expires, usually due to the contract expiring, you will need to apply a new license key. There are two possible scenarios:
If the license is enabled for quay.io images, you need to create a configmap as outlined here.
For Cloudsmith images, the license is disabled because you have already paid to pull images from Cloudsmith. The license key is not enforced, and no additional configuration is required. The operator will function correctly regardless of the configmap settings. In this case, you do not need to be concerned about the "not enforced" license status.
To verify the existing license, use the following command. In this example, the cluster name is cluster-example
under the namespace postgresql-operator-system
:
kubectl get cluster cluster-example -o yaml -n postgresql-operator-system | grep -A 3 licenseStatus
Sample Output:
licenseStatus:
licenseExpiration: "2024-06-13T00:00:00Z"
licenseStatus: Valid license (Testing)
repositoryAccess: true
valid: true
managedRolesStatus: {}
If you have a new license key, follow these steps to update it:
Use the following command to view current deployments:
kubectl get deployments -A
Sample Output:
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
postgresql-operator-system postgresql-operator-controller-manager 1/1 1 1 51d
First, delete the existing license with the following command:
Syntax:
kubectl delete configmap [configmap_name] -n [NAMESPACE_NAME_HERE]
Sample Command:
kubectl delete configmap postgresql-operator-controller-manager-config -n postgresql-operator-system
Sample Output:
configmap "postgresql-operator-controller-manager-config" deleted
Syntax:
kubectl create configmap -n [NAMESPACE_NAME_HERE] \
postgresql-operator-controller-manager-config \
--from-literal=EDB_LICENSE_KEY=[LICENSE_KEY_HERE]
Sample Command:
kubectl create configmap postgresql-operator-controller-manager-config --from-literal=EDB_LICENSE_KEY=xxxxxxxxxxS2LBVXIYZSKZ4WI3KWPFGFQQTZMIZFCPJCFQRHAYLTON3W64TEEI5CEZCGJJDVOSCSN5MVKTTJKRXEE2TBIZRXUWLMM4YFURTLPJHVKMJVMFLWIyyyyyyyyyy -n postgresql-operator-system
Sample Output:
configmap/postgresql-operator-controller-manager-config created
Restart the deployment to apply the new license key:
kubectl rollout restart deployment -n [NAMESPACE_NAME_HERE] \
postgresql-operator-controller-manager
Sample Command:
kubectl rollout restart deployment postgresql-operator-controller-manager -n postgresql-operator-system
Sample Output:
deployment.apps/postgresql-operator-controller-manager restarted
Finally, verify the new license with the following command:
kubectl get cluster cluster-example -o yaml -n postgresql-operator-system | grep -A 3 licenseStatus
Sample Output:
licenseStatus:
licenseExpiration: "2024-07-13T00:00:00Z"
licenseStatus: Valid license (Test-swap)
repositoryAccess: true
valid: true
managedRolesStatus: {}
Managing license keys in a Kubernetes environment is crucial for the seamless operation of the PostgreSQL operator. Always ensure that you have a valid license key, and be prepared to update it if it expires. The process involves verifying the existing license, deleting the expired license, creating a new config map with the new license key, and restarting the deployment. Following these steps will ensure that your operator continues to function correctly without any interruptions.