Skip to content

Commit

Permalink
Merge pull request #2546 from amazeeio/lagoon_114x
Browse files Browse the repository at this point in the history
Match PRs from Lagoon 1.14.x
  • Loading branch information
Toby Bellwood authored Feb 26, 2021
2 parents fb7a434 + 09c380e commit 1de1585
Show file tree
Hide file tree
Showing 37 changed files with 1,781 additions and 858 deletions.
27 changes: 14 additions & 13 deletions images/kubectl-build-deploy-dind/build-deploy-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ if [[ "$BUILD_TYPE" == "pullrequest" || "$BUILD_TYPE" == "branch" ]]; then
BUILD_ARGS+=(--build-arg IMAGE_REPO="${CI_OVERRIDE_IMAGE_REPO}")
BUILD_ARGS+=(--build-arg LAGOON_PROJECT="${PROJECT}")
BUILD_ARGS+=(--build-arg LAGOON_ENVIRONMENT="${ENVIRONMENT}")
BUILD_ARGS+=(--build-arg LAGOON_ENVIRONMENT_TYPE="${ENVIRONMENT_TYPE}")
BUILD_ARGS+=(--build-arg LAGOON_BUILD_TYPE="${BUILD_TYPE}")
BUILD_ARGS+=(--build-arg LAGOON_GIT_SOURCE_REPOSITORY="${SOURCE_REPOSITORY}")

Expand Down Expand Up @@ -601,20 +602,21 @@ do
helm template ${SERVICE_NAME} /kubectl-build-deploy/helmcharts/${SERVICE_TYPE} -s $HELM_SERVICE_TEMPLATE -f /kubectl-build-deploy/values.yaml "${HELM_ARGUMENTS[@]}" > $YAML_FOLDER/${SERVICE_NAME}.yaml
fi

HELM_INGRESS_TEMPLATE="templates/ingress.yaml"
if [ -f /kubectl-build-deploy/helmcharts/${SERVICE_TYPE}/$HELM_INGRESS_TEMPLATE ]; then
if [ $ROUTES_AUTOGENERATE_ENABLED == "true" ]; then
HELM_INGRESS_TEMPLATE="templates/ingress.yaml"
if [ -f /kubectl-build-deploy/helmcharts/${SERVICE_TYPE}/$HELM_INGRESS_TEMPLATE ]; then

# The very first generated route is set as MAIN_GENERATED_ROUTE
if [ -z "${MAIN_GENERATED_ROUTE+x}" ]; then
MAIN_GENERATED_ROUTE=$SERVICE_NAME
fi
# The very first generated route is set as MAIN_GENERATED_ROUTE
if [ -z "${MAIN_GENERATED_ROUTE+x}" ]; then
MAIN_GENERATED_ROUTE=$SERVICE_NAME
fi

helm template ${SERVICE_NAME} /kubectl-build-deploy/helmcharts/${SERVICE_TYPE} -s $HELM_INGRESS_TEMPLATE -f /kubectl-build-deploy/values.yaml "${HELM_ARGUMENTS[@]}" > $YAML_FOLDER/${SERVICE_NAME}.yaml
helm template ${SERVICE_NAME} /kubectl-build-deploy/helmcharts/${SERVICE_TYPE} -s $HELM_INGRESS_TEMPLATE -f /kubectl-build-deploy/values.yaml "${HELM_ARGUMENTS[@]}" > $YAML_FOLDER/${SERVICE_NAME}.yaml
fi
fi

HELM_DBAAS_TEMPLATE="templates/dbaas.yaml"
if [ -f /kubectl-build-deploy/helmcharts/${SERVICE_TYPE}/$HELM_DBAAS_TEMPLATE ]; then
# cat $KUBERNETES_SERVICES_TEMPLATE
# Load the requested class and plan for this service
DBAAS_ENVIRONMENT="${MAP_SERVICE_NAME_TO_DBAAS_ENVIRONMENT["${SERVICE_NAME}"]}"
yq write -i -- /kubectl-build-deploy/${SERVICE_NAME}-values.yaml 'environment' $DBAAS_ENVIRONMENT
Expand Down Expand Up @@ -1226,17 +1228,17 @@ if [[ "${CAPABILITIES[@]}" =~ "backup.appuio.ch/v1alpha1/Schedule" ]]; then
PRODUCTION_DAILY_BACKUP_RETENTION=$(cat .lagoon.yml | shyaml get-value backup-retention.production.daily "")

# Set template parameters for retention values (prefer .lagoon.yml values over supplied defaults after ensuring they are valid integers via "-eq" comparison)
if [ ! -z $PRODUCTION_MONTHLY_BACKUP_RETENTION ] && [ "$PRODUCTION_MONTHLY_BACKUP_RETENTION" -eq "$PRODUCTION_MONTHLY_BACKUP_RETENTION" ] && [ $ENVIRONMENT_TYPE = 'production']; then
if [ ! -z $PRODUCTION_MONTHLY_BACKUP_RETENTION ] && [ "$PRODUCTION_MONTHLY_BACKUP_RETENTION" -eq "$PRODUCTION_MONTHLY_BACKUP_RETENTION" ] && [ $ENVIRONMENT_TYPE = 'production' ]; then
MONTHLY_BACKUP_RETENTION=${PRODUCTION_MONTHLY_BACKUP_RETENTION}
else
MONTHLY_BACKUP_RETENTION=${MONTHLY_BACKUP_DEFAULT_RETENTION}
fi
if [ ! -z $PRODUCTION_WEEKLY_BACKUP_RETENTION ] && [ "$PRODUCTION_WEEKLY_BACKUP_RETENTION" -eq "$PRODUCTION_WEEKLY_BACKUP_RETENTION" ] && [ $ENVIRONMENT_TYPE = 'production']; then
if [ ! -z $PRODUCTION_WEEKLY_BACKUP_RETENTION ] && [ "$PRODUCTION_WEEKLY_BACKUP_RETENTION" -eq "$PRODUCTION_WEEKLY_BACKUP_RETENTION" ] && [ $ENVIRONMENT_TYPE = 'production' ]; then
WEEKLY_BACKUP_RETENTION=${PRODUCTION_WEEKLY_BACKUP_RETENTION}
else
WEEKLY_BACKUP_RETENTION=${WEEKLY_BACKUP_DEFAULT_RETENTION}
fi
if [ ! -z $PRODUCTION_DAILY_BACKUP_RETENTION ] && [ "$PRODUCTION_DAILY_BACKUP_RETENTION" -eq "$PRODUCTION_DAILY_BACKUP_RETENTION" ] && [ $ENVIRONMENT_TYPE = 'production']; then
if [ ! -z $PRODUCTION_DAILY_BACKUP_RETENTION ] && [ "$PRODUCTION_DAILY_BACKUP_RETENTION" -eq "$PRODUCTION_DAILY_BACKUP_RETENTION" ] && [ $ENVIRONMENT_TYPE = 'production' ]; then
DAILY_BACKUP_RETENTION=${PRODUCTION_DAILY_BACKUP_RETENTION}
else
DAILY_BACKUP_RETENTION=${DAILY_BACKUP_DEFAULT_RETENTION}
Expand Down Expand Up @@ -1270,8 +1272,7 @@ if [[ "${CAPABILITIES[@]}" =~ "backup.appuio.ch/v1alpha1/Schedule" ]]; then
--set baasBucketName="${BAAS_BUCKET_NAME}" > $YAML_FOLDER/k8up-lagoon-backup-schedule.yaml \
--set prune.retention.keepMonthly=$MONTHLY_BACKUP_RETENTION \
--set prune.retention.keepWeekly=$WEEKLY_BACKUP_RETENTION \
--set prune.retention.keepDaily=$DAILY_BACKUP_RETENTION \
--set lagoonEnvironmentType=$LAGOON_ENVIRONMENT_TYPE
--set prune.retention.keepDaily=$DAILY_BACKUP_RETENTION
fi

if [ "$(ls -A $YAML_FOLDER/)" ]; then
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{ if .Capabilities.APIVersions.Has "backup.appuio.ch/v1alpha1/PreBackupPod" }}
apiVersion: backup.appuio.ch/v1alpha1
kind: PreBackupPod
metadata:
name: {{ include "mongodb-dbaas.fullname" . }}-prebackuppod
labels:
{{- include "mongodb-dbaas.labels" . | nindent 4 }}
annotations:
{{- include "mongodb-dbaas.annotations" . | nindent 4 }}
spec:
backupCommand: /bin/sh -c "mongodump --uri=mongodb://${BACKUP_DB_USER}:${BACKUP_DB_PASSWORD}@${BACKUP_DB_HOST}:${BACKUP_DB_PORT}/${BACKUP_DB_NAME}?ssl=true&sslInsecure=true&tls=true&tlsInsecure=true --archive"
fileExtension: .{{ include "mongodb-dbaas.fullname" . }}.bson
pod:
metadata:
labels:
prebackuppod: {{ include "mongodb-dbaas.fullname" . }}
{{- include "mongodb-dbaas.labels" . | nindent 8 }}
spec:
containers:
- args:
- sleep
- infinity
env:
- name: BACKUP_DB_HOST
valueFrom:
configMapKeyRef:
key: {{ include "mongodb-dbaas.fullnameUppercase" . }}_HOST
name: lagoon-env
- name: BACKUP_DB_USER
valueFrom:
configMapKeyRef:
key: {{ include "mongodb-dbaas.fullnameUppercase" . }}_USER
name: lagoon-env
- name: BACKUP_DB_PASSWORD
valueFrom:
configMapKeyRef:
key: {{ include "mongodb-dbaas.fullnameUppercase" . }}_PASSWORD
name: lagoon-env
- name: BACKUP_DB_NAME
valueFrom:
configMapKeyRef:
key: {{ include "mongodb-dbaas.fullnameUppercase" . }}_DB_NAME
name: lagoon-env
- name: BACKUP_DB_PORT
valueFrom:
configMapKeyRef:
key: {{ include "mongodb-dbaas.fullnameUppercase" . }}_DB_PORT
name: lagoon-env
- name: BACKUP_DB_AUTHSOURCE
valueFrom:
configMapKeyRef:
key: {{ include "mongodb-dbaas.fullnameUppercase" . }}_DB_AUTHSOURCE
name: lagoon-env
- name: BACKUP_DB_AUTHMECHANISM
valueFrom:
configMapKeyRef:
key: {{ include "mongodb-dbaas.fullnameUppercase" . }}_DB_AUTHMECHANISM
name: lagoon-env
- name: BACKUP_DB_AUTHTLS
valueFrom:
configMapKeyRef:
key: {{ include "mongodb-dbaas.fullnameUppercase" . }}_DB_AUTHTLS
name: lagoon-env
image: imagecache.amazeeio.cloud/uselagoon/php-8.0-cli
imagePullPolicy: Always
name: {{ include "mongodb-dbaas.fullname" . }}-prebackuppod
{{ end }}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ metadata:
{{- include "node-persistent.annotations" . | nindent 4 }}
spec:
accessModes:
- ReadWriteOnce
- ReadWriteMany
storageClassName: bulk
resources:
requests:
storage: {{ .Values.persistentStorage.size | quote }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{ if .Capabilities.APIVersions.Has "backup.appuio.ch/v1alpha1/PreBackupPod" }}
apiVersion: backup.appuio.ch/v1alpha1
kind: PreBackupPod
metadata:
name: {{ include "postgres-dbaas.fullname" . }}-prebackuppod
labels:
{{- include "postgres-dbaas.labels" . | nindent 4 }}
annotations:
{{- include "postgres-dbaas.annotations" . | nindent 4 }}
spec:
backupCommand: /bin/sh -c "PGPASSWORD=$BACKUP_DB_PASSWORD pg_dump --host=$BACKUP_DB_HOST --port=$BACKUP_DB_PORT --dbname=$BACKUP_DB_NAME --format=t -w"
fileExtension: .{{ include "postgres-dbaas.fullname" . }}.tar
pod:
metadata:
labels:
prebackuppod: {{ include "postgres-dbaas.fullname" . }}
{{- include "postgres-dbaas.labels" . | nindent 8 }}
spec:
containers:
- args:
- sleep
- infinity
env:
- name: BACKUP_DB_HOST
valueFrom:
configMapKeyRef:
key: {{ include "postgres-dbaas.fullnameUppercase" . }}_HOST
name: lagoon-env
- name: BACKUP_DB_PORT
valueFrom:
configMapKeyRef:
key: {{ include "postgres-dbaas.fullnameUppercase" . }}_PORT
name: lagoon-env
- name: BACKUP_DB_USERNAME
valueFrom:
configMapKeyRef:
key: {{ include "postgres-dbaas.fullnameUppercase" . }}_USERNAME
name: lagoon-env
- name: BACKUP_DB_PASSWORD
valueFrom:
configMapKeyRef:
key: {{ include "postgres-dbaas.fullnameUppercase" . }}_PASSWORD
name: lagoon-env
- name: BACKUP_DB_NAME
valueFrom:
configMapKeyRef:
key: {{ include "postgres-dbaas.fullnameUppercase" . }}_NAME
name: lagoon-env
image: imagecache.amazeeio.cloud/uselagoon/php-8.0-cli
imagePullPolicy: Always
name: {{ include "postgres-dbaas.fullname" . }}-prebackuppod
{{ end }}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
{{- include "postgres-single.labels" . | nindent 8 }}
annotations:
{{- include "postgres-single.annotations" . | nindent 8 }}
k8up.syn.tools/backupcommand: /bin/sh -c "/bin/busybox tar -cf - -C /var/lib/postgresql/data ."
k8up.syn.tools/backupcommand: /bin/sh -c "/bin/busybox tar -cf - -C {{ .Values.persistentStorage.path | quote }} ."
k8up.syn.tools/file-extension: .{{ include "postgres-single.fullname" . }}.tar
lagoon.sh/configMapSha: {{ .Values.configMapSha | quote }}
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ spec:
{{- include "redis-persistent.datadogLabels" . | nindent 8 }}
annotations:
{{- include "redis-persistent.annotations" . | nindent 8 }}
k8up.syn.tools/backupCommand: /bin/sh -c "/bin/busybox tar -cf - -C {{ .Values.persistentStorage.path }} ."
k8up.syn.tools/fileExtension: .{{ include "redis-persistent.fullname" . }}.tar
lagoon.sh/configMapSha: {{ .Values.configMapSha | quote }}
spec:
{{- with .Values.imagePullSecrets }}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ spec:
{{- include "solr.datadogLabels" . | nindent 8 }}
annotations:
{{- include "solr.annotations" . | nindent 8 }}
k8up.syn.tools/backupcommand: /bin/sh -c "/bin/busybox tar -cf - -C {{ .Values.persistentStorage.path }} ."
k8up.syn.tools/file-extension: .{{ include "solr.fullname" . }}.tar
lagoon.sh/configMapSha: {{ .Values.configMapSha | quote }}
spec:
{{- with .Values.imagePullSecrets }}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ spec:
{{- include "varnish-persistent.datadogLabels" . | nindent 8 }}
annotations:
{{- include "varnish-persistent.annotations" . | nindent 8 }}
k8up.syn.tools/backupCommand: /bin/sh -c "/bin/busybox tar -cf - -C {{ .Values.persistentStorage.path }} ."
k8up.syn.tools/fileExtension: .{{ include "varnish-persistent.fullname" . }}.tar
lagoon.sh/configMapSha: {{ .Values.configMapSha | quote }}
spec:
{{- with .Values.imagePullSecrets }}
Expand Down

This file was deleted.

Loading

0 comments on commit 1de1585

Please sign in to comment.