Skip to content

K8SPG-1045: add .spec.tls.certManagementPolicy field#1679

Open
pooknull wants to merge 12 commits into
mainfrom
K8SPG-1045
Open

K8SPG-1045: add .spec.tls.certManagementPolicy field#1679
pooknull wants to merge 12 commits into
mainfrom
K8SPG-1045

Conversation

@pooknull

@pooknull pooknull commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

https://perconadev.atlassian.net/browse/K8SPG-1045

DESCRIPTION

This PR adds .spec.tls.certManagementPolicy which controls how TLS secrets are managed. The following values are supported:

  • auto - the operator creates and maintains TLS secrets. This is the default.
  • userProvidedOnly - the operator never generates or modifies TLS secrets. Reconciliation pauses until every required secret is provided by the user.

When secrets are missing (when userProvidedOnly is used), the cluster reports:

conditions:
- type: TLSSecretsReady
  status: "False"
  reason: TLSSecretsMissing
- type: Progressing
  status: "False"
  reason: Paused

The TLSSecretsReady message lists the missing secret names.

Once these secrets are present, the operator creates the instance StatefulSet so its generated name can be seen by the user.

After that, user should create corresponding <statefulset-name>-certs secret.

User's secrets should contain postgres-operator.crunchydata.com/cluster: <cluster-name> label to trigger reconcile

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported PG version?
  • Does the change support oldest and newest supported Kubernetes version?

); err != nil {
return nil, errors.Wrapf(err, "get user-provided instance TLS secret %s", existing.Name)
}
return existing, nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're returning a nil *corev1.Secret with a nil error. this is unexpected for caller. can we improve if possible or at least comment in function's godoc

@pooknull pooknull Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_, hasCluster := obj.GetLabels()[naming.LabelCluster]
return hasCluster
}))).
Watches(&corev1.Pod{}, r.watchPods()).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be if I create secret manually? As I understand we don't have labels in secret in this case.

@pooknull pooknull Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are going to expect user to set this cluster label: #1679 (comment)

@hors

hors commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

@pooknull please fix conflicts

Comment on lines +39 to +50
clusters := &v1beta1.PostgresClusterList{}
if err := r.Client.List(ctx, clusters, client.InNamespace(obj.GetNamespace())); err != nil {
return nil
}

requests := make([]reconcile.Request, 0, len(clusters.Items))
for i := range clusters.Items {
requests = append(requests, reconcile.Request{
NamespacedName: client.ObjectKeyFromObject(&clusters.Items[i]),
})
}
return requests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure that we want to do this? i'd force user to add cluster label to the secret instead of blindly triggering reconcile

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you. I have reverted this change: 1c0bbf6

@pooknull
pooknull requested review from egegunes and nmarukovich July 21, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants