From 0cb3f04c413288395f3308af71e49b05e12b27f3 Mon Sep 17 00:00:00 2001 From: Nicolas Marcq Date: Thu, 7 Dec 2023 12:04:44 +0100 Subject: [PATCH] fix maintenance static --- k8s/squest_k8s/tasks/02-db.yml | 1 - k8s/squest_k8s/tasks/05-django.yml | 21 ++++++++++++++++----- k8s/squest_k8s/tasks/07-maintenance.yml | 13 +++++++------ k8s/update.yml | 8 ++++---- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/k8s/squest_k8s/tasks/02-db.yml b/k8s/squest_k8s/tasks/02-db.yml index 75a9afe85..6804af0bf 100644 --- a/k8s/squest_k8s/tasks/02-db.yml +++ b/k8s/squest_k8s/tasks/02-db.yml @@ -2,7 +2,6 @@ kubernetes.core.k8s: kubeconfig: "{{ k8s_kubeconfig_path }}" state: present -# namespace: "{{ squest_namespace }}" namespace: "default" # mandatory as they have hardcoded hooks in default NS definition: "{{ lookup('file', 'mariadb-operator.v0.22.0.yml') | from_yaml_all }}" diff --git a/k8s/squest_k8s/tasks/05-django.yml b/k8s/squest_k8s/tasks/05-django.yml index e1adbe3f9..9c96e153a 100644 --- a/k8s/squest_k8s/tasks/05-django.yml +++ b/k8s/squest_k8s/tasks/05-django.yml @@ -136,14 +136,10 @@ volumeMounts: - mountPath: /app/static name: django-static - - mountPath: /app/media - name: django-media restartPolicy: Never volumes: - - name: django-media - persistentVolumeClaim: - claimName: django-media - name: django-static + readOnly: true persistentVolumeClaim: claimName: django-static @@ -261,6 +257,7 @@ persistentVolumeClaim: claimName: django-media - name: django-static + readOnly: true persistentVolumeClaim: claimName: django-static - name: nginx-config @@ -319,3 +316,17 @@ name: django port: number: 8080 + +- name: Wait until Django deployment available + kubernetes.core.k8s_info: + kubeconfig: "{{ k8s_kubeconfig_path }}" + api_version: "apps/v1" + kind: Deployment + name: "django" + namespace: "{{ squest_namespace }}" + wait: yes + wait_sleep: 10 + wait_timeout: 600 + wait_condition: + type: Available + status: "True" diff --git a/k8s/squest_k8s/tasks/07-maintenance.yml b/k8s/squest_k8s/tasks/07-maintenance.yml index 6ff92972c..51c4aafc1 100644 --- a/k8s/squest_k8s/tasks/07-maintenance.yml +++ b/k8s/squest_k8s/tasks/07-maintenance.yml @@ -15,6 +15,8 @@ data: nginx.conf: "{{ lookup('file', playbook_dir + '/../docker/maintenance.nginx.conf') }}" maintenance.html: "{{ lookup('file', playbook_dir + '/../docker/maintenance.html') }}" + binaryData: + squest_logo_v2_300_300.png: "{{ lookup('file', playbook_dir + '/../project-static/squest/img/squest_logo_v2_300_300.png') |b64encode }}" - name: Deploy maintenance static page kubernetes.core.k8s: @@ -56,14 +58,11 @@ - name: nginx-config-maintenance mountPath: /usr/share/nginx/html/index.html subPath: maintenance.html - - mountPath: /usr/share/nginx/html/squest_logo_v2_300_300.png - name: django-static - subPath: ./squest/img/squest_logo_v2_300_300.png + - name: nginx-config-maintenance + mountPath: /usr/share/nginx/html/squest_logo_v2_300_300.png + subPath: squest_logo_v2_300_300.png restartPolicy: Always volumes: - - name: django-static - persistentVolumeClaim: - claimName: django-static - name: nginx-config-maintenance configMap: name: nginx-config-maintenance @@ -72,6 +71,8 @@ path: nginx.conf - key: maintenance.html path: maintenance.html + - key: squest_logo_v2_300_300.png + path: squest_logo_v2_300_300.png - name: Maintenance service kubernetes.core.k8s: diff --git a/k8s/update.yml b/k8s/update.yml index d79c7242c..737a4f164 100644 --- a/k8s/update.yml +++ b/k8s/update.yml @@ -19,7 +19,7 @@ nginx.ingress.kubernetes.io/backend-protocol: "HTTP" spec: rules: - - host: "{{ squest_host_url }}" + - host: "{{ squest_django.ingress.host }}" http: paths: - pathType: Prefix @@ -30,7 +30,7 @@ port: number: 80 - - name: Update Django env as config map + - name: Update Django env config map kubernetes.core.k8s: kubeconfig: "{{ k8s_kubeconfig_path }}" namespace: "{{ squest_namespace }}" @@ -43,7 +43,7 @@ app: squest service: django name: django-env - data: "{{ squest_django_env }}" + data: "{{ squest_django.env }}" - name: Delete migration job kubernetes.core.k8s: @@ -168,7 +168,7 @@ nginx.ingress.kubernetes.io/backend-protocol: "HTTP" spec: rules: - - host: "{{ squest_host_url }}" + - host: "{{ squest_django.ingress.host }}" http: paths: - pathType: Prefix