@@ -34,7 +34,7 @@ import yaml;
3434print(yaml.load(open("' ${CKAN_VALUES_FILE} ' ")).get("ckanHelmChartVersion", ""))
3535' `
3636
37- LOAD_BALANCER_HOSTNAME=$( kubectl -n default get service traefik -o yaml \
37+ LOAD_BALANCER_HOSTNAME=$( kubectl $KUBECTL_GLOBAL_ARGS -n default get service traefik -o yaml \
3838 | python3 -c ' import sys, yaml; print(yaml.load(sys.stdin)["status"]["loadBalancer"]["ingress"][0]["hostname"])' 2> /dev/null)
3939
4040if [ " ${REGISTER_SUBDOMAIN} " != " " ]; then
@@ -97,7 +97,7 @@ if ! [ -z "${INSTANCE_DOMAIN}" ]; then
9797
9898 mv $TRAEFIK_VALUES_MODIFIED_FILE $TRAEFIK_VALUES_FILE
9999
100- echo Deploying to kube context ` kubectl config current-context` , load balancer hostname: ${LOAD_BALANCER_HOSTNAME}
100+ echo Deploying to kube context ` kubectl $KUBECTL_GLOBAL_ARGS config current-context` , load balancer hostname: ${LOAD_BALANCER_HOSTNAME}
101101
102102 helm upgrade " ${TRAEFIK_HELM_RELEASE_NAME} " " ${TRAEFIK_HELM_CHART_PATH} " \
103103 --namespace " ${TRAEFIK_NAMESPACE} " -if " ${TRAEFIK_VALUES_FILE} " --dry-run --debug > /dev/stderr && \
@@ -107,22 +107,22 @@ if ! [ -z "${INSTANCE_DOMAIN}" ]; then
107107 fi
108108fi
109109
110- if kubectl get ns " ${INSTANCE_NAMESPACE} " ; then
110+ if kubectl $KUBECTL_GLOBAL_ARGS get ns " ${INSTANCE_NAMESPACE} " ; then
111111 IS_NEW_NAMESPACE=0
112112 echo Namespace exists: ${INSTANCE_NAMESPACE}
113113 echo skipping RBAC creation
114114else
115115 IS_NEW_NAMESPACE=1
116116 echo Creating namespace: ${INSTANCE_NAMESPACE}
117117
118- kubectl create ns " ${INSTANCE_NAMESPACE} " && \
119- kubectl --namespace " ${INSTANCE_NAMESPACE} " \
118+ kubectl $KUBECTL_GLOBAL_ARGS create ns " ${INSTANCE_NAMESPACE} " && \
119+ kubectl $KUBECTL_GLOBAL_ARGS --namespace " ${INSTANCE_NAMESPACE} " \
120120 create serviceaccount " ckan-${INSTANCE_NAMESPACE} -operator" && \
121- kubectl --namespace " ${INSTANCE_NAMESPACE} " \
121+ kubectl $KUBECTL_GLOBAL_ARGS --namespace " ${INSTANCE_NAMESPACE} " \
122122 create role " ckan-${INSTANCE_NAMESPACE} -operator-role" \
123123 --verb list,get,create \
124124 --resource secrets,pods,pods/exec,pods/portforward && \
125- kubectl --namespace " ${INSTANCE_NAMESPACE} " \
125+ kubectl $KUBECTL_GLOBAL_ARGS --namespace " ${INSTANCE_NAMESPACE} " \
126126 create rolebinding " ckan-${INSTANCE_NAMESPACE} -operator-rolebinding" \
127127 --role " ckan-${INSTANCE_NAMESPACE} -operator-role" \
128128 --serviceaccount " ${INSTANCE_NAMESPACE} :ckan-${INSTANCE_NAMESPACE} -operator"
@@ -153,7 +153,7 @@ helm_upgrade() {
153153wait_for_pods () {
154154 DELAY_SECONDS=10
155155 TOTAL_SECONDS=0
156- while ! kubectl --namespace " ${INSTANCE_NAMESPACE} " get pods -o yaml | python3 -c '
156+ while ! kubectl $KUBECTL_GLOBAL_ARGS --namespace " ${INSTANCE_NAMESPACE} " get pods -o yaml | python3 -c '
157157import yaml, sys;
158158for pod in yaml.load(sys.stdin)["items"]:
159159 if pod["status"]["phase"] != "Running":
@@ -164,17 +164,17 @@ for pod in yaml.load(sys.stdin)["items"]:
164164 exit(1)
165165exit(0)
166166 ' ; do
167- kubectl --namespace " ${INSTANCE_NAMESPACE} " get pods
167+ kubectl $KUBECTL_GLOBAL_ARGS --namespace " ${INSTANCE_NAMESPACE} " get pods
168168 sleep $DELAY_SECONDS
169169 TOTAL_SECONDS=$( expr $TOTAL_SECONDS + $DELAY_SECONDS )
170170 echo " ...${TOTAL_SECONDS} s"
171171 # if [ "$(expr $TOTAL_SECONDS > 180)" == "1" ]; then
172172 # echo "Waiting too long, deleting and redeploying ckan and jobs deployments"
173- # kubectl delete deployment ckan jobs
173+ # kubectl $KUBECTL_GLOBAL_ARGS delete deployment ckan jobs
174174 # ! helm_upgrade && return 1
175175 # fi
176176 done && \
177- kubectl --namespace " ${INSTANCE_NAMESPACE} " get pods
177+ kubectl $KUBECTL_GLOBAL_ARGS --namespace " ${INSTANCE_NAMESPACE} " get pods
178178}
179179
180180if [ " ${IS_NEW_NAMESPACE} " == " 1" ]; then
@@ -189,23 +189,23 @@ sleep 1 &&\
189189wait_for_pods
190190[ " $? " != " 0" ] && exit 1
191191
192- CKAN_POD_NAME=$( kubectl -n ${INSTANCE_NAMESPACE} get pods -l " app=ckan" -o ' jsonpath={.items[0].metadata.name}' )
192+ CKAN_POD_NAME=$( kubectl $KUBECTL_GLOBAL_ARGS -n ${INSTANCE_NAMESPACE} get pods -l " app=ckan" -o ' jsonpath={.items[0].metadata.name}' )
193193echo CKAN_POD_NAME = " ${CKAN_POD_NAME} " > /dev/stderr
194194
195- if kubectl -n ${INSTANCE_NAMESPACE} exec -it ${CKAN_POD_NAME} -- bash -c \
195+ if kubectl $KUBECTL_GLOBAL_ARGS -n ${INSTANCE_NAMESPACE} exec -it ${CKAN_POD_NAME} -- bash -c \
196196 " ckan-paster --plugin=ckan sysadmin -c /etc/ckan/production.ini list" \
197197 | grep " name=admin"
198198then
199199 CKAN_ADMIN_PASSWORD=$( \
200- get_secret_from_json " $( kubectl -n " ${INSTANCE_NAMESPACE} " get secret ckan-admin-password -o json) " \
200+ get_secret_from_json " $( kubectl $KUBECTL_GLOBAL_ARGS -n " ${INSTANCE_NAMESPACE} " get secret ckan-admin-password -o json) " \
201201 " CKAN_ADMIN_PASSWORD" \
202202 )
203203 echo admin user already exists
204204else
205205 CKAN_ADMIN_PASSWORD=$( python3 -c " import binascii,os;print(binascii.hexlify(os.urandom(12)).decode())" )
206- ! kubectl -n " ${INSTANCE_NAMESPACE} " create secret generic ckan-admin-password " --from-literal=CKAN_ADMIN_PASSWORD=${CKAN_ADMIN_PASSWORD} " && exit 1
206+ ! kubectl $KUBECTL_GLOBAL_ARGS -n " ${INSTANCE_NAMESPACE} " create secret generic ckan-admin-password " --from-literal=CKAN_ADMIN_PASSWORD=${CKAN_ADMIN_PASSWORD} " && exit 1
207207 echo y \
208- | kubectl -n ${INSTANCE_NAMESPACE} exec -it ${CKAN_POD_NAME} -- bash -c \
208+ | kubectl $KUBECTL_GLOBAL_ARGS -n ${INSTANCE_NAMESPACE} exec -it ${CKAN_POD_NAME} -- bash -c \
209209 " ckan-paster --plugin=ckan sysadmin -c /etc/ckan/production.ini add admin password=${CKAN_ADMIN_PASSWORD} email=admin@${INSTANCE_ID} " \
210210 > /dev/stderr
211211 [ " $? " != " 0" ] && exit 1
214214if ! [ -z " ${INSTANCE_DOMAIN} " ]; then
215215 echo Running sanity tests for CKAN instance ${INSTSANCE_ID} on domain ${INSTANCE_DOMAIN}
216216 if [ " $( curl https://${INSTANCE_DOMAIN} /api/3) " != ' {"version": 3}' ]; then
217- kubectl -n default patch deployment traefik \
217+ kubectl $KUBECTL_GLOBAL_ARGS -n default patch deployment traefik \
218218 -p " {\" spec\" :{\" template\" :{\" metadata\" :{\" labels\" :{\" date\" :\" ` date +' %s' ` \" }}}}}" && \
219- kubectl -n default rollout status deployment traefik && \
219+ kubectl $KUBECTL_GLOBAL_ARGS -n default rollout status deployment traefik && \
220220 sleep 10 && \
221221 [ " $( curl https://${INSTANCE_DOMAIN} /api/3) " != ' {"version": 3}' ]
222222 [ " $? " != " 0" ] && exit 1
0 commit comments