create postgresql deployment
This commit is contained in:
@@ -59,6 +59,16 @@ apps:
|
||||
root_password: q4890qhhfgq9pfg3q4uyg33
|
||||
replication_password: 4q389hq7gf8qo47gq8374g
|
||||
|
||||
postgres:
|
||||
enabled: true
|
||||
namespace: postgres
|
||||
pvc: data-postgres-0
|
||||
state: present
|
||||
secrets:
|
||||
password: faj48290q2u58vy8qphqtqj
|
||||
postgres_password: q4890qhhfgq9pfg3q4uyg33
|
||||
replication_password: 4q389hq7gf8qo47gq8374g
|
||||
|
||||
gitea:
|
||||
enabled: false
|
||||
namespace: gitea
|
||||
|
||||
11
ansible-5/roles/prod.k3s/files/postgres/values.yaml
Normal file
11
ansible-5/roles/prod.k3s/files/postgres/values.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
# values for PostgreSQL
|
||||
|
||||
image:
|
||||
repository: bitnami/postgresql
|
||||
tag: 15.1.0-debian-11-r12
|
||||
|
||||
auth:
|
||||
database: test
|
||||
username: "test"
|
||||
existingSecret: postgres-secrets
|
||||
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
|
||||
@@ -22,6 +22,10 @@
|
||||
include_tasks: deployments/mariadb.yaml
|
||||
when: apps.mariadb.enabled
|
||||
|
||||
- name: deploy postgresql
|
||||
include_tasks: deployments/postgresql.yaml
|
||||
when: apps.postgres.enabled
|
||||
|
||||
- name: deploy gitea
|
||||
include_tasks: deployments/gitea.yaml
|
||||
when: apps.gitea.enabled
|
||||
|
||||
13
ansible-5/roles/prod.k3s/templates/postgres/pv-claim.yaml
Normal file
13
ansible-5/roles/prod.k3s/templates/postgres/pv-claim.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: "{{apps.postgres.pvc}}"
|
||||
namespace: "{{apps.postgres.namespace}}"
|
||||
spec:
|
||||
storageClassName: manual
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
17
ansible-5/roles/prod.k3s/templates/postgres/pv.yaml
Normal file
17
ansible-5/roles/prod.k3s/templates/postgres/pv.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
# persistent volume
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: postgres-pv-local
|
||||
labels:
|
||||
type: local
|
||||
spec:
|
||||
storageClassName: manual
|
||||
capacity:
|
||||
storage: 100Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
hostPath:
|
||||
path: "/opt/data/db/postgres-15.1"
|
||||
|
||||
Reference in New Issue
Block a user