diff --git a/bundle/manifests/pulp-operator.clusterserviceversion.yaml b/bundle/manifests/pulp-operator.clusterserviceversion.yaml index 894ef2366..c942e56a4 100644 --- a/bundle/manifests/pulp-operator.clusterserviceversion.yaml +++ b/bundle/manifests/pulp-operator.clusterserviceversion.yaml @@ -1089,7 +1089,7 @@ spec: - name: RELATED_IMAGE_PULP_REDIS value: redis:latest - name: RELATED_IMAGE_PULP_POSTGRES - value: postgres:13 + value: quay.io/sclorg/postgresql-15-c9s:latest - name: RELATED_IMAGE_PULP_INIT_GPG_CONTAINER value: quay.io/centos/centos:stream9 image: quay.io/pulp/pulp-operator:v0.15.0.dev @@ -1308,6 +1308,6 @@ spec: name: pulp-web - image: redis:latest name: pulp-redis - - image: postgres:13 + - image: quay.io/sclorg/postgresql-15-c9s:latest name: pulp-postgres version: 0.15.0 diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 581952236..9731d16a2 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -61,7 +61,7 @@ spec: - name: RELATED_IMAGE_PULP_REDIS value: redis:latest - name: RELATED_IMAGE_PULP_POSTGRES - value: postgres:13 + value: quay.io/sclorg/postgresql-15-c9s:latest - name: RELATED_IMAGE_PULP_INIT_GPG_CONTAINER value: quay.io/centos/centos:stream9 securityContext: diff --git a/config/manifests/bases/pulp-operator.clusterserviceversion.yaml b/config/manifests/bases/pulp-operator.clusterserviceversion.yaml index 237473f56..188794d4c 100644 --- a/config/manifests/bases/pulp-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/pulp-operator.clusterserviceversion.yaml @@ -943,7 +943,7 @@ spec: - name: RELATED_IMAGE_PULP_REDIS value: redis:latest - name: RELATED_IMAGE_PULP_POSTGRES - value: postgres:13 + value: quay.io/sclorg/postgresql-15-c9s:latest - name: RELATED_IMAGE_PULP_INIT_GPG_CONTAINER value: quay.io/centos/centos:stream9 image: quay.io/pulp/pulp-operator:devel diff --git a/roles/backup/defaults/main.yml b/roles/backup/defaults/main.yml index cfd42f8bb..9b3c4a388 100644 --- a/roles/backup/defaults/main.yml +++ b/roles/backup/defaults/main.yml @@ -12,7 +12,8 @@ backup_storage_requirements: '' # Specify storage class to determine how to dynamically create PVC's with backup_storage_class: '' -postgres_version: 13 +postgres_version: 15 +_postgres_image: quay.io/sclorg/postgresql-15-c9s:latest # Secret Names admin_password_secret: "{{ deployment_name }}-admin-password" diff --git a/roles/backup/vars/main.yml b/roles/backup/vars/main.yml index c1cd8a91d..e4d0a3ddd 100644 --- a/roles/backup/vars/main.yml +++ b/roles/backup/vars/main.yml @@ -1,4 +1,5 @@ --- deployment_type: "pulp" -_postgres_image: postgres:13 +postgres_version: 15 +_postgres_image: quay.io/sclorg/postgresql-15-c9s:latest diff --git a/roles/postgres/defaults/main.yml b/roles/postgres/defaults/main.yml index 723aa591c..f0179a6d2 100644 --- a/roles/postgres/defaults/main.yml +++ b/roles/postgres/defaults/main.yml @@ -1,8 +1,9 @@ --- deployment_type: pulp -postgres_version: 13 -_postgres_image: postgres:13 +postgres_version: 15 +old_postgres_pod: [] +_postgres_image: quay.io/sclorg/postgresql-15-c9s:latest postgres_storage_requirements: requests: diff --git a/roles/postgres/tasks/main.yml b/roles/postgres/tasks/main.yml index ad78e96a8..6c2b26ade 100644 --- a/roles/postgres/tasks/main.yml +++ b/roles/postgres/tasks/main.yml @@ -200,10 +200,10 @@ """ register: _old_pg_version - - name: Upgrade data dir from Postgres 12 to 13 if applicable + - name: Upgrade data dir from old Postgres to {{ postgres_version }} if applicable include_tasks: upgrade_postgres.yml when: - - _old_pg_version.stdout | default('0') | trim == '12' + - (_old_pg_version.stdout | default(0) | int ) < supported_pg_version when: - managed_database - this_pulp['resources'][0]['status']['upgradedPostgresVersion'] | default('none') != '12' diff --git a/roles/postgres/tasks/upgrade_postgres.yml b/roles/postgres/tasks/upgrade_postgres.yml index 2578cc905..fd03b72b0 100644 --- a/roles/postgres/tasks/upgrade_postgres.yml +++ b/roles/postgres/tasks/upgrade_postgres.yml @@ -1,8 +1,9 @@ --- # Upgrade Postgres (Managed Databases only) -# * If postgres version is not 12, and not an external postgres instance (when managed_database is yes), -# then run this playbook with include_tasks from database_configuration.yml +# * If postgres version is not the default/supported postgres_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 # pod via a pg_restore. @@ -42,7 +43,7 @@ status: "False" lastTransitionTime: "{{ lookup('pipe', 'date --iso-8601=seconds') }}" -- name: Create Database configuration with new -postgres-{{ postgres_version }} hostname +- name: Create Database configuration secret with new -postgres-{{ postgres_version }} hostname k8s: apply: true definition: "{{ lookup('template', 'postgres_upgrade.secret.yaml.j2') }}" @@ -123,9 +124,19 @@ set_fact: postgres_pod_name: "{{ postgres_pod['resources'][0]['metadata']['name'] }}" +- name: Get the name of the service for the old postgres pod + k8s_info: + kind: Service + namespace: "{{ ansible_operator_meta.namespace }}" + label_selectors: + - "app.kubernetes.io/component=database" + - "app.kubernetes.io/instance={{ old_postgres_pod.metadata.labels['app.kubernetes.io/instance'] }}" + - "app.kubernetes.io/managed-by=pulp-operator" + register: old_postgres_svc + - name: Set full resolvable host name for old postgres pod set_fact: - resolvable_db_host: "{{ ansible_operator_meta.name }}-postgres-svc.{{ ansible_operator_meta.namespace }}.svc.cluster.local" # yamllint disable-line rule:line-length + resolvable_db_host: "{{ old_postgres_svc['resources'][0]['metadata']['name'] }}.{{ ansible_operator_meta.namespace }}.svc.cluster.local" # yamllint disable-line rule:line-length no_log: "{{ no_log }}" @@ -200,7 +211,7 @@ - name: Set flag signifying that this instance has been migrated set_fact: - upgraded_postgres_version: '13' + upgraded_postgres_version: '{{ postgres_version }}' - k8s_status: api_version: "{{ api_version }}" @@ -220,9 +231,12 @@ kind: StatefulSet api_version: v1 namespace: "{{ ansible_operator_meta.namespace }}" - name: "{{ ansible_operator_meta.name }}-postgres" + name: "{{ item }}" state: absent wait: true + loop: + - "{{ ansible_operator_meta.name }}-postgres" + - "{{ ansible_operator_meta.name }}-postgres-13" - k8s_status: api_version: "{{ api_version }}" @@ -241,8 +255,11 @@ kind: Service api_version: v1 namespace: "{{ ansible_operator_meta.namespace }}" - name: "{{ ansible_operator_meta.name }}-postgres-svc" + name: "{{ item }}" state: absent + loop: + - "{{ ansible_operator_meta.name }}-postgres-svc" + - "{{ ansible_operator_meta.name }}-postgres-13" - k8s_status: api_version: "{{ api_version }}" @@ -261,8 +278,11 @@ kind: PersistentVolumeClaim api_version: v1 namespace: "{{ ansible_operator_meta.namespace }}" - name: "postgres-{{ ansible_operator_meta.name }}-postgres-0" + name: "{{ item }}" state: absent + loop: + - "postgres-{{ ansible_operator_meta.name }}-postgres-0" + - "postgres-{{ ansible_operator_meta.name }}-postgres-13-0" when: - postgres_keep_pvc_after_upgrade is defined - postgres_keep_pvc_after_upgrade | length diff --git a/roles/restore/vars/main.yml b/roles/restore/vars/main.yml index c87e038c9..885176fd7 100644 --- a/roles/restore/vars/main.yml +++ b/roles/restore/vars/main.yml @@ -1,7 +1,7 @@ --- deployment_type: "pulp" -_postgres_image: postgres:13 +_postgres_image: quay.io/sclorg/postgresql-15-c9s:latest custom_resource_key: '_pulp_pulpproject_org_pulprestore'