create postgresql deployment
This commit is contained in:
65
ansible-5/roles/prod.k3s/tasks/deployments/postgresql.yaml
Normal file
65
ansible-5/roles/prod.k3s/tasks/deployments/postgresql.yaml
Normal file
@@ -0,0 +1,65 @@
|
||||
---
|
||||
#https://github.com/bitnami/charts/tree/main/bitnami/postgresql
|
||||
|
||||
|
||||
|
||||
- name: Create a namespace for postgres
|
||||
k8s:
|
||||
kubeconfig: "/etc/rancher/k3s/k3s.yaml"
|
||||
name: "{{apps.postgres.namespace}}"
|
||||
api_version: v1
|
||||
kind: Namespace
|
||||
state: "{{apps.postgres.state}}"
|
||||
become: true
|
||||
|
||||
- name: create persistent volume resources
|
||||
kubernetes.core.k8s:
|
||||
kubeconfig: "/etc/rancher/k3s/k3s.yaml"
|
||||
state: "{{apps.postgres.state}}"
|
||||
definition: "{{ lookup('template', item) | from_yaml }}"
|
||||
loop:
|
||||
- postgres/pv.yaml
|
||||
- postgres/pv-claim.yaml
|
||||
become: true
|
||||
|
||||
- name: create secret for postgres
|
||||
kubernetes.core.k8s:
|
||||
kubeconfig: "/etc/rancher/k3s/k3s.yaml"
|
||||
state: "{{apps.postgres.state}}"
|
||||
definition:
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
type: Opaque
|
||||
metadata:
|
||||
name: postgres-secrets
|
||||
namespace: "{{apps.postgres.namespace}}"
|
||||
stringData:
|
||||
password: "{{apps.postgres.secrets.password}}"
|
||||
postgres-password: "{{apps.postgres.secrets.postgres_password}}"
|
||||
replication-password: "{{apps.postgres.secrets.replication_password}}"
|
||||
become: true
|
||||
|
||||
- name: Install postgres globally available
|
||||
block:
|
||||
- name: Add postgres chart helm repo
|
||||
local_action:
|
||||
module: kubernetes.core.helm_repository
|
||||
name: bitnami
|
||||
repo_url: https://charts.bitnami.com/bitnami
|
||||
|
||||
- name: load variables files/postgres/values.yaml
|
||||
ansible.builtin.include_vars:
|
||||
file: files/postgres/values.yaml
|
||||
name: stash_values
|
||||
|
||||
- name: Install postgres Release
|
||||
local_action:
|
||||
module: kubernetes.core.helm
|
||||
release_state: "{{apps.postgres.state}}"
|
||||
name: postgresql
|
||||
namespace: "{{apps.postgres.namespace}}"
|
||||
create_namespace: yes
|
||||
update_repo_cache: True
|
||||
chart_ref: bitnami/postgresql
|
||||
values: "{{stash_values}}"
|
||||
wait: true
|
||||
Reference in New Issue
Block a user