From 46fca2af5afd709e9d1ddd2f21e8c760563ce3cb Mon Sep 17 00:00:00 2001 From: Marcelo Moreira de Mello Date: Wed, 21 Apr 2021 15:41:18 -0400 Subject: [PATCH] updated --- README.md | 9 ------ .../tasks/check_and_scale_down_deployment.yml | 19 ------------ .../tasks/database_configuration.yml | 30 +------------------ roles/installer/tasks/migrate_data.yml | 19 ++++++++++-- .../tasks/resources_configuration.yml | 25 ---------------- 5 files changed, 18 insertions(+), 84 deletions(-) delete mode 100644 roles/installer/tasks/check_and_scale_down_deployment.yml diff --git a/README.md b/README.md index c3092d51..5f2d675f 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,6 @@ An [Ansible AWX](https://github.com/ansible/awx) operator for Kubernetes built w * [LDAP Certificate Authority](#ldap-certificate-authority) * [Persisting Projects Directory](#persisting-projects-directory) * [Custom Volume and Volume Mount Options](#custom-volume-and-volume-mount-options) - * [Upgrade Notes](#upgrade-notes) - * [From Older Versions](#from-older-versions) * [Exporting Environment Variables to Containers](#exporting-environment-variables-to-containers) * [Development](#development) * [Testing](#testing) @@ -482,13 +480,6 @@ Example spec file for volumes and volume mounts > :warning: **Volume and VolumeMount names cannot contain underscores(_)** -## Upgrade Notes - -### From Older Versions - -For `AWX` instances created by the `awx-operator<0.0.8`, it is required both PostgreSQL `statefulset` and AWX `deployment` resources to be deleted and recreated. This is required due to new labels added on both resources and the requirement of the Kubernetes API which enforces `selector.matchLabels` attributes to be `ready-only`. - -The `awx-operator` will handle the upgrading both resources. Note that just the `statefulset` and `deployment` will be recreated. Therefore, any `persistent volume` used on any of these 2 resources, **shall not be deleted**. #### Exporting Environment Variables to Containers If you need to export custom environment variables to your containers. diff --git a/roles/installer/tasks/check_and_scale_down_deployment.yml b/roles/installer/tasks/check_and_scale_down_deployment.yml deleted file mode 100644 index cab7af23..00000000 --- a/roles/installer/tasks/check_and_scale_down_deployment.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- - -- name: Check for presence of Deployment - k8s_info: - api_version: v1 - kind: Deployment - name: "{{ meta.name }}" - namespace: "{{ meta.namespace }}" - register: tower_deployment - -- name: Scale down Deployment for migration - k8s_scale: - api_version: v1 - kind: Deployment - name: "{{ meta.name }}" - namespace: "{{ meta.namespace }}" - replicas: 0 - wait: yes - when: tower_deployment['resources'] | length diff --git a/roles/installer/tasks/database_configuration.yml b/roles/installer/tasks/database_configuration.yml index 7065cfe4..a79f55c4 100644 --- a/roles/installer/tasks/database_configuration.yml +++ b/roles/installer/tasks/database_configuration.yml @@ -64,40 +64,12 @@ set_fact: pg_config: '{{ _generated_pg_config_resources["resources"] | default([]) | length | ternary(_generated_pg_config_resources, _pg_config) }}' -- name: Check if PostgreSQL statefuset is present - k8s_info: - api_version: v1 - kind: StatefulSet - namespace: '{{ meta.namespace }}' - name: '{{ meta.name }}-postgres' - register: _postgres_statefulset_result - -- name: Determine if PostgreSQL statefulset must be recreated - set_fact: - # yamllint disable-line rule:line-length - recreate_statefulset: '{{ _postgres_statefulset_result["resources"][0]["metadata"]["labels"]["app.kubernetes.io/managed-by"] | default("") | ternary("False", "True") }}' # noqa 204 - when: _postgres_statefulset_result['resources'] | length - -- block: - - name: Check and scale down deployment - include_tasks: check_and_scale_down_deployment.yml - - - name: Delete PostgreSQL statefulset to ensure expected labels - k8s: - state: absent - api_version: v1 - kind: StatefulSet - namespace: '{{ meta.namespace }}' - name: '{{ meta.name }}-postgres' - wait: yes - when: recreate_statefulset is defined and recreate_statefulset|bool - - name: Create Database if no database is specified k8s: apply: true definition: "{{ lookup('template', 'tower_postgres.yaml.j2') }}" when: - - pg_config['resources'][0]['data']['type'] | default('') | b64decode == 'managed' or recreate_statefulset|bool + - pg_config['resources'][0]['data']['type'] | default('') | b64decode == 'managed' - name: Store Database Configuration set_fact: diff --git a/roles/installer/tasks/migrate_data.yml b/roles/installer/tasks/migrate_data.yml index 966c8d14..63ec4c75 100644 --- a/roles/installer/tasks/migrate_data.yml +++ b/roles/installer/tasks/migrate_data.yml @@ -24,8 +24,23 @@ set_fact: postgres_pod_name: "{{ postgres_pod['resources'][0]['metadata']['name'] }}" -- name: Check and scale down deployment - include_tasks: check_and_scale_down_deployment.yml +- name: Check for presence of Deployment + k8s_info: + api_version: v1 + kind: Deployment + name: "{{ meta.name }}" + namespace: "{{ meta.namespace }}" + register: tower_deployment + +- name: Scale down Deployment for migration + k8s_scale: + api_version: v1 + kind: Deployment + name: "{{ meta.name }}" + namespace: "{{ meta.namespace }}" + replicas: 0 + wait: yes + when: tower_deployment['resources'] | length - name: Set pg_dump command set_fact: diff --git a/roles/installer/tasks/resources_configuration.yml b/roles/installer/tasks/resources_configuration.yml index 5e5412ea..703191bc 100644 --- a/roles/installer/tasks/resources_configuration.yml +++ b/roles/installer/tasks/resources_configuration.yml @@ -1,19 +1,5 @@ --- -- name: Check if deployment is present - k8s_info: - api_version: v1 - kind: Deployment - namespace: '{{ meta.namespace }}' - name: '{{ meta.name }}' - register: _deployment_result - -- name: Determine if deployment must be recreated - set_fact: - # yamllint disable-line rule:line-length - recreate_deployment: '{{ _deployment_result["resources"][0]["metadata"]["labels"]["app.kubernetes.io/managed-by"] | default("") | ternary("False", "True") }}' # noqa 204 - when: _deployment_result['resources'] | length - - name: Get the current resource pod information. k8s_info: api_version: v1 @@ -26,22 +12,11 @@ field_selectors: - status.phase=Running register: tower_pods - changed_when: tower_pods["resources"] | length - name: Set the resource pod name as a variable. set_fact: tower_pod_name: "{{ tower_pods['resources'][0]['metadata']['name'] | default('') }}" -- name: Delete deployment to ensure expected labels - k8s: - state: absent - api_version: v1 - kind: Deployment - namespace: '{{ meta.namespace }}' - name: '{{ meta.name }}' - wait: yes - when: recreate_deployment is defined and recreate_deployment|bool - - name: Apply Resources k8s: apply: yes