Skip to content

Commit

Permalink
Merge branch 'main' into K8SPG-619
Browse files Browse the repository at this point in the history
  • Loading branch information
hors authored Jan 2, 2025
2 parents 48ed896 + 463bf42 commit 8460d9f
Show file tree
Hide file tree
Showing 24 changed files with 437 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8362,6 +8362,8 @@ spec:
type: boolean
pgStatStatements:
type: boolean
pgvector:
type: boolean
type: object
image:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8074,6 +8074,8 @@ spec:
type: boolean
pg_stat_monitor:
type: boolean
pgvector:
type: boolean
type: object
custom:
items:
Expand Down
2 changes: 1 addition & 1 deletion cmd/postgres-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"

//"github.com/percona/percona-postgresql-operator/internal/controller/pgupgrade"

"github.com/percona/percona-postgresql-operator/internal/controller/pgupgrade"
"github.com/percona/percona-postgresql-operator/internal/controller/postgrescluster"
"github.com/percona/percona-postgresql-operator/internal/controller/runtime"
Expand Down Expand Up @@ -106,6 +105,7 @@ func main() {
namespaces,
cfg,
false,
false,
features,
)
assertNoError(err)
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/pgv2.percona.com_perconapgclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8480,6 +8480,8 @@ spec:
type: boolean
pg_stat_monitor:
type: boolean
pgvector:
type: boolean
type: object
custom:
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8322,6 +8322,8 @@ spec:
type: boolean
pgStatStatements:
type: boolean
pgvector:
type: boolean
type: object
image:
description: |-
Expand Down
4 changes: 4 additions & 0 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8773,6 +8773,8 @@ spec:
type: boolean
pg_stat_monitor:
type: boolean
pgvector:
type: boolean
type: object
custom:
items:
Expand Down Expand Up @@ -34005,6 +34007,8 @@ spec:
type: boolean
pgStatStatements:
type: boolean
pgvector:
type: boolean
type: object
image:
description: |-
Expand Down
6 changes: 6 additions & 0 deletions deploy/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ metadata:
# - percona.com/delete-ssl
spec:
crVersion: 2.6.0
# metadata:
# annotations:
# example-annotation: value
# labels:
# example-label: value
# secrets:
# customRootCATLSSecret:
# name: cluster1-ca-cert
Expand Down Expand Up @@ -492,6 +497,7 @@ spec:
# builtin:
# pg_stat_monitor: true
# pg_audit: true
# pgvector: false
# custom:
# - name: pg_cron
# version: 1.6.1
4 changes: 4 additions & 0 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8773,6 +8773,8 @@ spec:
type: boolean
pg_stat_monitor:
type: boolean
pgvector:
type: boolean
type: object
custom:
items:
Expand Down Expand Up @@ -34005,6 +34007,8 @@ spec:
type: boolean
pgStatStatements:
type: boolean
pgvector:
type: boolean
type: object
image:
description: |-
Expand Down
4 changes: 4 additions & 0 deletions deploy/cw-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8773,6 +8773,8 @@ spec:
type: boolean
pg_stat_monitor:
type: boolean
pgvector:
type: boolean
type: object
custom:
items:
Expand Down Expand Up @@ -34005,6 +34007,8 @@ spec:
type: boolean
pgStatStatements:
type: boolean
pgvector:
type: boolean
type: object
image:
description: |-
Expand Down
5 changes: 4 additions & 1 deletion e2e-tests/tests/init-deploy/01-create-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ commands:

source ../../functions

get_cr | kubectl -n "${NAMESPACE}" apply -f -
get_cr \
| yq '.spec.metadata.labels.test-label = "test"' \
| yq '.spec.metadata.annotations.test-annotation = "test"' \
| kubectl -n "${NAMESPACE}" apply -f -
231 changes: 231 additions & 0 deletions e2e-tests/tests/init-deploy/05-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 300
---
apiVersion: v1
kind: Secret
metadata:
annotations:
test-annotation: test
labels:
app.kubernetes.io/instance: init-deploy
app.kubernetes.io/managed-by: percona-postgresql-operator
app.kubernetes.io/name: percona-postgresql
app.kubernetes.io/part-of: percona-postgresql
pgv2.percona.com/version: 2.6.0
postgres-operator.crunchydata.com/cluster: init-deploy
postgres-operator.crunchydata.com/pgbackrest: ""
postgres-operator.crunchydata.com/pgbackrest-config: ""
test-label: test
name: init-deploy-pgbackrest
type: Opaque
---
apiVersion: v1
kind: Secret
metadata:
annotations:
test-annotation: test
labels:
app.kubernetes.io/instance: init-deploy
app.kubernetes.io/managed-by: percona-postgresql-operator
app.kubernetes.io/name: percona-postgresql
app.kubernetes.io/part-of: percona-postgresql
postgres-operator.crunchydata.com/cluster: init-deploy
postgres-operator.crunchydata.com/cluster-certificate: replication-client-tls
test-label: test
name: init-deploy-replication-cert
type: Opaque
---
apiVersion: v1
kind: Secret
metadata:
annotations:
test-annotation: test
labels:
app.kubernetes.io/instance: init-deploy
app.kubernetes.io/managed-by: percona-postgresql-operator
app.kubernetes.io/name: percona-postgresql
app.kubernetes.io/part-of: percona-postgresql
postgres-operator.crunchydata.com/cluster: init-deploy
postgres-operator.crunchydata.com/pguser: postgres
postgres-operator.crunchydata.com/role: pguser
test-label: test
name: init-deploy-pguser-postgres
type: Opaque
---
apiVersion: v1
kind: Secret
metadata:
annotations:
test-annotation: test
labels:
app.kubernetes.io/instance: init-deploy
app.kubernetes.io/managed-by: percona-postgresql-operator
app.kubernetes.io/name: percona-postgresql
app.kubernetes.io/part-of: percona-postgresql
postgres-operator.crunchydata.com/cluster: init-deploy
postgres-operator.crunchydata.com/pguser: init-deploy
postgres-operator.crunchydata.com/role: pguser
test-label: test
name: init-deploy-pguser-init-deploy
type: Opaque
---
apiVersion: v1
kind: Secret
metadata:
annotations:
test-annotation: test
labels:
app.kubernetes.io/component: pgbouncer
app.kubernetes.io/instance: init-deploy
app.kubernetes.io/managed-by: percona-postgresql-operator
app.kubernetes.io/name: percona-postgresql
app.kubernetes.io/part-of: percona-postgresql
pgv2.percona.com/version: 2.6.0
postgres-operator.crunchydata.com/cluster: init-deploy
postgres-operator.crunchydata.com/role: pgbouncer
test-label: test
name: init-deploy-pgbouncer
type: Opaque
---
apiVersion: v1
kind: Secret
metadata:
annotations:
test-annotation: test
labels:
app.kubernetes.io/instance: init-deploy
app.kubernetes.io/managed-by: percona-postgresql-operator
app.kubernetes.io/name: percona-postgresql
app.kubernetes.io/part-of: percona-postgresql
postgres-operator.crunchydata.com/cluster: init-deploy
postgres-operator.crunchydata.com/cluster-certificate: postgres-tls
test-label: test
name: init-deploy-cluster-cert
type: Opaque
---
apiVersion: v1
kind: Secret
metadata:
annotations:
test-annotation: test
labels:
test-label: test
name: init-deploy-cluster-ca-cert
ownerReferences:
- apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
name: init-deploy
type: Opaque
---
apiVersion: v1
kind: ConfigMap
metadata:
annotations:
test-annotation: test
labels:
postgres-operator.crunchydata.com/cluster: init-deploy
test-label: test
name: init-deploy-config
ownerReferences:
- apiVersion: postgres-operator.crunchydata.com/v1beta1
blockOwnerDeletion: true
controller: true
kind: PostgresCluster
name: init-deploy
---
apiVersion: v1
kind: ConfigMap
metadata:
annotations:
test-annotation: test
labels:
app.kubernetes.io/instance: init-deploy
app.kubernetes.io/managed-by: percona-postgresql-operator
app.kubernetes.io/name: percona-postgresql
app.kubernetes.io/part-of: percona-postgresql
pgv2.percona.com/version: 2.6.0
postgres-operator.crunchydata.com/cluster: init-deploy
postgres-operator.crunchydata.com/pgbackrest: ""
postgres-operator.crunchydata.com/pgbackrest-config: ""
test-label: test
name: init-deploy-pgbackrest-config
ownerReferences:
- apiVersion: postgres-operator.crunchydata.com/v1beta1
blockOwnerDeletion: true
controller: true
kind: PostgresCluster
name: init-deploy
---
apiVersion: v1
kind: ConfigMap
metadata:
annotations:
test-annotation: test
labels:
app.kubernetes.io/component: pgbouncer
app.kubernetes.io/instance: init-deploy
app.kubernetes.io/managed-by: percona-postgresql-operator
app.kubernetes.io/name: percona-postgresql
app.kubernetes.io/part-of: percona-postgresql
pgv2.percona.com/version: 2.6.0
postgres-operator.crunchydata.com/cluster: init-deploy
postgres-operator.crunchydata.com/role: pgbouncer
test-label: test
name: init-deploy-pgbouncer
ownerReferences:
- apiVersion: postgres-operator.crunchydata.com/v1beta1
blockOwnerDeletion: true
controller: true
kind: PostgresCluster
name: init-deploy
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations:
test-annotation: test
generation: 1
labels:
app.kubernetes.io/instance: init-deploy
app.kubernetes.io/managed-by: percona-postgresql-operator
app.kubernetes.io/name: percona-postgresql
app.kubernetes.io/part-of: percona-postgresql
pgv2.percona.com/version: 2.6.0
postgres-operator.crunchydata.com/cluster: init-deploy
postgres-operator.crunchydata.com/data: pgbackrest
postgres-operator.crunchydata.com/pgbackrest: ""
postgres-operator.crunchydata.com/pgbackrest-dedicated: ""
test-label: test
name: init-deploy-repo-host
ownerReferences:
- apiVersion: postgres-operator.crunchydata.com/v1beta1
blockOwnerDeletion: true
controller: true
kind: PostgresCluster
name: init-deploy
spec:
template:
metadata:
annotations:
test-annotation: test
labels:
app.kubernetes.io/instance: init-deploy
app.kubernetes.io/managed-by: percona-postgresql-operator
app.kubernetes.io/name: percona-postgresql
app.kubernetes.io/part-of: percona-postgresql
pgv2.percona.com/version: 2.6.0
postgres-operator.crunchydata.com/cluster: init-deploy
postgres-operator.crunchydata.com/data: pgbackrest
postgres-operator.crunchydata.com/pgbackrest: ""
postgres-operator.crunchydata.com/pgbackrest-dedicated: ""
test-label: test
status:
availableReplicas: 1
collisionCount: 0
currentReplicas: 1
observedGeneration: 1
readyReplicas: 1
replicas: 1
updatedReplicas: 1

9 changes: 9 additions & 0 deletions internal/controller/postgrescluster/pki.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package postgrescluster
import (
"context"

gover "github.com/hashicorp/go-version"
"github.com/pkg/errors"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -109,6 +110,14 @@ func (r *Reconciler) reconcileRootCertificate(
intent.Data = make(map[string][]byte)
intent.ObjectMeta.OwnerReferences = existing.ObjectMeta.OwnerReferences

if cluster.Labels != nil {
currVersion, err := gover.NewVersion(cluster.Labels[naming.LabelVersion])
if err == nil && currVersion.GreaterThanOrEqual(gover.Must(gover.NewVersion("2.6.0"))) && cluster.Spec.Metadata != nil {
intent.Labels = cluster.Spec.Metadata.Labels
intent.Annotations = cluster.Spec.Metadata.Annotations
}
}

// A root secret is scoped to the namespace where postgrescluster(s)
// are deployed. For operator deployments with postgresclusters in more than
// one namespace, there will be one root per namespace.
Expand Down
Loading

0 comments on commit 8460d9f

Please sign in to comment.