Skip to content

Commit

Permalink
Upgrading to postgres:15
Browse files Browse the repository at this point in the history
  • Loading branch information
john-westcott-iv committed Jul 12, 2023
1 parent 822b3a4 commit 0747103
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ spec:

#### Postgres Version

The default Postgres version for the version of AWX bundled with the latest version of the awx-operator is Postgres 13. You can find this default for a given version by at the default value for [_postgres_image_version](./roles/installer/defaults/main.yml#L138).
The default Postgres version for the version of AWX bundled with the latest version of the awx-operator is Postgres 15. You can find this default for a given version by at the default value for [_postgres_image_version](./roles/installer/defaults/main.yml#L138).

We only have coverage for the default version of Postgres. Newer versions of Postgres (14+) will likely work, but should only be configured as an external database. If your database is managed by the awx-operator (default if you don't specify a `postgres_configuration_secret`), then you should not override the default version as this may cause issues when awx-operator tries to upgrade your postgresql pod.

Expand Down Expand Up @@ -575,7 +575,7 @@ The following variables are customizable for the managed PostgreSQL service

| Name | Description | Default |
| --------------------------------------------- | --------------------------------------------- | ---------------------------------- |
| postgres_image | Path of the image to pull | postgres:12 |
| postgres_image | Path of the image to pull | postgres:15 |
| postgres_init_container_resource_requirements | Database init container resource requirements | requests: {cpu: 10m, memory: 64Mi} |
| postgres_resource_requirements | PostgreSQL container resource requirements | requests: {cpu: 10m, memory: 64Mi} |
| postgres_storage_requirements | PostgreSQL container storage requirements | requests: {storage: 8Gi} |
Expand Down Expand Up @@ -780,7 +780,7 @@ example, specifying `task_tolerations` will allow the AWX task pod to be schedul
| Name | Description | Default |
| -------------------------------- | ---------------------------------------- | ------- |
| postgres_image | Path of the image to pull | postgres |
| postgres_image_version | Image version to pull | 13 |
| postgres_image_version | Image version to pull | 15 |
| node_selector | AWX pods' nodeSelector | '' |
| web_node_selector | AWX web pods' nodeSelector | '' |
| task_node_selector | AWX task pods' nodeSelector | '' |
Expand Down Expand Up @@ -1412,7 +1412,7 @@ The first part of any upgrade should be a backup. Note, there are secrets in the

In the event you need to recover the backup see the [restore role documentation](https://github.com/ansible/awx-operator/tree/devel/roles/restore). *Before Restoring from a backup*, be sure to:
* delete the old existing AWX CR
* delete the persistent volume claim (PVC) for the database from the old deployment, which has a name like `postgres-13-<deployment-name>-postgres-13-0`
* delete the persistent volume claim (PVC) for the database from the old deployment, which has a name like `postgres-15-<deployment-name>-postgres-15-0`

**Note**: Do not delete the namespace/project, as that will delete the backup and the backup's PVC as well.

Expand Down
4 changes: 2 additions & 2 deletions roles/backup/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
deployment_type: "awx"
_postgres_image: postgres
_postgres_image_version: 13
_postgres_image_version: 15
backup_complete: false
database_type: "unmanaged"
supported_pg_version: 13
supported_pg_version: 15
image_pull_policy: IfNotPresent
2 changes: 1 addition & 1 deletion roles/installer/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ _image_version: "{{ lookup('env', 'DEFAULT_AWX_VERSION') or 'latest' }}"
_redis_image: docker.io/redis
_redis_image_version: 7
_postgres_image: postgres
_postgres_image_version: 13
_postgres_image_version: 15
image_pull_policy: IfNotPresent
image_pull_secrets: []

Expand Down
12 changes: 6 additions & 6 deletions roles/installer/tasks/database_configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
namespace: "{{ ansible_operator_meta.namespace }}"
register: this_awx

- name: Check if postgres pod is running and version 12
- name: Check if postgres pod is running an older version
block:
- name: Set path to PG_VERSION file for given container image
set_fact:
Expand All @@ -139,13 +139,13 @@
"""
register: _old_pg_version

- name: Upgrade data dir from Postgres 12 to 13 if applicable
- name: Upgrade data dir from old Postgres to {{ supported_pg_version }} if applicable
include_tasks: upgrade_postgres.yml
when:
- _old_pg_version.stdout | default('0') | trim == '12'
- _old_pg_version.stdout | default('0') | trim < supported_pg_version
when:
- managed_database
- this_awx['resources'][0]['status']['upgradedPostgresVersion'] | default('none') != '12'
- this_awx['resources'][0]['status']['upgradedPostgresVersion'] | default('none') < supported_pg_version
- old_postgres_pod['resources'] | length # upgrade is complete and old pg pod has been removed

- block:
Expand All @@ -167,7 +167,7 @@
kubernetes.core.k8s_scale:
api_version: apps/v1
kind: StatefulSet
name: "{{ ansible_operator_meta.name }}-postgres-13"
name: "{{ ansible_operator_meta.name }}-postgres-15"
namespace: "{{ ansible_operator_meta.namespace }}"
replicas: 0
wait: yes
Expand All @@ -177,7 +177,7 @@
state: absent
api_version: apps/v1
kind: StatefulSet
name: "{{ ansible_operator_meta.name }}-postgres-13"
name: "{{ ansible_operator_meta.name }}-postgres-15"
namespace: "{{ ansible_operator_meta.namespace }}"
wait: yes
when: create_statefulset_result.error == 422
Expand Down
6 changes: 3 additions & 3 deletions roles/installer/tasks/upgrade_postgres.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---

# Upgrade Posgres (Managed Databases only)
# * If postgres version is not 12, and not an external postgres instance (when managed_database is yes),
# * If postgres version is not supported_pg_version, and not an external postgres instance (when managed_database is yes),
# then run this playbook with include_tasks from database_configuration.yml
# * Data will be streamed via a pg_dump from the postgres 12 pod to the postgres 13
# * Data will be streamed via a pg_dump from the postgres 12/13 pod to the postgres supported_pg_version
# pod via a pg_restore.


Expand Down Expand Up @@ -102,7 +102,7 @@

- name: Set flag signifying that this instance has been migrated
set_fact:
upgraded_postgres_version: '13'
upgraded_postgres_version: '{{ supported_pg_version }}'

# Cleanup old Postgres resources
- name: Remove old Postgres StatefulSet
Expand Down
2 changes: 1 addition & 1 deletion roles/installer/templates/statefulsets/postgres.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ spec:
args: {{ postgres_extra_args }}
{% endif %}
env:
# For postgres_image based on rhel8/postgresql-13
# For postgres_image based on rhel8/postgresql-{{ supported_pg_version }}
- name: POSTGRESQL_DATABASE
valueFrom:
secretKeyRef:
Expand Down
2 changes: 1 addition & 1 deletion roles/installer/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ postgres_host_auth_method: 'scram-sha-256'
ldap_cacert_ca_crt: ''
bundle_ca_crt: ''
projects_existing_claim: ''
supported_pg_version: 13
supported_pg_version: 15
2 changes: 1 addition & 1 deletion roles/restore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This role assumes you are authenticated with an Openshift or Kubernetes cluster:

*Before Restoring from a backup*, be sure to:
- delete the old existing AWX CR
- delete the persistent volume claim (PVC) for the database from the old deployment, which has a name like `postgres-13-<deployment-name>-postgres-13-0`
- delete the persistent volume claim (PVC) for the database from the old deployment, which has a name like `postgres-15-<deployment-name>-postgres-15-0`

**Note**: Do not delete the namespace/project, as that will delete the backup and the backup's PVC as well.

Expand Down
4 changes: 2 additions & 2 deletions roles/restore/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

deployment_type: "awx"
_postgres_image: postgres
_postgres_image_version: 13
_postgres_image_version: 15

backup_api_version: '{{ deployment_type }}.ansible.com/v1beta1'
backup_kind: 'AWXBackup'
Expand All @@ -12,5 +12,5 @@ secret_key_secret: '{{ deployment_name }}-secret-key'
admin_password_secret: '{{ deployment_name }}-admin-password'
broadcast_websocket_secret: '{{ deployment_name }}-broadcast-websocket'
postgres_configuration_secret: '{{ deployment_name }}-postgres-configuration'
supported_pg_version: 13
supported_pg_version: 15
image_pull_policy: IfNotPresent

0 comments on commit 0747103

Please sign in to comment.