forked from artemiscloud/activemq-artemis-jolokia-api-server
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeploy.sh
executable file
·75 lines (67 loc) · 2.5 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env sh
DEFAULT_IMAGE="quay.io/arkmq-org/activemq-artemis-jolokia-api-server:latest"
API_SERVER_IMAGE=${DEFAULT_IMAGE}
SCRIPT_NAME=$(basename "$0")
function printUsage() {
echo "${SCRIPT_NAME}: Deploying to openshift"
echo "Usage:"
echo " ./${SCRIPT_NAME} -i|--image <image url>"
echo "Options: "
echo " -i|--image Specify the plugin image to deploy. (default is ${DEFAULT_IMAGE})"
echo " -h|--help Print this message."
}
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
printUsage
exit 0
;;
-i|--image)
API_SERVER_IMAGE="$2"
shift
shift
;;
-*|--*)
echo "Unknown option $1"
printUsage
exit 1
;;
*)
;;
esac
done
# find the cert-manager operator namespace, if this can't be retrived there's no
# possibility to proceed
certManagerNamespace=$(oc get Subscriptions --all-namespaces -ojson | jq -r '.items[] | select(.spec.name == "cert-manager") | .metadata.namespace')
if test -z "$certManagerNamespace"
then
certManagerNamespace=$(oc get Subscriptions --all-namespaces -ojson | jq -r '.items[] | select(.spec.name == "openshift-cert-manager-operator") | .metadata.namespace')
if test -z "$certManagerNamespace"
then
echo "cert-manager's namespace can't be determined, check that it is installed"
oc get Subscriptions --all-namespaces
exit 1
fi
fi
echo "cert-manager's namespace: $certManagerNamespace"
# retrieve the cluster domain to produce a valid cluster issuer
clusterDomain=$(oc get -n openshift-ingress-operator ingresscontroller/default -o json | jq -r '.status.domain')
if test -z "$certManagerNamespace"
then
echo "The cluster domain can't be retrived"
exit 1
fi
echo "cluster domain: $clusterDomain"
echo "deploying using image: ${API_SERVER_IMAGE}"
oc kustomize deploy \
| sed "s|image: .*|image: ${API_SERVER_IMAGE}|" \
| sed "s|- issuer.mydomain.tld|- issuer.${clusterDomain}|" \
| sed "s|namespace: openshift-operators|namespace: ${certManagerNamespace}|" \
| oc apply -f -
while ! oc get secret jolokia-api-server-selfsigned-ca-cert-secret --namespace=${certManagerNamespace}; do echo "Waiting for the CA"; sleep 1; done
# copy the secret from the cert-manager namespace to the jolokia api server
# namespace
oc get secret jolokia-api-server-selfsigned-ca-cert-secret \
--namespace=${certManagerNamespace} -oyaml \
| sed s/"namespace: ${certManagerNamespace}"/"namespace: activemq-artemis-jolokia-api-server"/\ \
| oc apply -n activemq-artemis-jolokia-api-server -f -