-
Notifications
You must be signed in to change notification settings - Fork 180
K8SPSMDB-1457: add certManagementPolicy option #2266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
myJamong
wants to merge
12
commits into
percona:main
Choose a base branch
from
myJamong:K8SPSMDB-1457-add-certManagementPolicy-option
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7b280ee
add certManagerPolicy option
myJamong 99e280f
add cert-management-policy to e2e-test
myJamong 65bc7a8
update generated manifests for certManagementPolicy
myJamong 311ebda
fix: gracefully handle missing TLS secret when certManagementPolicy i…
myJamong 13c07d9
add TLSSecretMissing Status condition when TLS secret is missing with…
myJamong 3f68918
read existing StatefulSet SSL annotations to prevent pod restart when…
myJamong 283d3d9
add TLSSecretMissing condition verification to e2e test
myJamong 06c12bc
add unit tests for certManagementPolicy userProvidedOnly SSL handling
myJamong 3ba9f74
hange TLS secret missing log level from Info to Error for better visi…
myJamong 0b573f5
skip cluster readiness check when verifying pods after SSL secret del…
myJamong 4968ab6
Rename TLSSecretMissing condition to TLSSecretsReady with positive ty…
myJamong f9fc556
Merge branch 'main' into K8SPSMDB-1457-add-certManagementPolicy-option
egegunes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| apiVersion: psmdb.percona.com/v1 | ||
| kind: PerconaServerMongoDB | ||
| metadata: | ||
| name: some-name | ||
| spec: | ||
| image: | ||
| imagePullPolicy: Always | ||
| updateStrategy: SmartUpdate | ||
| tls: | ||
| certManagementPolicy: auto | ||
| backup: | ||
| enabled: false | ||
| replsets: | ||
| - name: rs0 | ||
| affinity: | ||
| antiAffinityTopologyKey: none | ||
| resources: | ||
| limits: | ||
| cpu: 500m | ||
| memory: 1G | ||
| requests: | ||
| cpu: 100m | ||
| memory: 0.1G | ||
| volumeSpec: | ||
| persistentVolumeClaim: | ||
| resources: | ||
| requests: | ||
| storage: 1Gi | ||
| expose: | ||
| enabled: false | ||
| type: ClusterIP | ||
| size: 3 | ||
| secrets: | ||
| users: some-users |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| apiVersion: psmdb.percona.com/v1 | ||
| kind: PerconaServerMongoDB | ||
| metadata: | ||
| name: some-name | ||
| spec: | ||
| image: | ||
| imagePullPolicy: Always | ||
| updateStrategy: SmartUpdate | ||
| tls: | ||
| certManagementPolicy: userProvidedOnly | ||
| backup: | ||
| enabled: false | ||
| replsets: | ||
| - name: rs0 | ||
| affinity: | ||
| antiAffinityTopologyKey: none | ||
| resources: | ||
| limits: | ||
| cpu: 500m | ||
| memory: 1G | ||
| requests: | ||
| cpu: 100m | ||
| memory: 0.1G | ||
| volumeSpec: | ||
| persistentVolumeClaim: | ||
| resources: | ||
| requests: | ||
| storage: 1Gi | ||
| expose: | ||
| enabled: false | ||
| type: ClusterIP | ||
| size: 3 | ||
| secrets: | ||
| users: some-users |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -o errexit | ||
|
|
||
| test_dir="$(realpath "$(dirname "$0")")" | ||
| . "${test_dir}/../functions" | ||
| set_debug | ||
|
|
||
| cluster="some-name" | ||
|
|
||
| test_user_provided_only() { | ||
| desc '=== Test: certManagementPolicy: userProvidedOnly ===' | ||
|
|
||
| desc 'create secrets (users + TLS)' | ||
| kubectl_bin apply -f "$conf_dir/secrets_with_tls.yml" | ||
|
|
||
| desc "create PSMDB cluster $cluster with certManagementPolicy: userProvidedOnly" | ||
| apply_cluster "$test_dir/conf/$cluster.yml" | ||
|
|
||
| desc 'check if all Pods started' | ||
| wait_for_running $cluster-rs0 3 | ||
|
|
||
| desc 'save SSL secrets for later restore' | ||
| kubectl_bin get secret ${cluster}-ssl -o yaml >"$tmp_dir/ssl_backup.yaml" | ||
| kubectl_bin get secret ${cluster}-ssl-internal -o yaml >"$tmp_dir/ssl_internal_backup.yaml" | ||
|
|
||
| desc 'delete SSL secrets to simulate secret loss' | ||
| kubectl_bin delete secret ${cluster}-ssl ${cluster}-ssl-internal | ||
|
|
||
| desc 'wait for a few reconcile loops' | ||
| sleep 30 | ||
|
|
||
| desc 'verify operator did NOT recreate SSL secrets' | ||
| if kubectl_bin get secret ${cluster}-ssl 2>/dev/null; then | ||
| echo "FAIL: operator recreated SSL secret when certManagementPolicy is userProvidedOnly" | ||
| exit 1 | ||
| fi | ||
| if kubectl_bin get secret ${cluster}-ssl-internal 2>/dev/null; then | ||
| echo "FAIL: operator recreated SSL internal secret when certManagementPolicy is userProvidedOnly" | ||
| exit 1 | ||
| fi | ||
| echo "PASS: operator did not recreate SSL secrets" | ||
|
|
||
| desc 'verify TLSSecretMissing status condition is set' | ||
| local condition | ||
| condition=$(kubectl_bin get psmdb ${cluster} -o jsonpath='{.status.conditions[?(@.type=="TLSSecretMissing")].status}') | ||
| if [[ "$condition" != "True" ]]; then | ||
| echo "FAIL: TLSSecretMissing condition is not set (got: '$condition')" | ||
| exit 1 | ||
| fi | ||
| echo "PASS: TLSSecretMissing condition is set" | ||
|
|
||
| desc 'verify pods are still running (no restart, skip cluster readiness check)' | ||
| wait_for_running $cluster-rs0 3 false | ||
|
|
||
| desc 'restore SSL secrets' | ||
| kubectl_bin apply -f "$tmp_dir/ssl_backup.yaml" | ||
| kubectl_bin apply -f "$tmp_dir/ssl_internal_backup.yaml" | ||
|
|
||
| desc 'verify cluster is still healthy after secret restore' | ||
| sleep 10 | ||
| wait_for_running $cluster-rs0 3 | ||
|
|
||
| desc 'verify TLSSecretMissing condition is removed after secret restore' | ||
| local condition_after | ||
| condition_after=$(kubectl_bin get psmdb ${cluster} -o jsonpath='{.status.conditions[?(@.type=="TLSSecretMissing")].status}') | ||
| if [[ -n "$condition_after" ]]; then | ||
| echo "FAIL: TLSSecretMissing condition should be removed after secret restore (got: '$condition_after')" | ||
| exit 1 | ||
| fi | ||
| echo "PASS: TLSSecretMissing condition is removed after secret restore" | ||
|
|
||
| desc 'cleanup cluster' | ||
| kubectl_bin delete psmdb $cluster | ||
| wait_for_delete psmdb/$cluster 180 | ||
| } | ||
|
|
||
| test_auto() { | ||
| desc '=== Test: certManagementPolicy: auto ===' | ||
|
|
||
| desc 'create only user secrets (no TLS secrets)' | ||
| kubectl_bin apply -f "$conf_dir/secrets.yml" | ||
|
|
||
| desc "create PSMDB cluster $cluster with certManagementPolicy: auto" | ||
| apply_cluster "$test_dir/conf/$cluster-auto.yml" | ||
|
|
||
| desc 'wait for operator to auto-create SSL secrets' | ||
| sleep 30 | ||
|
|
||
| desc 'verify operator created SSL secrets automatically' | ||
| if ! kubectl_bin get secret ${cluster}-ssl 2>/dev/null; then | ||
| echo "FAIL: operator did not create SSL secret when certManagementPolicy is auto" | ||
| exit 1 | ||
| fi | ||
| if ! kubectl_bin get secret ${cluster}-ssl-internal 2>/dev/null; then | ||
| echo "FAIL: operator did not create SSL internal secret when certManagementPolicy is auto" | ||
| exit 1 | ||
| fi | ||
| echo "PASS: operator created SSL secrets automatically" | ||
|
|
||
| desc 'check if all Pods started' | ||
| wait_for_running $cluster-rs0 3 | ||
| } | ||
|
|
||
| main() { | ||
| create_infra "$namespace" | ||
| destroy_cert_manager || true | ||
|
|
||
| test_user_provided_only | ||
| test_auto | ||
|
|
||
| destroy "$namespace" | ||
|
|
||
| desc 'test passed' | ||
| } | ||
|
|
||
| main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| arbiter | ||
| balancer | ||
| cert-management-policy | ||
| cross-site-sharded | ||
| custom-replset-name | ||
| custom-tls | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| arbiter | ||
| balancer | ||
| cert-management-policy | ||
| cross-site-sharded | ||
| custom-replset-name | ||
| custom-tls | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@myJamong I think rather than having a negative condition type and a positive status, we should have a positive type and negative status. for example:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed - 4968ab6
Renamed TLSSecretMissing to TLSSecretsReady with positive type and negative status and updated all references including unit tests and e2e tests.