mirror of
https://github.com/ansible/awx-operator.git
synced 2026-05-08 06:12:54 +00:00
Add postgres_extra_settings (#2071)
* Add hacking/ directory to .gitignore as it is commonly used for dev scripts * Add postgres_extra_settings * Add postgres_configuration_secret checksum to DB statefulset * Docs for postgres_extra_settings, CI coverage, and examples --------- Co-authored-by: Christian M. Adams <chadams@redhat.com>
This commit is contained in:
@@ -422,8 +422,11 @@ projects_persistence: false
|
||||
# Define an existing PersistentVolumeClaim to use
|
||||
projects_existing_claim: ''
|
||||
#
|
||||
# Define postgres configuration arguments to use
|
||||
# Define postgres configuration arguments to use (Deprecated)
|
||||
postgres_extra_args: ''
|
||||
#
|
||||
# Define postgresql.conf configurations
|
||||
postgres_extra_settings: []
|
||||
|
||||
postgres_data_volume_init: false
|
||||
postgres_init_container_commands: |
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
- name: Get database configuration
|
||||
include_tasks: database_configuration.yml
|
||||
|
||||
- name: Create postgresql.conf ConfigMap
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'configmaps/postgres_extra_settings.yaml.j2') }}"
|
||||
when: postgres_extra_settings | length
|
||||
|
||||
# It is possible that N-2 postgres pods may still be present in the namespace from previous upgrades.
|
||||
# So we have to take that into account and preferentially set the most recent one.
|
||||
- name: Get the old postgres pod (N-1)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: '{{ ansible_operator_meta.name }}-postgres-extra-settings'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
labels:
|
||||
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }}
|
||||
data:
|
||||
99-overrides.conf: |
|
||||
{% for pg_setting in postgres_extra_settings %}
|
||||
{% if pg_setting.value is string %}
|
||||
{{ pg_setting.setting }} = '{{ pg_setting.value }}'
|
||||
{% else %}
|
||||
{{ pg_setting.setting }} = {{ pg_setting.value }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
@@ -34,6 +34,11 @@ spec:
|
||||
app.kubernetes.io/component: 'database'
|
||||
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
||||
annotations:
|
||||
{% if postgres_extra_settings | length > 0 %}
|
||||
checksum-postgres_extra_settings: "{{ lookup('template', 'configmaps/postgres_extra_settings.yaml.j2') | sha1 }}"
|
||||
{% endif %}
|
||||
checksum-secret-postgres_configuration_secret: "{{ lookup('ansible.builtin.vars', 'pg_config', default='')["resources"][0]["data"] | default('') | sha1 }}"
|
||||
{% if postgres_annotations %}
|
||||
{{ postgres_annotations | indent(width=8) }}
|
||||
{% endif %}
|
||||
@@ -137,6 +142,11 @@ spec:
|
||||
- name: postgres-{{ supported_pg_version }}
|
||||
mountPath: '{{ _postgres_data_path | dirname }}'
|
||||
subPath: '{{ _postgres_data_path | dirname | basename }}'
|
||||
{% if postgres_extra_settings | length > 0 %}
|
||||
- name: pg-overrides
|
||||
mountPath: /opt/app-root/src/postgresql-cfg
|
||||
readOnly: true
|
||||
{% endif %}
|
||||
{% if postgres_extra_volume_mounts %}
|
||||
{{ postgres_extra_volume_mounts | indent(width=12, first=True) }}
|
||||
{% endif %}
|
||||
@@ -149,9 +159,19 @@ spec:
|
||||
tolerations:
|
||||
{{ postgres_tolerations | indent(width=8) }}
|
||||
{% endif %}
|
||||
{% if postgres_extra_volumes %}
|
||||
{% if (postgres_extra_volumes | length + postgres_extra_settings | length) > 0 %}
|
||||
volumes:
|
||||
{% if postgres_extra_volumes %}
|
||||
{{ postgres_extra_volumes | indent(width=8, first=False) }}
|
||||
{% endif %}
|
||||
{% if postgres_extra_settings | length > 0 %}
|
||||
- name: pg-overrides
|
||||
configMap:
|
||||
name: '{{ ansible_operator_meta.name }}-postgres-extra-settings'
|
||||
items:
|
||||
- key: 99-overrides.conf
|
||||
path: 99-overrides.conf
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
|
||||
Reference in New Issue
Block a user