3 # ============LICENSE_START=======================================================
4 # Copyright (C) 2023 Nordix Foundation.
5 # ================================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 # SPDX-License-Identifier: Apache-2.0
19 # ============LICENSE_END=========================================================
24 echo "No argument supplied"
29 WORKDIR=$(dirname "$(realpath "$0")")
31 if [ "$OPERATION" == "deploy" ]; then
32 echo "Deploying cert-manager application..."
33 echo "-------------------------------------"
34 kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml
36 echo "Waiting for pods to start..."
37 echo "----------------------------"
38 kubectl wait deployment -n cert-manager cert-manager --for=condition=available --timeout=300s
39 kubectl wait deployment -n cert-manager cert-manager-cainjector --for=condition=available --timeout=300s
40 kubectl wait deployment -n cert-manager cert-manager-webhook --for=condition=available --timeout=300s
42 echo "Checking pod status..."
43 echo "----------------------"
44 kubectl get pods -n cert-manager
46 # Once the pods are up and running we still need to wait for the certificate controller process to start
47 # before certificates can be issued
48 echo "Waiting for certificate controller..."
49 echo "------------------------------------"
52 echo "Creating certificates..."
53 echo "------------------------"
54 kubectl apply -f $WORKDIR/cluster-issuer.yaml
55 kubectl apply -f $WORKDIR/issuer.yaml
56 kubectl apply -f $WORKDIR/webhook-server-certificate.yaml
57 kubectl apply -f $WORKDIR/keycloak-server-certificate.yaml
58 kubectl apply -f $WORKDIR/keycloak-client-certificate.yaml
59 elif [ "$OPERATION" == "undeploy" ]; then
60 echo "Deleting certificates..."
61 echo "------------------------"
62 kubectl delete -f $WORKDIR/cluster-issuer.yaml
63 kubectl delete -f $WORKDIR/issuer.yaml
64 kubectl delete -f $WORKDIR/webhook-server-certificate.yaml
65 kubectl delete -f $WORKDIR/keycloak-server-certificate.yaml
66 kubectl delete -f $WORKDIR/keycloak-client-certificate.yaml
67 kubectl delete secret -n default cm-cluster-issuer-rootca-secret
68 kubectl delete secret -n default cm-keycloak-client-certs
69 kubectl delete secret -n default cm-keycloak-server-certs
70 kubectl delete secret -n default cm-webhook-server-certs
71 echo "Undeploying cert-manager application..."
72 echo "---------------------------------------"
73 kubectl delete -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml
75 echo "Unrecogized operation ${OPERATION}"