Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions k8s/deployment/build_deployment
Original file line number Diff line number Diff line change
@@ -1,33 +1,5 @@
#!/bin/bash

echo "TEMPLATE DIR: $OUTPUT_DIR, ACTION: $ACTION, DRY_RUN: $DRY_RUN"

APPLIED_FILES=()

# Find all .yaml files that were not yet applied / deleted
while IFS= read -r TEMPLATE_FILE; do
echo "kubectl $ACTION $TEMPLATE_FILE"

if [[ "$DRY_RUN" == "false" ]]; then
kubectl "$ACTION" -f "$TEMPLATE_FILE"
fi

BASE_DIR="$(dirname "$TEMPLATE_FILE")"
FILENAME="$(basename "$TEMPLATE_FILE")"
DEST_DIR="${BASE_DIR}/$ACTION"

mkdir -p "$DEST_DIR"

mv "$TEMPLATE_FILE" "$DEST_DIR/$FILENAME"

# Add the moved file path to our array
APPLIED_FILES+=("$DEST_DIR/$FILENAME")
done < <(find "$OUTPUT_DIR" \( -path "*/apply" -o -path "*/delete" \) -prune -o -type f -name "*.yaml" -print)

if [[ "$DRY_RUN" == "true" ]]; then
exit 1
fi

IAM=${IAM-"{}"}

IAM_ENABLED=$(echo "$IAM" | jq -r .ENABLED)
Expand Down
29 changes: 28 additions & 1 deletion k8s/deployment/templates/deployment.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ spec:
{{ end }}
{{ end }}
{{ end }}

- name: application
envFrom:
- secretRef:
Expand Down Expand Up @@ -281,6 +280,34 @@ spec:
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
volumeMounts:
{{- if .parameters.results }}
{{- range .parameters.results }}
{{- if and (eq .type "file") }}
{{- if gt (len .values) 0 }}
- name: {{ printf "file-%s" (filepath.Base .destination_path | strings.ReplaceAll "." "-") }}
mountPath: {{ .destination_path }}
subPath: {{ filepath.Base .destination_path }}
readOnly: true
{{- end }}
{{- end }}
{{- end }}
{{- end }}
volumes:
{{- if .parameters.results }}
{{- range .parameters.results }}
{{- if and (eq .type "file") }}
{{- if gt (len .values) 0 }}
- name: {{ printf "file-%s" (filepath.Base .destination_path | strings.ReplaceAll "." "-") }}
secret:
secretName: s-{{ $.scope.id }}-d-{{ $.deployment.id }}
items:
- key: {{ printf "app-data-%s" (filepath.Base .destination_path) }}
path: {{ filepath.Base .destination_path }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
Expand Down
2 changes: 1 addition & 1 deletion k8s/deployment/templates/secret.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ data:
{{- end }}
{{- if and (eq .type "file") }}
{{- if gt (len .values) 0 }}
{{ printf "app-data-%s" (filepath.Base .destination_path) }}: {{ index .values 0 "value" | strings.TrimPrefix "data:application/json;base64," }}
{{ printf "app-data-%s" (filepath.Base .destination_path) }}: {{ index .values 0 "value" | regexp.Replace "^data:[^;]+;base64," "" }}
{{- end }}
{{- end }}
{{- end }}
Expand Down
12 changes: 3 additions & 9 deletions scheduled_task/deployment/workflows/blue_green.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,9 @@ steps:
file: "$OUTPUT_DIR/secret-$SCOPE_ID-$DEPLOYMENT_ID.yaml"
- name: update blue deployment
type: script
file: "$OVERRIDES_PATH/deployment/build_blue_deployment"
action: replace
output:
- name: DEPLOYMENT_PATH
type: file
file: "$OUTPUT_DIR/deployment-$SCOPE_ID-$BLUE_DEPLOYMENT_ID.yaml"
- name: SECRET_PATH
type: file
file: "$OUTPUT_DIR/secret-$SCOPE_ID-$BLUE_DEPLOYMENT_ID.yaml"
post:
name: wait deployment active
action: skip
- name: apply
type: script
file: "$SERVICE_PATH/apply_templates"
Expand Down
8 changes: 0 additions & 8 deletions scheduled_task/deployment/workflows/finalize.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
steps:
- name: build green deployment
type: script
action: replace
file: "$OVERRIDES_PATH/deployment/build_deployment"
output:
- name: DEPLOYMENT_PATH
type: file
file: "$OUTPUT_DIR/deployment-$SCOPE_ID-$DEPLOYMENT_ID.yaml"
- name: create green deployment
post:
name: wait deployment active
action: skip
Expand Down
15 changes: 0 additions & 15 deletions scheduled_task/deployment/workflows/rollback.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
steps:
- name: update blue deployment
type: script
action: replace
file: "$OVERRIDES_PATH/deployment/build_blue_deployment"
output:
- name: DEPLOYMENT_PATH
type: file
file: "$OUTPUT_DIR/deployment-$SCOPE_ID-$DEPLOYMENT_ID.yaml"
- name: SECRET_PATH
type: file
file: "$OUTPUT_DIR/secret-$SCOPE_ID-$DEPLOYMENT_ID.yaml"
- name: create blue deployment
post:
name: wait deployment active
action: skip
- name: build deployment
type: script
action: replace
Expand Down