From 1e38eeb6bbd8a18e16e27e70b97afc1c1d891510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Sun, 4 Jun 2023 15:05:01 +0200 Subject: [PATCH] wip --- README.md | 16 +- fruits-chart/Chart.yaml | 5 + .../templates/database-operator.yaml | 6 +- fruits-chart/templates/database-vm.yaml | 160 ++++++++++++++++++ fruits-chart/templates/deployment.yaml | 59 +++++++ fruits-chart/templates/route.yaml | 20 +++ fruits-chart/templates/service.yaml | 23 +++ fruits-chart/templates/servicebinding.yaml | 15 ++ fruits-chart/values.yaml | 2 + infrastructure/templates/crunchy.yaml | 14 ++ infrastructure/templates/fruits-dev.yaml | 47 ++++- .../templates/helmchartrepository.yaml | 10 ++ infrastructure/templates/servicebinding.yaml | 14 ++ kustomize/postgres/kustomization.yaml | 4 - 14 files changed, 377 insertions(+), 18 deletions(-) create mode 100644 fruits-chart/Chart.yaml rename kustomize/postgres/postgres.yaml => fruits-chart/templates/database-operator.yaml (87%) create mode 100644 fruits-chart/templates/database-vm.yaml create mode 100644 fruits-chart/templates/deployment.yaml create mode 100644 fruits-chart/templates/route.yaml create mode 100644 fruits-chart/templates/service.yaml create mode 100644 fruits-chart/templates/servicebinding.yaml create mode 100644 fruits-chart/values.yaml create mode 100644 infrastructure/templates/crunchy.yaml create mode 100644 infrastructure/templates/helmchartrepository.yaml create mode 100644 infrastructure/templates/servicebinding.yaml delete mode 100644 kustomize/postgres/kustomization.yaml diff --git a/README.md b/README.md index a22a638..d86a1f7 100644 --- a/README.md +++ b/README.md @@ -58,14 +58,10 @@ aws s3api put-bucket-policy --bucket mad-roadshow-france-2023-helm-charts --poli }' rclone config rclone ls aws:mad-roadshow-france-2023-helm-charts +mkdir -p /tmp/mad-roadshow-france-2023-helm-charts +helm package -d /tmp/mad-roadshow-france-2023-helm-charts fruits-chart +helm repo index --url "https://mad-roadshow-france-2023-helm-charts.s3.eu-west-3.amazonaws.com/" "/tmp/mad-roadshow-france-2023-helm-charts" +rclone sync --delete-after /tmp/mad-roadshow-france-2023-helm-charts aws:mad-roadshow-france-2023-helm-charts +rclone ls aws:mad-roadshow-france-2023-helm-charts +curl https://mad-roadshow-france-2023-helm-charts.s3.eu-west-3.amazonaws.com/index.yaml ``` - -## Deploy Postgres CrunchyDB - -1. Create a namespace ***preprod-database*** -2. Install the crunchyDB operator -3. run oc apply -k kustomize/postgres - -More details here : https://access.crunchydata.com/documentation/postgres-operator/5.3.1/quickstart/ - - diff --git a/fruits-chart/Chart.yaml b/fruits-chart/Chart.yaml new file mode 100644 index 0000000..f8bc210 --- /dev/null +++ b/fruits-chart/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: fruits-app +type: application +version: 0.0.1 +appVersion: "0.0.1" diff --git a/kustomize/postgres/postgres.yaml b/fruits-chart/templates/database-operator.yaml similarity index 87% rename from kustomize/postgres/postgres.yaml rename to fruits-chart/templates/database-operator.yaml index ecf6c0c..5284082 100644 --- a/kustomize/postgres/postgres.yaml +++ b/fruits-chart/templates/database-operator.yaml @@ -1,10 +1,11 @@ +{{ if eq .Values.db.deployment "operator" }} apiVersion: postgres-operator.crunchydata.com/v1beta1 kind: PostgresCluster metadata: name: hippo spec: - image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi8-15.2-0 - postgresVersion: 15 + image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi8-14.7-0 + postgresVersion: 14 instances: - name: instance1 dataVolumeClaimSpec: @@ -25,3 +26,4 @@ spec: resources: requests: storage: 1Gi +{{ end }} diff --git a/fruits-chart/templates/database-vm.yaml b/fruits-chart/templates/database-vm.yaml new file mode 100644 index 0000000..ddc01fb --- /dev/null +++ b/fruits-chart/templates/database-vm.yaml @@ -0,0 +1,160 @@ +{{ if eq .Values.db.deployment "vm" }} +apiVersion: v1 +kind: Secret +metadata: + name: database-cloudinit +type: Opaque +stringData: + userData: | + #cloud-config + + users: + - name: nicolas + gecos: Nicolas MASSE + groups: wheel + lock_passwd: false + passwd: $6$XUTB20jVVXIqh78k$L1A9Lft5JlbOtNbeDP.fOZ5giLl09LfJGGCon5uwtsIhPJoNkj4SIk08Rb6vSowOps2ik5tlUwT2ZOZ6jjr7.0 + ssh_authorized_keys: + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPR1tt58X0+vbvsCR12gMAqr+g7vjt1Fx/qqz9EiboIs nicolas@localhost.localdomain + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFW62WJXI1ZCMfNA4w0dMpL0fsldhbEfULNGIUB0nQui nmasse@localhost.localdomain + + write_files: + - path: /etc/sudoers + content: | + Defaults !visiblepw + Defaults always_set_home + Defaults match_group_by_gid + Defaults always_query_group_plugin + Defaults env_reset + Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS" + Defaults env_keep += "MAIL QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE" + Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES" + Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE" + Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY" + Defaults secure_path = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/lib/snapd/snap/bin + root ALL=(ALL) ALL + %wheel ALL=(ALL) NOPASSWD: ALL + #includedir /etc/sudoers.d + permissions: '0440' + append: false + + - path: /root/bootstrap.sh + content: | + #!/bin/bash + set -Eeuo pipefail + PGSETUP_INITDB_OPTIONS=--auth-host=scram-sha-256 postgresql-setup --initdb --unit postgresql + sed -i.bak -E "s/^#*\s*listen_addresses\s*=\s*'[^']*'/listen_addresses = '0.0.0.0'/" /var/lib/pgsql/data/postgresql.conf + cat >> /var/lib/pgsql/data/pg_hba.conf <