feat: ask confirmation if ingress domain does not correspond the current cluster (#936)

* chore(Makefile): ask confirmation if ingress domain does not correspond the current cluster

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
pull/957/head
Serhii Leshchenko 2021-07-21 11:08:08 +03:00 committed by GitHub
parent 24f854c0c1
commit d8f87e4165
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 3 deletions

View File

@ -234,7 +234,7 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
yq -rYi ".spec.subresources.status = {}" "$(ECLIPSE_CHE_BACKUP_CRD_V1BETA1)"
yq -rYi ".spec.subresources.status = {}" "$(ECLIPSE_CHE_RESTORE_CRD_V1BETA1)"
# remove "required" attributes from v1beta1 crd files
# remove "required" attributes from v1beta1 crd files
$(MAKE) removeRequiredAttribute "filePath=$(ECLIPSE_CHE_CRD_V1BETA1)"
$(MAKE) removeRequiredAttribute "filePath=$(ECLIPSE_CHE_BACKUP_SERVER_CONFIGURATION_CRD_V1BETA1)"
$(MAKE) removeRequiredAttribute "filePath=$(ECLIPSE_CHE_BACKUP_CRD_V1BETA1)"
@ -300,11 +300,13 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
$(KUSTOMIZE) build config/default | kubectl delete -f -
prepare-templates:
echo "[INFO] Copying Che Operator ./templates ..."
cp templates/keycloak-provision.sh /tmp/keycloak-provision.sh
cp templates/delete-identity-provider.sh /tmp/delete-identity-provider.sh
cp templates/create-github-identity-provider.sh /tmp/create-github-identity-provider.sh
cp templates/oauth-provision.sh /tmp/oauth-provision.sh
cp templates/keycloak-update.sh /tmp/keycloak-update.sh
echo "[INFO] Copying Che Operator ./templates completed."
# Download Dev Workspace operator templates
echo "[INFO] Downloading Dev Workspace operator templates ..."
@ -337,18 +339,33 @@ create-namespace:
kubectl create namespace ${ECLIPSE_CHE_NAMESPACE} || true
set -e
.PHONY: apply-cr-crd
apply-cr-crd:
# before applying resources on K8s check if ingress domain corresponds to the current cluster
# no OpenShift ingress domain is ignored, so skip it
if [ "$$(oc api-resources --api-group='route.openshift.io' 2>&1 | grep -o routes)" != "routes" ]; then
export CLUSTER_API_URL=$$(oc whoami --show-server=true) || true;
export CLUSTER_DOMAIN=$$(echo $${CLUSTER_API_URL} | sed -E 's/https:\/\/(.*):.*/\1/g')
export CHE_CLUSTER_DOMAIN=$$(yq -r .spec.k8s.ingressDomain $(ECLIPSE_CHE_CR))
export CHE_CLUSTER_DOMAIN=$${CHE_CLUSTER_DOMAIN%".nip.io"}
if [ $${CLUSTER_DOMAIN} != $${CHE_CLUSTER_DOMAIN} ];then
echo "[WARN] Your cluster address is $${CLUSTER_DOMAIN} but CheCluster has $${CHE_CLUSTER_DOMAIN} configured"
echo "[WARN] Make sure that .spec.k8s.ingressDomain in $${ECLIPSE_CHE_CR} has the right value and rerun"
echo "[WARN] Press y to continue anyway. [y/n] ? " && read ans && [ $${ans:-N} = y ] || exit 1;
fi
fi
kubectl apply -f ${ECLIPSE_CHE_CRD_V1}
kubectl apply -f ${ECLIPSE_CHE_BACKUP_SERVER_CONFIGURATION_CRD_V1}
kubectl apply -f ${ECLIPSE_CHE_BACKUP_CRD_V1}
kubectl apply -f ${ECLIPSE_CHE_RESTORE_CRD_V1}
kubectl apply -f ${ECLIPSE_CHE_RESTORE_CRD_V1}
kubectl apply -f ${ECLIPSE_CHE_CR} -n ${ECLIPSE_CHE_NAMESPACE}
apply-cr-crd-beta:
kubectl apply -f ${ECLIPSE_CHE_CRD_V1BETA1}
kubectl apply -f ${ECLIPSE_CHE_BACKUP_SERVER_CONFIGURATION_CRD_V1BETA1}
kubectl apply -f ${ECLIPSE_CHE_BACKUP_CRD_V1BETA1}
kubectl apply -f ${ECLIPSE_CHE_RESTORE_CRD_V1BETA1}
kubectl apply -f ${ECLIPSE_CHE_RESTORE_CRD_V1BETA1}
kubectl apply -f ${ECLIPSE_CHE_CR} -n ${ECLIPSE_CHE_NAMESPACE}
create-env-file: prepare-templates