Skip to content

Commit

Permalink
pgAdmin use and discovery (#3739)
Browse files Browse the repository at this point in the history
* Reconcile admin secret
* Working pgadmin with new image
* Cluster config reconcile and load
* add KUTTL test, fix item sorting
  • Loading branch information
benjaminjb authored Oct 10, 2023
1 parent 6407a4f commit a026ab5
Show file tree
Hide file tree
Showing 40 changed files with 1,852 additions and 40 deletions.
68 changes: 68 additions & 0 deletions config/crd/bases/postgres-operator.crunchydata.com_pgadmins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ spec:
spec:
description: PGAdminSpec defines the desired state of PGAdmin
properties:
adminUsername:
description: AdminUsername is the username to set during pgAdmin startup.
pgAdmin requires this to have a valid email form.
type: string
affinity:
description: 'Scheduling constraints of the PGAdmin pod. More info:
https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node'
Expand Down Expand Up @@ -1334,6 +1338,70 @@ spec:
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
serverGroups:
description: ServerGroups for importing PostgresClusters to pgAdmin.
To create a pgAdmin with no selectors, leave this field empty. A
pgAdmin created with no `ServerGroups` will not automatically add
any servers through discovery. PostgresClusters can still be added
manually.
items:
properties:
name:
description: The name for the ServerGroup in pgAdmin. Must be
unique in the pgAdmin's ServerGroups since it becomes the
ServerGroup name in pgAdmin.
type: string
postgresClusterSelector:
description: PostgresClusterSelector selects clusters to dynamically
add to pgAdmin by matching labels. An empty selector like
`{}` will select ALL clusters in the namespace.
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
items:
description: A label selector requirement is a selector
that contains values, a key, and an operator that relates
the key and values.
properties:
key:
description: key is the label key that the selector
applies to.
type: string
operator:
description: operator represents a key's relationship
to a set of values. Valid operators are In, NotIn,
Exists and DoesNotExist.
type: string
values:
description: values is an array of string values.
If the operator is In or NotIn, the values array
must be non-empty. If the operator is Exists or
DoesNotExist, the values array must be empty. This
array is replaced during a strategic merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs.
A single {key,value} in the matchLabels map is equivalent
to an element of matchExpressions, whose key field is
"key", the operator is "In", and the values array contains
only "value". The requirements are ANDed.
type: object
type: object
required:
- name
- postgresClusterSelector
type: object
type: array
service:
description: Specification of the service that exposes pgAdmin.
properties:
Expand Down
7 changes: 7 additions & 0 deletions config/rbac/cluster/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ rules:
- patch
- update
- watch
- apiGroups:
- postgres-operator.crunchydata.com
resources:
- pgpgadmins
verbs:
- list
- watch
- apiGroups:
- postgres-operator.crunchydata.com
resources:
Expand Down
7 changes: 7 additions & 0 deletions config/rbac/namespace/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ rules:
- patch
- update
- watch
- apiGroups:
- postgres-operator.crunchydata.com
resources:
- pgpgadmins
verbs:
- list
- watch
- apiGroups:
- postgres-operator.crunchydata.com
resources:
Expand Down
111 changes: 111 additions & 0 deletions docs/content/references/crd.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions examples/pgadmin/pgadmin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ spec:
resources:
requests:
storage: 1Gi
serverGroups:
- name: supply
# An empty selector selects all postgresclusters in the Namespace
postgresClusterSelector: {}
- name: demand
postgresClusterSelector:
matchLabels:
postgres-operator.crunchydata.com/cluster: hippo
2 changes: 1 addition & 1 deletion internal/controller/postgrescluster/patroni.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ func (r *Reconciler) reconcilePatroniSwitchover(ctx context.Context,

// To ensure idempotency, the operator verifies that the timeline reported by Patroni
// matches the timeline that was present when the switchover was first requested.
// TODO(benjb): consider pulling the timeline from the pod annotation; manual experiments
// TODO(benjaminjb): consider pulling the timeline from the pod annotation; manual experiments
// have shown that the annotation on the Leader pod is up to date during a switchover, but
// missing from the Replica pods.
timeline, err := patroni.Executor(exec).GetTimeline(ctx)
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/postgrescluster/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (r *Reconciler) reconcilePostgresDatabases(
if cluster.Spec.PostGISVersion == "" {
postgisInstallOK = true
} else if postgisInstallOK = postgis.EnableInPostgreSQL(ctx, exec) == nil; !postgisInstallOK {
// TODO(benjb): Investigate under what conditions postgis would fail install
// TODO(benjaminjb): Investigate under what conditions postgis would fail install
r.Recorder.Event(cluster, corev1.EventTypeWarning, "PostGISDisabled",
"Unable to install PostGIS")
}
Expand Down
8 changes: 7 additions & 1 deletion internal/controller/standalone_pgadmin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ package standalone_pgadmin

const (
// key for standalone pgAdmin settings
settingsConfigMapKey = "pgadmin-settings.json"
settingsConfigMapKey = "pgadmin-settings.json"
settingsClusterMapKey = "pgadmin-shared-clusters.json"

logVolume = "pgadmin-log"
configMountPath = "/etc/pgadmin/conf.d"

pgAdminPort = 5050
)
Loading

0 comments on commit a026ab5

Please sign in to comment.