Skip to content

Commit 324776b

Browse files
committed
[NO-ISSUE] compatibility with all cert-managers
There's two variant of cert-manager available on the openshift operatorHub, one for upstream (the community one) and one for downstream built by Red Hat. Depending on which one the cluster administrator did chose, the deploy and undeploy script must adapt to it. This is what this PR brings in to the table. Now the scripts are looking first if the upstream version is installed, and then if the downstream version is there. The deploy script will fail if no cert-manager are present on the cluster.
1 parent db69a83 commit 324776b

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

deploy.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,36 @@ done
4040
certManagerNamespace=$(oc get Subscriptions --all-namespaces -ojson | jq -r '.items[] | select(.spec.name == "cert-manager") | .metadata.namespace')
4141
if test -z "$certManagerNamespace"
4242
then
43-
echo "cert-manager's namespace can't be determined, check that it is installed"
44-
oc get Subscriptions --all-namespaces
45-
exit 1
43+
certManagerNamespace=$(oc get Subscriptions --all-namespaces -ojson | jq -r '.items[] | select(.spec.name == "openshift-cert-manager-operator") | .metadata.namespace')
44+
if test -z "$certManagerNamespace"
45+
then
46+
echo "cert-manager's namespace can't be determined, check that it is installed"
47+
oc get Subscriptions --all-namespaces
48+
exit 1
49+
fi
4650
fi
4751
echo "cert-manager's namespace: $certManagerNamespace"
4852

4953
# retrieve the cluster domain to produce a valid cluster issuer
5054
clusterDomain=$(oc get -n openshift-ingress-operator ingresscontroller/default -o json | jq -r '.status.domain')
5155
if test -z "$certManagerNamespace"
5256
then
53-
echo "The cluster domain can't be retrived"
54-
exit 1
57+
echo "The cluster domain can't be retrived"
58+
exit 1
5559
fi
5660
echo "cluster domain: $clusterDomain"
5761

5862
echo "deploying using image: ${API_SERVER_IMAGE}"
5963
oc kustomize deploy \
6064
| sed "s|image: .*|image: ${API_SERVER_IMAGE}|" \
6165
| sed "s|- issuer.mydomain.tld|- issuer.${clusterDomain}|" \
66+
| sed "s|namespace: openshift-operators|namespace: ${certManagerNamespace}|" \
6267
| oc apply -f -
6368

64-
65-
while ! kubectl get secret jolokia-api-server-selfsigned-ca-cert-secret --namespace openshift-operators; do echo "Waiting for the CA"; sleep 1; done
69+
while ! oc get secret jolokia-api-server-selfsigned-ca-cert-secret --namespace=${certManagerNamespace}; do echo "Waiting for the CA"; sleep 1; done
6670
# copy the secret from the cert-manager namespace to the jolokia api server
6771
# namespace
6872
oc get secret jolokia-api-server-selfsigned-ca-cert-secret \
69-
--namespace=openshift-operators -oyaml \
73+
--namespace=${certManagerNamespace} -oyaml \
7074
| sed s/"namespace: ${certManagerNamespace}"/"namespace: activemq-artemis-jolokia-api-server"/\ \
71-
| kubectl apply -n activemq-artemis-jolokia-api-server -f -
75+
| oc apply -n activemq-artemis-jolokia-api-server -f -

undeploy.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
#!/usr/bin/env sh
22

3-
oc kustomize deploy | oc delete -f -
3+
# find the cert-manager operator namespace, if this can't be retrived there's no
4+
# possibility to proceed
5+
certManagerNamespace=$(oc get Subscriptions --all-namespaces -ojson | jq -r '.items[] | select(.spec.name == "cert-manager") | .metadata.namespace')
6+
if test -z "$certManagerNamespace"
7+
then
8+
certManagerNamespace=$(oc get Subscriptions --all-namespaces -ojson | jq -r '.items[] | select(.spec.name == "openshift-cert-manager-operator") | .metadata.namespace')
9+
if test -z "$certManagerNamespace"
10+
then
11+
echo "cert-manager's namespace can't be determined, defaulting to default namespace"
12+
certManagerNamespace="openshift-operators"
13+
fi
14+
fi
15+
echo "cert-manager's namespace: $certManagerNamespace"
16+
oc kustomize deploy \
17+
| sed "s|namespace: openshift-operators|namespace: ${certManagerNamespace}|" \
18+
| oc delete -f -
419
oc delete secret jolokia-api-server-selfsigned-ca-cert-secret -n activemq-artemis-jolokia-api-server
5-
oc delete secret jolokia-api-server-selfsigned-ca-cert-secret -n openshift-operators
20+
oc delete secret jolokia-api-server-selfsigned-ca-cert-secret -n ${certManagerNamespace}

0 commit comments

Comments
 (0)