-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup unused service certs when using apiOverride
Deletes service route certs issued by default/custom issuer when using custom route certs via apiOverride or service override with load balancer Signed-off-by: Veronika Fisarova <[email protected]>
- Loading branch information
Showing
15 changed files
with
525 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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,14 @@ | ||
resources: | ||
- ../../base/openstackcontrolplane | ||
|
||
patches: | ||
- target: | ||
kind: OpenStackControlPlane | ||
name: .* | ||
patch: |- | ||
- op: replace | ||
path: /metadata/name | ||
value: openstack | ||
- target: | ||
kind: OpenStackControlPlane | ||
path: patch.yaml |
This file contains 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,21 @@ | ||
apiVersion: core.openstack.org/v1beta1 | ||
kind: OpenStackControlPlane | ||
metadata: | ||
name: openstack | ||
spec: | ||
barbican: | ||
apiOverride: | ||
tls: | ||
secretName: barbican-custom-route | ||
placement: | ||
apiOverride: | ||
route: | ||
spec: | ||
tls: | ||
certificate: | | ||
CERT123 | ||
key: | | ||
KEY123 | ||
caCertificate: | | ||
CACERT123 | ||
termination: reencrypt |
This file contains 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 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,10 @@ | ||
# A ctustom barbican secret that's used for route override | ||
apiVersion: v1 | ||
kind: Secret | ||
type: k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ently 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,57 @@ | ||
#!/bin/bash | ||
|
||
ROUTE_NAME=$1 | ||
|
||
if [[ "$ROUTE_NAME" == "barbican" ]]; then | ||
EXPECTED_CERTIFICATE="-----BEGIN CERTIFICATE----- | ||
MIIBfjCCASUCFB2bFw2MfRB0vIAZmNe81aRJIj8GMAoGCCqGSM49BAMCMEIxCzAJ | ||
BgNVBAYTAlhYMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1 | ||
bHQgQ29tcGFueSBMdGQwHhcNMjQwNDI5MDc0NzM4WhcNMjUwNDI5MDc0NzM4WjBC | ||
MQswCQYDVQQGEwJYWDEVMBMGA1UEBwwMRGVmYXVsdCBDaXR5MRwwGgYDVQQKDBNE | ||
ZWZhdWx0IENvbXBhbnkgTHRkMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAExuPx | ||
YX5SrJpymPX/j67XXiHiSte8S6wzbuJd0xM4HODaZbt0r0IWO8rRQUEeLnudFoF6 | ||
Ju4R3QUT8d+t3zDZqTAKBggqhkjOPQQDAgNHADBEAiBYsG23KRf/3o+R9+imWJa4 | ||
8d2zu9eMr6qkTg5Q4tj/sgIgLaox7QK2Ao4dY3nmlyg9ascsQNKV4bpdSXAX/drH | ||
7DE= | ||
-----END CERTIFICATE-----" | ||
|
||
EXPECTED_CA_CERTIFICATE="-----BEGIN CERTIFICATE----- | ||
MIIB2DCCAX+gAwIBAgIUWARgHwuaus9w7uQ1opRlDXRPRvswCgYIKoZIzj0EAwIw | ||
QjELMAkGA1UEBhMCWFgxFTATBgNVBAcMDERlZmF1bHQgQ2l0eTEcMBoGA1UECgwT | ||
RGVmYXVsdCBDb21wYW55IEx0ZDAeFw0yNDA0MjkwNzQ2NDdaFw0yNTA0MjkwNzQ2 | ||
NDdaMEIxCzAJBgNVBAYTAlhYMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNV | ||
BAoME0RlZmF1bHQgQ29tcGFueSBMdGQwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNC | ||
AATg695MQRE7erKhHfNL0MA+2bve1TruxjNm5kUJaCk8CbQWififn9WjHlPnND6x | ||
ftxDyis5MyTvdjpYnzZTxSEwo1MwUTAdBgNVHQ4EFgQUVkjtNnURJ4c+kvZn7/fF | ||
EJhMz7QwHwYDVR0jBBgwFoAUVkjtNnURJ4c+kvZn7/fFEJhMz7QwDwYDVR0TAQH/ | ||
BAUwAwEB/zAKBggqhkjOPQQDAgNHADBEAiAuExPY3JFBuZ1IFv5Sf+Ai3YHwtoSb | ||
PzKC6Dq0YRpNqgIgTTK9yfJpiJSHwJqa2dWnD8dJkf8jKH+6/VJrRk3mpkY= | ||
-----END CERTIFICATE-----" | ||
elif [[ "$ROUTE_NAME" == "placement" ]]; then | ||
EXPECTED_CERTIFICATE="CERT123" | ||
EXPECTED_CA_CERTIFICATE="CACERT123" | ||
fi | ||
|
||
TLS_DATA=$(oc get route ${ROUTE_NAME}-public -n $NAMESPACE -o jsonpath='{.spec.tls}') | ||
|
||
# Extract certificates from the route | ||
ACTUAL_CERTIFICATE=$(echo "$TLS_DATA" | jq -r '.certificate') | ||
ACTUAL_CA_CERTIFICATE=$(echo "$TLS_DATA" | jq -r '.caCertificate') | ||
|
||
TRIMMED_EXPECTED_CERTIFICATE=$(echo "$EXPECTED_CERTIFICATE" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') | ||
TRIMMED_ACTUAL_CERTIFICATE=$(echo "$ACTUAL_CERTIFICATE" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') | ||
|
||
TRIMMED_EXPECTED_CA_CERTIFICATE=$(echo "$EXPECTED_CA_CERTIFICATE" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') | ||
TRIMMED_ACTUAL_CA_CERTIFICATE=$(echo "$ACTUAL_CA_CERTIFICATE" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') | ||
|
||
if [[ "$TRIMMED_EXPECTED_CERTIFICATE" != "$TRIMMED_ACTUAL_CERTIFICATE" ]]; then | ||
echo "Certificate does not match for route $ROUTE_NAME in namespace $NAMESPACE." | ||
exit 1 | ||
fi | ||
|
||
if [[ "$TRIMMED_EXPECTED_CA_CERTIFICATE" != "$TRIMMED_ACTUAL_CA_CERTIFICATE" ]]; then | ||
echo "CA Certificate does not match for route $ROUTE_NAME in namespace $NAMESPACE." | ||
exit 1 | ||
fi | ||
|
||
echo "TLS data matches for route $ROUTE_NAME in namespace $NAMESPACE." |
1 change: 1 addition & 0 deletions
1
tests/kuttl/tests/ctlplane-tls-custom-route/01-assert-deploy-openstack.yaml
This file contains 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 @@ | ||
../../common/assert-sample-deployment.yaml |
5 changes: 5 additions & 0 deletions
5
tests/kuttl/tests/ctlplane-tls-custom-route/01-deploy-openstack.yaml
This file contains 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,5 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
oc kustomize ../../../../config/samples/base/openstackcontrolplane | oc apply -n $NAMESPACE -f - |
4 changes: 4 additions & 0 deletions
4
tests/kuttl/tests/ctlplane-tls-custom-route/02-assert-custom-route-secret.yaml
This file contains 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,4 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: barbican-custom-route |
5 changes: 5 additions & 0 deletions
5
tests/kuttl/tests/ctlplane-tls-custom-route/02-deploy-custom-route-secret.yaml
This file contains 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,5 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
oc apply -n $NAMESPACE -f ../../common/custom-barbican-route.yaml |
Oops, something went wrong.