Helm/PostgreSQL/PV: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| Line 1: | Line 1: | ||
{|class='wikitable' | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight lang='bash'> | |||
helm repo add bitnami https://charts.bitnami.com/bitnami | |||
helm repo update && helm repo list | |||
kubectl config get-contexts | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|} | |||
==Config== | ==Config== | ||
{| | {|class='wikitable mw-collapsible' | ||
|valign= | !scope='col' style='text-align:left' colspan='2'| | ||
<syntaxhighlight lang= | Config | ||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight lang='bash'> | |||
export KUBECONFIG="${HOME}/.kube/aws-kubeconfig.yaml" | export KUBECONFIG="${HOME}/.kube/aws-kubeconfig.yaml" | ||
export KUBECONFIG="${HOME}/.kube/dev-kubeconfig.yaml" | export KUBECONFIG="${HOME}/.kube/dev-kubeconfig.yaml" | ||
| Line 13: | Line 23: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|valign= | |valign='top' style='width:50%'| | ||
<syntaxhighlight lang= | <syntaxhighlight lang='bash'> | ||
cat <<'EXE'| sudo bash | cat <<'EXE'| sudo bash | ||
mkdir -p /var/minikube/pvc/postgresql/data-postgresql-0/ | mkdir -p /var/minikube/pvc/postgresql/data-postgresql-0/ | ||
| Line 23: | Line 33: | ||
==Install== | ==Install== | ||
{| | {|class='wikitable mw-collapsible' | ||
!scope='col' style='text-align:left' colspan='2'| | |||
<syntaxhighlight lang= | Install | ||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight lang='bash'> | |||
helm show values bitnami/postgresql --version=15.5.20|less | helm show values bitnami/postgresql --version=15.5.20|less | ||
helm show values bitnami/postgresql --version=15.5.21|less | helm show values bitnami/postgresql --version=15.5.21|less | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
|valign='top'| | |||
<syntaxhighlight lang='bash'> | |||
|valign= | |||
<syntaxhighlight lang= | |||
kubectl get ns|grep postgresql | kubectl get ns|grep postgresql | ||
kubectl delete ns postgresql | kubectl delete ns postgresql | ||
| Line 44: | Line 53: | ||
|valign="bottom"| | |valign="bottom"| | ||
<syntaxhighlight lang= | <syntaxhighlight lang='properties'> | ||
cat <<ENV | kubectl -n postgresql create secret generic postgresql --from-env-file=/dev/stdin | cat <<ENV | kubectl -n postgresql create secret generic postgresql --from-env-file=/dev/stdin | ||
replication-password=sadaqah! | replication-password=sadaqah! | ||
| Line 53: | Line 62: | ||
|- | |- | ||
| | |valign='top' colspan='2'| | ||
* [[K8s/Storage#Storage » Mount|Skipped » Find More 👉 Storage » Mount]] | * [[K8s/Storage#Storage » Mount|Skipped » Find More 👉 Storage » Mount]] | ||
|- | |- | ||
| | |valign='top' colspan='2'| | ||
* [[K8s/Storage#Storage » Class » Hostpath|Skipped » Find More 👉 Storage » Class » Hostpath]] | * [[K8s/Storage#Storage » Class » Hostpath|Skipped » Find More 👉 Storage » Class » Hostpath]] | ||
|- | |- | ||
| | |valign='top' colspan='2'| | ||
* [[K8s/Storage#Storage » Persistent Volume|Skipped » Find More 👉 Storage » Persistent Volume]] | * [[K8s/Storage#Storage » Persistent Volume|Skipped » Find More 👉 Storage » Persistent Volume]] | ||
|- | |- | ||
|valign='top'| | |||
|valign= | |||
<syntaxhighlight lang="yaml" highlight="13-15"> | <syntaxhighlight lang="yaml" highlight="13-15"> | ||
cat <<'YML'| kubectl apply -f - | cat <<'YML'| kubectl apply -f - | ||
| Line 97: | Line 94: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|valign= | |valign='top'| | ||
<syntaxhighlight lang="yaml" highlight="8,9,16,17"> | <syntaxhighlight lang="yaml" highlight="8,9,16,17"> | ||
cat << YML | kubectl apply -f - | cat << YML | kubectl apply -f - | ||
| Line 120: | Line 117: | ||
|- | |- | ||
| | |valign='top' colspan='2'| | ||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
cat <<YML | helm -n postgresql install postgresql bitnami/postgresql --version=15.5.21 -f - | cat <<YML | helm -n postgresql install postgresql bitnami/postgresql --version=15.5.21 -f - | ||
| Line 172: | Line 166: | ||
|- | |- | ||
| | |valign='top' colspan='2'| | ||
* [[Minikube MetalLB#MetalLB » Forward » Route|Skipped » Find More 👉 MetalLB » Forward » Route]] | * [[Minikube MetalLB#MetalLB » Forward » Route|Skipped » Find More 👉 MetalLB » Forward » Route]] | ||
|- | |- | ||
|valign='top'| | |valign='top'| | ||
<syntaxhighlight lang= | <syntaxhighlight lang='bash'> | ||
echo -n password: ; read -s PGPASSWORD; export PGPASSWORD; echo | echo -n password: ; read -s PGPASSWORD; export PGPASSWORD; echo | ||
psql -h192.168.49.102 -p5432 -Uacademia academia | psql -h192.168.49.102 -p5432 -Uacademia academia | ||
| Line 190: | Line 178: | ||
|valign='top'| | |valign='top'| | ||
<syntaxhighlight lang= | <syntaxhighlight lang='bash'> | ||
echo -n password: ; read -s PGPASSWORD; export PGPASSWORD; echo | echo -n password: ; read -s PGPASSWORD; export PGPASSWORD; echo | ||
psql 'postgres://academia:@192.168.49.102:5432/academia' | psql 'postgres://academia:@192.168.49.102:5432/academia' | ||
| Line 198: | Line 186: | ||
==Uninstall== | ==Uninstall== | ||
<syntaxhighlight lang= | {|class='wikitable mw-collapsible' | ||
!scope='col' style='text-align:left' colspan='2'| | |||
Uninstall | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight lang='bash'> | |||
kubectl delete namespace postgresql | kubectl delete namespace postgresql | ||
| Line 205: | Line 198: | ||
kubectl delete pv postgresql-data-postgresql-0 | kubectl delete pv postgresql-data-postgresql-0 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|valign='top' style='width:50%'| | |||
|} | |||
==Swiss Knife== | ==Swiss Knife== | ||
{|class='wikitable mw-collapsible' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
Swiss Knife | |||
|- | |||
|valign='top' style='width:50%'| | |||
* [[Helm/PostgreSQL#Swiss Knife|Skipped » Find More » 👈]] | * [[Helm/PostgreSQL#Swiss Knife|Skipped » Find More » 👈]] | ||
|valign='top' style='width:50%'| | |||
|} | |||
==AWS » EKS== | ==AWS » EKS== | ||
{|class='wikitable mw-collapsible' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
AWS » EKS | |||
|- | |||
|valign='top' style='width:50%'| | |||
* [[Helm/PostgreSQL#AWS » EKS|Skipped » Find More » 👈]] | * [[Helm/PostgreSQL#AWS » EKS|Skipped » Find More » 👈]] | ||
|valign='top' style='width:50%'| | |||
|} | |||
==Playground== | ==Playground== | ||
{| | {|class='wikitable mw-collapsible' | ||
| colspan= | !scope='col' style='text-align:left' colspan='2'| | ||
<syntaxhighlight lang= | Playground | ||
|- | |||
|valign='top' colspan='2'| | |||
<syntaxhighlight lang='bash'> | |||
helm -n postgresql install postgresql bitnami/postgresql --version=15.5.20 | helm -n postgresql install postgresql bitnami/postgresql --version=15.5.20 | ||
helm -n postgresql upgrade -i postgresql bitnami/postgresql --version=15.5.21 | helm -n postgresql upgrade -i postgresql bitnami/postgresql --version=15.5.21 | ||
helm show values bitnami/postgresql --version=15.5.21|less | helm show values bitnami/postgresql --version=15.5.21|less | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| colspan= | |valign='top' colspan='2'| | ||
<syntaxhighlight lang= | <syntaxhighlight lang='bash'> | ||
kubectl -n postgresql get secret postgresql -o json|jq -r '.data."postgres-password"'|base64 -d;echo | kubectl -n postgresql get secret postgresql -o json|jq -r '.data."postgres-password"'|base64 -d;echo | ||
kubectl -n postgresql get secret postgresql -o json|jq -r '.data.password'|base64 -d;echo | kubectl -n postgresql get secret postgresql -o json|jq -r '.data.password'|base64 -d;echo | ||
| Line 234: | Line 245: | ||
kubectl -n postgresql exec -it svc/postgresql -- psql -Upostgres | kubectl -n postgresql exec -it svc/postgresql -- psql -Upostgres | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| colspan= | |valign='top' colspan='2'| | ||
<syntaxhighlight lang= | <syntaxhighlight lang='bash'> | ||
kubectl config --kubeconfig=${HOME}/.kube/aws-kubeconfig.yaml view --flatten | kubectl config --kubeconfig=${HOME}/.kube/aws-kubeconfig.yaml view --flatten | ||
kubectl config --kubeconfig=${HOME}/.kube/dev-kubeconfig.yaml view --flatten | kubectl config --kubeconfig=${HOME}/.kube/dev-kubeconfig.yaml view --flatten | ||
| Line 246: | Line 253: | ||
kubectl config --kubeconfig=${HOME}/.kube/config view --flatten | kubectl config --kubeconfig=${HOME}/.kube/config view --flatten | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
|valign='top' style='width:50%'| | |||
<syntaxhighlight lang='bash'> | |||
| valign= | |||
<syntaxhighlight lang= | |||
kubectl -n postgresql delete all --all | kubectl -n postgresql delete all --all | ||
kubectl -n postgresql delete ing --all | kubectl -n postgresql delete ing --all | ||
| Line 258: | Line 261: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| valign= | |valign='top' style='width:50%'| | ||
<syntaxhighlight lang= | <syntaxhighlight lang='bash'> | ||
kubectl delete pv postgresql-data-postgresql-0 | kubectl delete pv postgresql-data-postgresql-0 | ||
kubectl -n postgresql delete svc --all | kubectl -n postgresql delete svc --all | ||
kubectl -n postgresql delete pvc --all | kubectl -n postgresql delete pvc --all | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
|valign='top'| | |||
<syntaxhighlight lang='bash'> | |||
| valign= | |||
<syntaxhighlight lang= | |||
kubectl -n postgresql rollout history sts postgresql | kubectl -n postgresql rollout history sts postgresql | ||
kubectl -n postgresql rollout restart sts postgresql | kubectl -n postgresql rollout restart sts postgresql | ||
| Line 276: | Line 275: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| valign= | |valign='top'| | ||
<syntaxhighlight lang= | <syntaxhighlight lang='bash'> | ||
kubectl -n postgresql exec -it postgresql-0 -- psql -Upostgres | kubectl -n postgresql exec -it postgresql-0 -- psql -Upostgres | ||
kubectl -n postgresql logs -f svc/postgresql -c postgresql | kubectl -n postgresql logs -f svc/postgresql -c postgresql | ||
| Line 286: | Line 285: | ||
==References== | ==References== | ||
{| | {|class='wikitable mw-collapsible' | ||
| valign= | !scope='col' style='text-align:left' colspan='3'| | ||
References | |||
|- | |||
|valign='top' style='width:33%'| | |||
* [https://tyk.io/docs/deployment-and-operations/tyk-self-managed/deployment-lifecycle/installations/kubernetes/tyk-helm-tyk-stack-postgresql/ Helm » PostgreSQL » Quick Start] | * [https://tyk.io/docs/deployment-and-operations/tyk-self-managed/deployment-lifecycle/installations/kubernetes/tyk-helm-tyk-stack-postgresql/ Helm » PostgreSQL » Quick Start] | ||
* [https://stackoverflow.com/questions/76489284/ Helm » PostgreSQL » Init Script] | * [https://stackoverflow.com/questions/76489284/ Helm » PostgreSQL » Init Script] | ||
| Line 299: | Line 301: | ||
* [[Helm]] | * [[Helm]] | ||
| valign= | |valign='top' style='width:34%'| | ||
* [https://stackoverflow.com/questions/75596795/ Helm » Pass YAML/JSON using <code>stdin</code>] | * [https://stackoverflow.com/questions/75596795/ Helm » Pass YAML/JSON using <code>stdin</code>] | ||
* [[Helm/MariaDB/PV|Helm » MariaDB » PV]] | * [[Helm/MariaDB/PV|Helm » MariaDB » PV]] | ||
* [[Helm/PgAdmin4|Helm » PgAdmin4]] | * [[Helm/PgAdmin4|Helm » PgAdmin4]] | ||
| valign= | |valign='top' style='width:33%'| | ||
|- | |- | ||
|valign='top'| | |||
| valign= | |||
* [https://github.com/bitnami/charts/tree/main/bitnami/postgresql-ha PostgreSQL » Bitnami » Helm Charts » HA] | * [https://github.com/bitnami/charts/tree/main/bitnami/postgresql-ha PostgreSQL » Bitnami » Helm Charts » HA] | ||
* [https://github.com/bitnami/charts/tree/main/bitnami/postgresql PostgreSQL » Bitnami » Helm Charts] | * [https://github.com/bitnami/charts/tree/main/bitnami/postgresql PostgreSQL » Bitnami » Helm Charts] | ||
| Line 319: | Line 317: | ||
* [[PostgreSQL]] | * [[PostgreSQL]] | ||
| valign= | |valign='top'| | ||
|valign='top'| | |||
|- | |- | ||
|valign='top'| | |||
| valign= | |||
* [https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ K8s » Configure Service Accounts for Pods] | * [https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ K8s » Configure Service Accounts for Pods] | ||
* [https://spacelift.io/blog/restart-kubernetes-pods-with-kubectl K8s » Restart Pods With Kubectl] | * [https://spacelift.io/blog/restart-kubernetes-pods-with-kubectl K8s » Restart Pods With Kubectl] | ||
| Line 339: | Line 333: | ||
* [[K8s]] | * [[K8s]] | ||
| valign= | |valign='top'| | ||
* [https://kubernetes.io/docs/reference/kubectl/generated/kubectl_rollout/ K8s » <code>kubectl rollout</code>] | * [https://kubernetes.io/docs/reference/kubectl/generated/kubectl_rollout/ K8s » <code>kubectl rollout</code>] | ||
* [[K8s/CSI Hostpath Driver|K8s » CSI Hostpath Driver]] | * [[K8s/CSI Hostpath Driver|K8s » CSI Hostpath Driver]] | ||
| Line 351: | Line 345: | ||
* [[UFW]] | * [[UFW]] | ||
| valign= | |valign='top'| | ||
|} | |} | ||
Latest revision as of 21:13, 19 January 2026
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update && helm repo list
kubectl config get-contexts
|
Config
|
Config | |
|---|---|
export KUBECONFIG="${HOME}/.kube/aws-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/dev-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/gcp-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/config"
|
cat <<'EXE'| sudo bash
mkdir -p /var/minikube/pvc/postgresql/data-postgresql-0/
chown -R 1001:1001 /var/minikube/pvc/postgresql/
EXE
|
Install
|
Install | |
|---|---|
helm show values bitnami/postgresql --version=15.5.20|less
helm show values bitnami/postgresql --version=15.5.21|less
| |
kubectl get ns|grep postgresql
kubectl delete ns postgresql
kubectl get ns|grep postgresql
kubectl create ns postgresql
|
cat <<ENV | kubectl -n postgresql create secret generic postgresql --from-env-file=/dev/stdin
replication-password=sadaqah!
postgres-password=sadaqah!
password=sadaqah!
ENV
|
cat <<'YML'| kubectl apply -f -
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: postgresql-data-postgresql-0
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: hostpath
hostPath:
path: /var/hostpath_pv/postgresql/data-postgresql-0
type: DirectoryOrCreate
YML
|
cat << YML | kubectl apply -f -
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app.kubernetes.io/name: postgresql
name: data-postgresql-0
namespace: postgresql
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: hostpath
volumeName: postgresql-data-postgresql-0
YML
|
cat <<YML | helm -n postgresql install postgresql bitnami/postgresql --version=15.5.21 -f -
---
global:
defaultStorageClass: hostpath
postgresql:
auth:
existingSecret: postgresql
username: academia
database: academia
primary:
service:
type: LoadBalancer
loadBalancerIP: 192.168.49.102
persistence:
size: 10Gi
storageClass: hostpath
existingClaim: data-postgresql-0
initdbScripts:
initdb:
scripts:
init-chorke.sql: |
-- create database
CREATE DATABASE academia_flair_staging;
CREATE DATABASE academia_audit_staging;
CREATE DATABASE academia_quote_staging;
CREATE DATABASE academia_users_staging;
-- create user
CREATE USER chorke WITH ENCRYPTED PASSWORD 'sadaqah!';
-- ALTER USER chorke WITH NOSUPERUSER;
-- ALTER USER chorke WITH SUPERUSER;
-- grant owner
ALTER DATABASE academia_flair_staging OWNER TO chorke;
ALTER DATABASE academia_audit_staging OWNER TO chorke;
ALTER DATABASE academia_quote_staging OWNER TO chorke;
ALTER DATABASE academia_users_staging OWNER TO chorke;
-- grant access
GRANT ALL PRIVILEGES ON DATABASE academia_flair_staging TO chorke;
GRANT ALL PRIVILEGES ON DATABASE academia_audit_staging TO chorke;
GRANT ALL PRIVILEGES ON DATABASE academia_quote_staging TO chorke;
GRANT ALL PRIVILEGES ON DATABASE academia_users_staging TO chorke;
YML
| |
echo -n password: ; read -s PGPASSWORD; export PGPASSWORD; echo
psql -h192.168.49.102 -p5432 -Uacademia academia
psql -h192.168.49.102 -p5432 -Upostgres postgres
|
echo -n password: ; read -s PGPASSWORD; export PGPASSWORD; echo
psql 'postgres://academia:@192.168.49.102:5432/academia'
psql 'postgres://postgres:@192.168.49.102:5432/postgres'
|
Uninstall
|
Uninstall | |
|---|---|
kubectl delete namespace postgresql
helm uninstall -n postgresql postgresql
kubectl -n postgresql delete pvc --all
kubectl delete pv postgresql-data-postgresql-0
|
|
Swiss Knife
|
Swiss Knife | |
|---|---|
AWS » EKS
|
AWS » EKS | |
|---|---|
Playground
|
Playground | |
|---|---|
helm -n postgresql install postgresql bitnami/postgresql --version=15.5.20
helm -n postgresql upgrade -i postgresql bitnami/postgresql --version=15.5.21
helm show values bitnami/postgresql --version=15.5.21|less
| |
kubectl -n postgresql get secret postgresql -o json|jq -r '.data."postgres-password"'|base64 -d;echo
kubectl -n postgresql get secret postgresql -o json|jq -r '.data.password'|base64 -d;echo
kubectl -n postgresql exec -it svc/postgresql -c postgresql -- psql -Upostgres
kubectl -n postgresql exec -it svc/postgresql -c postgresql -- bash
kubectl -n postgresql exec -it svc/postgresql -- psql -Upostgres
| |
kubectl config --kubeconfig=${HOME}/.kube/aws-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/dev-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/gcp-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/config view --flatten
| |
kubectl -n postgresql delete all --all
kubectl -n postgresql delete ing --all
kubectl -n postgresql delete sts --all
|
kubectl delete pv postgresql-data-postgresql-0
kubectl -n postgresql delete svc --all
kubectl -n postgresql delete pvc --all
|
kubectl -n postgresql rollout history sts postgresql
kubectl -n postgresql rollout restart sts postgresql
kubectl -n postgresql rollout status sts postgresql
|
kubectl -n postgresql exec -it postgresql-0 -- psql -Upostgres
kubectl -n postgresql logs -f svc/postgresql -c postgresql
kubectl -n postgresql logs -f svc/postgresql
|
References
|
References | ||
|---|---|---|