Skip to content

Commit

Permalink
PR #2582 ported to main
Browse files Browse the repository at this point in the history
  • Loading branch information
Toby Bellwood committed Apr 9, 2021
1 parent cf7edb0 commit 30987e1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
56 changes: 48 additions & 8 deletions images/kubectl-build-deploy-dind/build-deploy-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -831,9 +831,19 @@ if [ "${ENVIRONMENT_TYPE}" == "production" ]; then
touch /kubectl-build-deploy/${ROUTE_DOMAIN}-values.yaml
echo "$ROUTE_ANNOTATIONS" | yq p - annotations > /kubectl-build-deploy/${ROUTE_DOMAIN}-values.yaml

# ${ROUTE_DOMAIN} is used as a helm release name which be max 53 characters long.
# So we need some logic to make sure it's always max 53 characters
if [[ ${#ROUTE_DOMAIN} -gt 53 ]] ; then
# Trim the route domain to 47 characters, and add an 5 character hash of the domain at the end
# this gives a total of 53 characters
INGRESS_NAME=${ROUTE_DOMAIN:0:47}-$(echo ${ROUTE_DOMAIN} | md5sum | cut -f 1 -d " " | cut -c 1-5)
else
INGRESS_NAME=${ROUTE_DOMAIN}
fi

# The very first found route is set as MAIN_CUSTOM_ROUTE
if [ -z "${MAIN_CUSTOM_ROUTE+x}" ]; then
MAIN_CUSTOM_ROUTE=$ROUTE_DOMAIN
MAIN_CUSTOM_ROUTE=$INGRESS_NAME

# if we are in production we enabled monitoring for the main custom route
if [ "${ENVIRONMENT_TYPE}" == "production" ]; then
Expand All @@ -846,7 +856,7 @@ if [ "${ENVIRONMENT_TYPE}" == "production" ]; then

cat /kubectl-build-deploy/${ROUTE_DOMAIN}-values.yaml

helm template ${ROUTE_DOMAIN} \
helm template ${INGRESS_NAME} \
/kubectl-build-deploy/helmcharts/custom-ingress \
--set host="${ROUTE_DOMAIN}" \
--set service="${ROUTE_SERVICE}" \
Expand Down Expand Up @@ -941,9 +951,19 @@ if [ "${ENVIRONMENT_TYPE}" == "production" ]; then
touch /kubectl-build-deploy/${ROUTE_DOMAIN}-values.yaml
echo "$ROUTE_ANNOTATIONS" | yq p - annotations > /kubectl-build-deploy/${ROUTE_DOMAIN}-values.yaml

# ${ROUTE_DOMAIN} is used as a helm release name which be max 53 characters long.
# So we need some logic to make sure it's always max 53 characters
if [[ ${#ROUTE_DOMAIN} -gt 53 ]] ; then
# Trim the route domain to 47 characters, and add an 5 character hash of the domain at the end
# this gives a total of 53 characters
INGRESS_NAME=${ROUTE_DOMAIN:0:47}-$(echo ${ROUTE_DOMAIN} | md5sum | cut -f 1 -d " " | cut -c 1-5)
else
INGRESS_NAME=${ROUTE_DOMAIN}
fi

# The very first found route is set as MAIN_CUSTOM_ROUTE
if [ -z "${MAIN_CUSTOM_ROUTE+x}" ]; then
MAIN_CUSTOM_ROUTE=$ROUTE_DOMAIN
MAIN_CUSTOM_ROUTE=$INGRESS_NAME

# if we are in production we enabled monitoring for the main custom route
if [ "${ENVIRONMENT_TYPE}" == "production" ]; then
Expand All @@ -956,7 +976,7 @@ if [ "${ENVIRONMENT_TYPE}" == "production" ]; then

cat /kubectl-build-deploy/${ROUTE_DOMAIN}-values.yaml

helm template ${ROUTE_DOMAIN} \
helm template ${INGRESS_NAME} \
/kubectl-build-deploy/helmcharts/custom-ingress \
--set host="${ROUTE_DOMAIN}" \
--set service="${ROUTE_SERVICE}" \
Expand Down Expand Up @@ -1053,12 +1073,22 @@ if [ -n "$(cat .lagoon.yml | shyaml keys ${PROJECT}.environments.${BRANCH//./\\.
ROUTE_FASTLY_SERVICE_WATCH=true
fi

# ${ROUTE_DOMAIN} is used as a helm release name which be max 53 characters long.
# So we need some logic to make sure it's always max 53 characters
if [[ ${#ROUTE_DOMAIN} -gt 53 ]] ; then
# Trim the route domain to 47 characters, and add an 5 character hash of the domain at the end
# this gives a total of 53 characters
INGRESS_NAME=${ROUTE_DOMAIN:0:47}-$(echo ${ROUTE_DOMAIN} | md5sum | cut -f 1 -d " " | cut -c 1-5)
else
INGRESS_NAME=${ROUTE_DOMAIN}
fi

touch /kubectl-build-deploy/${ROUTE_DOMAIN}-values.yaml
echo "$ROUTE_ANNOTATIONS" | yq p - annotations > /kubectl-build-deploy/${ROUTE_DOMAIN}-values.yaml

# The very first found route is set as MAIN_CUSTOM_ROUTE
if [ -z "${MAIN_CUSTOM_ROUTE+x}" ]; then
MAIN_CUSTOM_ROUTE=$ROUTE_DOMAIN
MAIN_CUSTOM_ROUTE=$INGRESS_NAME

# if we are in production we enabled monitoring for the main custom route
if [ "${ENVIRONMENT_TYPE}" == "production" ]; then
Expand All @@ -1071,7 +1101,7 @@ if [ -n "$(cat .lagoon.yml | shyaml keys ${PROJECT}.environments.${BRANCH//./\\.

cat /kubectl-build-deploy/${ROUTE_DOMAIN}-values.yaml

helm template ${ROUTE_DOMAIN} \
helm template ${INGRESS_NAME} \
/kubectl-build-deploy/helmcharts/custom-ingress \
--set host="${ROUTE_DOMAIN}" \
--set service="${ROUTE_SERVICE}" \
Expand Down Expand Up @@ -1163,9 +1193,19 @@ else
touch /kubectl-build-deploy/${ROUTE_DOMAIN}-values.yaml
echo "$ROUTE_ANNOTATIONS" | yq p - annotations > /kubectl-build-deploy/${ROUTE_DOMAIN}-values.yaml

# ${ROUTE_DOMAIN} is used as a helm release name which be max 53 characters long.
# So we need some logic to make sure it's always max 53 characters
if [[ ${#ROUTE_DOMAIN} -gt 53 ]] ; then
# Trim the route domain to 47 characters, and add an 5 character hash of the domain at the end
# this gives a total of 53 characters
INGRESS_NAME=${ROUTE_DOMAIN:0:47}-$(echo ${ROUTE_DOMAIN} | md5sum | cut -f 1 -d " " | cut -c 1-5)
else
INGRESS_NAME=${ROUTE_DOMAIN}
fi

# The very first found route is set as MAIN_CUSTOM_ROUTE
if [ -z "${MAIN_CUSTOM_ROUTE+x}" ]; then
MAIN_CUSTOM_ROUTE=$ROUTE_DOMAIN
MAIN_CUSTOM_ROUTE=$INGRESS_NAME

# if we are in production we enabled monitoring for the main custom route
if [ "${ENVIRONMENT_TYPE}" == "production" ]; then
Expand All @@ -1178,7 +1218,7 @@ else

cat /kubectl-build-deploy/${ROUTE_DOMAIN}-values.yaml

helm template ${ROUTE_DOMAIN} \
helm template ${INGRESS_NAME} \
/kubectl-build-deploy/helmcharts/custom-ingress \
--set host="${ROUTE_DOMAIN}" \
--set service="${ROUTE_SERVICE}" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ lagoon.sh/prNumber: {{ .Values.prNumber | quote }}
lagoon.sh/prHeadBranch: {{ .Values.prHeadBranch | quote }}
lagoon.sh/prBaseBranch: {{ .Values.prBaseBranch | quote }}
{{- end }}
{{- end -}}
{{- end -}}

0 comments on commit 30987e1

Please sign in to comment.