postgres-operator
postgres-operator copied to clipboard
feat: support podLabels on Postgresqls
You can use cluster_labels to define labels for child resources incl. pods.
You can use cluster_labels to define labels for child resources incl. pods.
Hi @FxKu , that would only allow defining static labels for all clusters managed by the operator, correct? My team's use-case requires tagging pods (not necessarily all child resources) with dynamic labels (that must be unique between clusters) in the same way that podAnnotations appears to work.
Also cluster_labels is only working properly during the initial deployment. Afterwards, since it tries to patch all resources where it fails when trying to patch the PVC
time="2023-07-31T13:01:27Z" level=warning msg="new statefulset introduces extra labels in the label selector, cannot continue" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=info msg="statefulset prometheus-galaxy/ap-grafana-postgres-db is not in the desired state and needs to be updated" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="+ apiserver-access: allowed," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- cluster-name: ap-grafana-postgres-db" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="+ cluster-name: ap-grafana-postgres-db," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="+ internet-access: allowed" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="+ apiserver-access: allowed," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="+ internet-access: allowed," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- value: {\\application\\:\\spilo\\}" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="+ value: {\\apiserver-access\\:\\allowed\\,\\application\\:\\spilo\\,\\internet-access\\:\\allowed\\}" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- terminationMessagePath: /dev/termination-log," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- terminationMessagePolicy: File," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- restartPolicy: Always," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- dnsPolicy: ClusterFirst," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- serviceAccount: postgres-pod," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="+ apiserver-access: allowed," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="+ internet-access: allowed," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- }," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- schedulerName: default-scheduler" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="+ }" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- kind: PersistentVolumeClaim," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- apiVersion: v1," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="+ apiserver-access: allowed," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="+ internet-access: allowed," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- status: {" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- phase: Pending" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- }" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="+ status: {}" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- }," cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="- revisionHistoryLimit: 10" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="+ }" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=debug msg="updating statefulset" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=warning msg="error while syncing cluster state: could not sync statefulsets: could not update statefulset: could not patch statefulset spec \"prometheus-galaxy/ap-grafana-postgres-db\": StatefulSet.apps \"ap-grafana-postgres-db\" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', 'updateStrategy', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbidden" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=cluster
time="2023-07-31T13:01:27Z" level=error msg="could not sync cluster: could not sync statefulsets: could not update statefulset: could not patch statefulset spec \"prometheus-galaxy/ap-grafana-postgres-db\": StatefulSet.apps \"ap-grafana-postgres-db\" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', 'updateStrategy', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbidden" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=controller worker=0
time="2023-07-31T13:01:27Z" level=info msg="received add event for already existing Postgres cluster" cluster-name=prometheus-galaxy/ap-grafana-postgres-db pkg=controller worker=0
Any update on this @FxKu ? We also need this feature to enable istio on specific postgres!
I just found the following to pass labels to the db pods. Wasn't aware of it - however, this resolved my request
https://postgres-operator.readthedocs.io/en/latest/administrator/#add-cluster-specific-labels
If one really only needs to define pod labels via the cluster manifest it should be implemented like the annotations, yes. This PR only changes the CRD but does not reflect any changes in the go code.
I do wonder where we stop here? Can imagine people wanting to define labels for services, pvcs etc. This means more and more manifest options which we generally do not favor. Will be thinking, if this could not be solved with a separate CRD which the Postgres Operator consumes.