From d6f91e51d2ed7775b8fe02518fc07b12689b7504 Mon Sep 17 00:00:00 2001 From: Benjamin Chastanier Date: Thu, 21 Apr 2022 17:55:12 +0200 Subject: [PATCH] feat: add sidecar container to log app start / stop events Ticket: ENG-1160 --- .../templates/deployment.j2.yaml | 25 ++++++++++++++++ .../templates/deployment.j2.yaml | 25 ++++++++++++++++ .../templates/deployment.j2.yaml | 29 +++++++++++++++++-- 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/lib/aws/charts/q-application/templates/deployment.j2.yaml b/lib/aws/charts/q-application/templates/deployment.j2.yaml index b942e99f..769d6c5c 100644 --- a/lib/aws/charts/q-application/templates/deployment.j2.yaml +++ b/lib/aws/charts/q-application/templates/deployment.j2.yaml @@ -90,4 +90,29 @@ spec: requests: cpu: {{ total_cpus }} memory: {{ total_ram_in_mib }}Mi + + - name: {{ sanitized_name }}-sidecar + image: busybox + command: ["/bin/sh", "-c", "while true; do sleep 5; done"] + {%- if private_port %} + livenessProbe: + tcpSocket: + port: {{ private_port }} + initialDelaySeconds: {{ start_timeout_in_seconds }} + failureThreshold: 1 + periodSeconds: 5 + {%- endif %} + lifecycle: + postStart: + exec: + command: + - sh + - -c + - echo "-- APPLICATION STARTED --" >/proc/1/fd/1 + preStop: + exec: + command: + - sh + - -c + - echo "-- APPLICATION SHUTDOWN --" >/proc/1/fd/1 {%- endif %} diff --git a/lib/digitalocean/charts/q-application/templates/deployment.j2.yaml b/lib/digitalocean/charts/q-application/templates/deployment.j2.yaml index b942e99f..769d6c5c 100644 --- a/lib/digitalocean/charts/q-application/templates/deployment.j2.yaml +++ b/lib/digitalocean/charts/q-application/templates/deployment.j2.yaml @@ -90,4 +90,29 @@ spec: requests: cpu: {{ total_cpus }} memory: {{ total_ram_in_mib }}Mi + + - name: {{ sanitized_name }}-sidecar + image: busybox + command: ["/bin/sh", "-c", "while true; do sleep 5; done"] + {%- if private_port %} + livenessProbe: + tcpSocket: + port: {{ private_port }} + initialDelaySeconds: {{ start_timeout_in_seconds }} + failureThreshold: 1 + periodSeconds: 5 + {%- endif %} + lifecycle: + postStart: + exec: + command: + - sh + - -c + - echo "-- APPLICATION STARTED --" >/proc/1/fd/1 + preStop: + exec: + command: + - sh + - -c + - echo "-- APPLICATION SHUTDOWN --" >/proc/1/fd/1 {%- endif %} diff --git a/lib/scaleway/charts/q-application/templates/deployment.j2.yaml b/lib/scaleway/charts/q-application/templates/deployment.j2.yaml index 9d407b87..1d684d41 100644 --- a/lib/scaleway/charts/q-application/templates/deployment.j2.yaml +++ b/lib/scaleway/charts/q-application/templates/deployment.j2.yaml @@ -64,7 +64,7 @@ spec: name: {{ sanitized_name }} key: {{ ev.key }} {%- endfor %} - {%- if private_port %} + {%- if private_port %} ports: {%- for port in ports %} - containerPort: {{ port.port }} @@ -81,7 +81,7 @@ spec: port: {{ private_port }} initialDelaySeconds: {{ start_timeout_in_seconds }} periodSeconds: 20 - {%- endif %} + {%- endif %} resources: limits: cpu: {{ cpu_burst }} @@ -89,4 +89,29 @@ spec: requests: cpu: {{ total_cpus }} memory: {{ total_ram_in_mib }}Mi + + - name: {{ sanitized_name }}-sidecar + image: busybox + command: ["/bin/sh", "-c", "while true; do sleep 5; done"] + {%- if private_port %} + livenessProbe: + tcpSocket: + port: {{ private_port }} + initialDelaySeconds: {{ start_timeout_in_seconds }} + failureThreshold: 1 + periodSeconds: 5 + {%- endif %} + lifecycle: + postStart: + exec: + command: + - sh + - -c + - echo "-- APPLICATION STARTED --" >/proc/1/fd/1 + preStop: + exec: + command: + - sh + - -c + - echo "-- APPLICATION SHUTDOWN --" >/proc/1/fd/1 {%- endif %}