-
Notifications
You must be signed in to change notification settings - Fork 14
/
argo.sh
99 lines (73 loc) · 2.74 KB
/
argo.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
# LANG=C
SLEEP_SECONDS="${SLEEP_SECONDS:-8}"
ARGO_NS="openshift-gitops"
ARGO_CHANNEL="latest"
ARGO_KUSTOMIZE_OPERATOR="${GIT_ROOT}/components/operators/openshift-gitops-operator/operator/overlays/${ARGO_CHANNEL}"
ARGO_KUSTOMIZE_INSTANCE="${GIT_ROOT}/components/operators/openshift-gitops-operator/instance/overlays/default"
argo_print_info(){
route=$(oc get route openshift-gitops-server -o jsonpath='{.spec.host}' -n ${ARGO_NS} 2>/dev/null)
[ -z ${route+x} ] || return 1
echo
echo "Access ArgoCD here:"
echo "https://${route}"
echo
}
argo_wait_for_operator(){
ARGO_DEPLOY_STABLE=(cluster kam openshift-gitops-applicationset-controller openshift-gitops-redis openshift-gitops-repo-server openshift-gitops-server)
echo "Waiting for OpenShift GitOps operator to start"
until oc get deployment openshift-gitops-operator-controller-manager -n openshift-gitops-operator >/dev/null 2>&1
do
sleep 1
done
echo "Waiting for openshift-gitops namespace to be created"
until oc get ns ${ARGO_NS} >/dev/null 2>&1
do
sleep 1
done
echo "Waiting for OpenShift GitOps deployments to start"
until oc get deployment cluster -n ${ARGO_NS} >/dev/null 2>&1
do
sleep 1
done
echo "Waiting for all pods to be created"
for i in "${ARGO_DEPLOY_STABLE[@]}"
do
echo "Waiting for deployment $i"
oc rollout status deployment "$i" -n "${ARGO_NS}" >/dev/null 2>&1
done
echo
}
argo_install(){
echo
echo "Installing OpenShift GitOps Operator..."
oc apply -k "${ARGO_KUSTOMIZE_OPERATOR}"
echo "Pause ${SLEEP_SECONDS} seconds for the creation of the gitops-operator..."
sleep "${SLEEP_SECONDS}"
argo_wait_for_operator
# apply the cr you know and love
oc apply -k "${ARGO_KUSTOMIZE_INSTANCE}"
echo
echo "OpenShift GitOps successfully installed."
argo_print_info
}
argo_uninstall(){
ARGO_DEPLOY_STABLE=(cluster kam openshift-gitops-applicationset-controller openshift-gitops-redis openshift-gitops-repo-server openshift-gitops-server)
for i in "${ARGO_DEPLOY_STABLE[@]}"
do
echo "Scaling OpenShift GitOps deployment $i to 0"
oc scale --replicas=0 deployment "$i" -n "${ARGO_NS}"
done
# shellcheck disable=SC2034
NAMESPACE="${ARGO_NS}"
k8s_null_finalizers_for_all_resource_instances applicationsets.argoproj.io
oc delete applicationsets.argoproj.io -n "${ARGO_NS}" --all
k8s_null_finalizers_for_all_resource_instances application.argoproj.io
oc delete application.argoproj.io -n "${ARGO_NS}" --all
k8s_null_finalizers_for_all_resource_instances argocds.argoproj.io
oc delete argocds.argoproj.io -n "${ARGO_NS}" --all
oc delete -k "${ARGO_KUSTOMIZE_OPERATOR}"
oc delete -k "${ARGO_KUSTOMIZE_INSTANCE}"
oc delete project "${ARGO_NS}"-operator
oc delete project "${ARGO_NS}"
}