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
10 changes: 10 additions & 0 deletions k8s/deployment/delete_cluster_objects
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

DEPLOYMENT_TO_CLEAN="$DEPLOYMENT_ID"

if [ "$DEPLOYMENT" = "blue" ]; then
DEPLOYMENT_TO_CLEAN=$(echo "$CONTEXT" | jq .scope.current_active_deployment -r)
fi

kubectl delete deployment,service,hpa,ingress,pdb,secret,configmap \
-l deployment_id="$DEPLOYMENT_TO_CLEAN" -n "$K8S_NAMESPACE" --cascade=foreground --wait=true
9 changes: 9 additions & 0 deletions k8s/deployment/templates/deployment.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ metadata:
labels:
name: d-{{ .scope.id }}-{{ .deployment.id }}
app.kubernetes.io/part-of: {{ .namespace.slug }}
account: {{ .account.slug }}
account_id: "{{ .account.id }}"
namespace: {{ .namespace.slug }}
namespace_id: "{{ .namespace.id }}"
application: {{ .application.slug }}
application_id: "{{ .application.id }}"
scope: {{ .scope.slug }}
scope_id: "{{ .scope.id }}"
deployment_id: "{{ .deployment.id }}"
spec:
replicas: {{ .replicas }}
selector:
Expand Down
12 changes: 12 additions & 0 deletions k8s/deployment/templates/scaling.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ kind: HorizontalPodAutoscaler
metadata:
name: hpa-d-{{ .scope.id }}-{{ .deployment.id }}
namespace: {{ .k8s_namespace }}
labels:
name: d-{{ .scope.id }}-{{ .deployment.id }}
app.kubernetes.io/part-of: {{ .namespace.slug }}
account: {{ .account.slug }}
account_id: "{{ .account.id }}"
namespace: {{ .namespace.slug }}
namespace_id: "{{ .namespace.id }}"
application: {{ .application.slug }}
application_id: "{{ .application.id }}"
scope: {{ .scope.slug }}
scope_id: "{{ .scope.id }}"
deployment_id: "{{ .deployment.id }}"
spec:
scaleTargetRef:
apiVersion: apps/v1
Expand Down
27 changes: 27 additions & 0 deletions k8s/deployment/templates/service.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ metadata:
app.kubernetes.io/component: application
app.kubernetes.io/instance: {{ .scope.slug }}
app.kubernetes.io/name: {{ .scope.slug }}
account: {{ .account.slug }}
account_id: "{{ .account.id }}"
namespace: {{ .namespace.slug }}
namespace_id: "{{ .namespace.id }}"
application: {{ .application.slug }}
application_id: "{{ .application.id }}"
scope: {{ .scope.slug }}
scope_id: "{{ .scope.id }}"
deployment_id: "{{ .deployment.id }}"
{{- $global := index .k8s_modifiers "global" }}
{{- if $global }}
{{- $labels := index $global "labels" }}
Expand Down Expand Up @@ -83,6 +92,15 @@ metadata:
app.kubernetes.io/component: application
app.kubernetes.io/instance: {{ $.scope.slug }}
app.kubernetes.io/name: {{ $.scope.slug }}
account: {{ $.account.slug }}
account_id: "{{ $.account.id }}"
namespace: {{ $.namespace.slug }}
namespace_id: "{{ $.namespace.id }}"
application: {{ $.application.slug }}
application_id: "{{ $.application.id }}"
scope: {{ $.scope.slug }}
scope_id: "{{ $.scope.id }}"
deployment_id: "{{ $.deployment.id }}"
{{- $global := index .k8s_modifiers "global" }}
{{- if $global }}
{{- $labels := index $global "labels" }}
Expand Down Expand Up @@ -155,6 +173,15 @@ metadata:
app.kubernetes.io/component: application
app.kubernetes.io/instance: {{ $.scope.slug }}
app.kubernetes.io/name: {{ $.scope.slug }}
account: {{ $.account.slug }}
account_id: "{{ $.account.id }}"
namespace: {{ $.namespace.slug }}
namespace_id: "{{ $.namespace.id }}"
application: {{ $.application.slug }}
application_id: "{{ $.application.id }}"
scope: {{ $.scope.slug }}
scope_id: "{{ $.scope.id }}"
deployment_id: "{{ $.deployment.id }}"
annotations:
service.beta.openshift.io/serving-cert-secret-name: d-{{ $.scope.id }}-grpc-{{ .port }}
alb.ingress.kubernetes.io/healthcheck-interval-seconds: '10'
Expand Down
8 changes: 7 additions & 1 deletion k8s/deployment/workflows/delete.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,10 @@ steps:
file: "$SERVICE_PATH/apply_templates"
configuration:
ACTION: delete
DRY_RUN: false
DRY_RUN: false
post:
name: delete_cluster_objects
type: script
file: "$SERVICE_PATH/deployment/delete_cluster_objects"
configuration:
DEPLOYMENT: green
6 changes: 6 additions & 0 deletions k8s/deployment/workflows/finalize.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ steps:
configuration:
ACTION: delete
DRY_RUN: false
post:
name: delete_cluster_objects
type: script
file: "$SERVICE_PATH/deployment/delete_cluster_objects"
configuration:
DEPLOYMENT: blue
6 changes: 6 additions & 0 deletions k8s/deployment/workflows/rollback.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ steps:
configuration:
ACTION: delete
DRY_RUN: false
post:
name: delete_cluster_objects
type: script
file: "$SERVICE_PATH/deployment/delete_cluster_objects"
configuration:
DEPLOYMENT: green