diff --git a/kustomize/install/manager/kustomization.yaml b/kustomize/install/manager/kustomization.yaml index 5c5f0b84..df67892d 100644 --- a/kustomize/install/manager/kustomization.yaml +++ b/kustomize/install/manager/kustomization.yaml @@ -1,2 +1,19 @@ resources: - manager.yaml + +patchesStrategicMerge: +- |- + apiVersion: apps/v1 + kind: Deployment + metadata: + name: pgo + spec: + template: + spec: + containers: + - name: operator + env: + - name: CRUNCHY_DEBUG + value: "false" + - name: CHECK_FOR_UPGRADES + value: "false" diff --git a/kustomize/monitoring/my-ingress.yaml b/kustomize/monitoring/my-ingress.yaml new file mode 100644 index 00000000..d6dbe589 --- /dev/null +++ b/kustomize/monitoring/my-ingress.yaml @@ -0,0 +1,30 @@ +# +# This file was made by me, not from the crunchy repos +# And will not be included in the kustomize. +# The purpose is to access grafana dashboard via nginx-ingress +# +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + nginx.ingress.kubernetes.io/proxy-body-size: 10m + name: mon-pgo-ingress + namespace: postgres-operator +spec: + # How to get class name? + # Depend on setup of ingress controller + # kubectl get ingressClass --all-namespaces + ingressClassName: traefik + # ingressClassName: nginx + rules: + - host: mon-pgo.mxn0.store + http: + paths: + # note all services must be alive, otherwise might affect another + - path: / + pathType: Prefix + backend: + service: + name: crunchy-grafana + port: + number: 3000 diff --git a/kustomize/postgres/postgres.yaml b/kustomize/postgres/postgres.yaml index 32144b11..20d49858 100644 --- a/kustomize/postgres/postgres.yaml +++ b/kustomize/postgres/postgres.yaml @@ -5,14 +5,62 @@ metadata: spec: image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi8-15.4-0 postgresVersion: 15 + + # HA: + # https://access.crunchydata.com/documentation/postgres-operator/5.0.1/tutorial/high-availability/ + # https://stackoverflow.com/questions/77309504/crunchy-postgres-operator-whats-the-different-and-use-cases-between-spec-insta + # instances: - - name: instance1 + # name `db` will create pod name like: hippo-db1-lct8-0 + - name: i1 + replicas: 1 + # replicas: 2 dataVolumeClaimSpec: accessModes: - "ReadWriteOnce" resources: requests: storage: 1Gi + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + topologyKey: kubernetes.io/hostname + labelSelector: + matchLabels: + postgres-operator.crunchydata.com/cluster: hippo + postgres-operator.crunchydata.com/instance-set: i1 + - name: i2 + replicas: 1 + dataVolumeClaimSpec: + accessModes: + - "ReadWriteOnce" + resources: + requests: + storage: 1Gi + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + topologyKey: kubernetes.io/hostname + labelSelector: + matchLabels: + postgres-operator.crunchydata.com/cluster: hippo + postgres-operator.crunchydata.com/instance-set: i2 + + # add new user rhino, hippo still exist + # db name here is postgres db name, not db1, db2 instance's name above + users: + - name: rhino + databases: + - payment + - finance + - name: f2e + databases: + - f2e-local-pgo + backups: pgbackrest: image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:ubi8-2.47-0 @@ -25,3 +73,39 @@ spec: resources: requests: storage: 1Gi + + # connection pool + proxy: + pgBouncer: + image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:ubi8-1.19-4 + replicas: 2 + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + topologyKey: kubernetes.io/hostname + labelSelector: + matchLabels: + postgres-operator.crunchydata.com/cluster: hippo + postgres-operator.crunchydata.com/role: pgbouncer + # pgbouncer service + service: + metadata: + labels: + app: f2e-api + type: NodePort + nodePort: 30001 + + # hippo-ha service + service: + metadata: + labels: + app: f2e-api + type: NodePort + nodePort: 30000 + + monitoring: + pgmonitor: + exporter: + image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres-exporter:ubi8-5.4.2-0 diff --git a/merge-kubeconfig b/merge-kubeconfig new file mode 100755 index 00000000..0d1323ee --- /dev/null +++ b/merge-kubeconfig @@ -0,0 +1,68 @@ +#!/bin/bash + +# Initialize variables to store option values +show_help=0 +do_reset=0 + +# Check the first argument +if [ $# -ge 1 ]; then + if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then + show_help=1 + shift + elif [ "$1" == "-r" ] || [ "$1" == "--reset" ]; then + do_reset=1 + shift + fi +fi + + +if [ "$show_help" -eq 1 ]; then + echo "Usage: merge-kubeconfig [-h] [-r] [file1] [file2] [...] [file n]" + echo "Options:" + echo " -h, --help Show help" + echo " -r, --reset override(replace) the current config rather than merge with it" + echo "" + echo "Eg:" + echo "" + echo " 1) Append" + echo " " + echo " merge-kubeconfig ~/.kube/k3s-fi.conf aws-k8s.conf" + echo " " + echo " would append k3s-fi and aws-k8s config into current config, stored at ~/.kube/config" + echo " " + echo " 2) Replace" + echo "" + echo " merge-kubeconfig -r ~/.kube/k3s-fi.conf aws-k8s.conf" + echo "" + echo " would empty the current config, then store k3s-fi and aws-k8s config into current config, stored at ~/.kube/config" + + exit 0 +fi + + +KUBECONFIG="" +for arg in "$@"; do + KUBECONFIG="${KUBECONFIG}:${arg}" +done +# Remove the fisrt `:` char +KUBECONFIG="${KUBECONFIG#:}" +if [ "$do_reset" -ne 1 ]; then + KUBECONFIG=~/.kube/config:$KUBECONFIG +fi + +echo "---" +echo "KUBECONFIG=$KUBECONFIG" +echo "---" + +export KUBECONFIG +kubectl config view --flatten > all-in-one-kubeconfig.yaml +mv all-in-one-kubeconfig.yaml ~/.kube/config + +if [ "$do_reset" -eq 1 ]; then + echo "OK: replace current config with $@" + exit 0 +else + echo "OK: merged current config with $@" + exit 0 +fi +