From a0fdf653fb02d634bb1ca19aa8e66181b2250cab Mon Sep 17 00:00:00 2001 From: Hao Liu Date: Thu, 2 Mar 2023 14:24:38 -0500 Subject: [PATCH] enable web container to be restarted when configmap/secret change --- .../templates/deployments/web.yaml.j2 | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/roles/installer/templates/deployments/web.yaml.j2 b/roles/installer/templates/deployments/web.yaml.j2 index eaa19082..814b2250 100644 --- a/roles/installer/templates/deployments/web.yaml.j2 +++ b/roles/installer/templates/deployments/web.yaml.j2 @@ -25,8 +25,26 @@ spec: app.kubernetes.io/name: '{{ ansible_operator_meta.name }}-web' {{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=8) | trim }} {{ lookup("template", "../common/templates/labels//version.yaml.j2") | indent(width=8) | trim }} -{% if annotations %} annotations: +{% for template in [ + "configmaps/config", + "configmaps/pre_stop_scripts", + "secrets/app_credentials", + "storage/persistent", + ] %} + checksum-{{ template | replace('/', '-') }}: "{{ lookup('template', template + '.yaml.j2') | md5 }}" +{% endfor %} +{% for secret in [ + "bundle_cacert", + "route_tls", + "ldap_cacert", + "secret_key", + "receptor_ca", + "receptor_work_signing", + ] %} + checksum-secret-{{ secret }}: "{{ lookup('ansible.builtin.vars', secret, default='')["resources"][0]["data"] | default('') | md5 }}" +{% endfor %} +{% if annotations %} {{ annotations | indent(width=8) }} {% endif %} spec: @@ -102,13 +120,13 @@ spec: resources: {{ redis_resource_requirements }} - image: '{{ _image }}' name: '{{ ansible_operator_meta.name }}-web' + imagePullPolicy: '{{ image_pull_policy }}' {% if web_command %} command: {{ web_command }} {% endif %} {% if web_args %} args: {{ web_args }} {% endif %} - imagePullPolicy: '{{ image_pull_policy }}' ports: - containerPort: 8052 {% if ingress_type | lower == 'route' and route_tls_termination_mechanism | lower == 'passthrough' %}