helm repo add runix https://helm.runix.net
helm repo update && helm repo list
kubectl config get-contexts
Config
export KUBECONFIG="${HOME}/.kube/dev-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/gcp-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/config"
Install
helm show values runix/pgadmin4 --version=1.30.0|less
helm show values runix/pgadmin4 --version=1.31.0|less
kubectl get ns|grep pgadmin
kubectl delete ns pgadmin
|
kubectl get ns|grep pgadmin
kubectl create ns pgadmin
cat <<ENV | kubectl -n pgadmin create secret generic pgadmin --from-env-file=/dev/stdin
password=sadaqah!
ENV
|
|
cat <<-'YML' | kubectl -n pgadmin create secret generic servers --from-file=servers=/dev/stdin
---
servers:
first:
Name: psql.k8s.local
Group: www.k8s.local
Port: 5432
Username: academia
Host: postgresql.postgresql.svc
MaintenanceDB: academia
YML
|
|
cat << YML | kubectl -n pgadmin apply -f -
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-pgadmin
spec:
storageClassName: standard
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /tmp/hostpath-provisioner/pgadmin/pvc-pgadmin
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app.kubernetes.io/name: pgadmin
name: pvc-pgadmin
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
volumeName: pv-pgadmin
YML
|
cat << YML | kubectl -n pgadmin apply -f -
---
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app.kubernetes.io/name: pgadmin
name: pvc-pgadmin
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
YML
|
|
cat <<YML | helm -n pgadmin install pgadmin runix/pgadmin4 --version=1.31.0 -f -
---
ingress:
enabled: true
ingressClassName: nginx
hosts:
- host: pgadmin.k8s.local
paths:
- path: /
pathType: Prefix
persistentVolume:
existingClaim: pvc-pgadmin
size: 10Gi
fullnameOverride: pgadmin
existingSecret: pgadmin
serverDefinitions:
enabled: true
resourceType: Secret
existingSecret: servers
env:
email: [email protected]
enhanced_cookie_protection: "True"
YML
|
|
echo -n password: ; read -s PGPASSWORD; export PGPASSWORD; echo
psql -h psql.k8s.local -p 5432 -U academia academia
psql -h psql.k8s.local -p 5432 -U postgres postgres
|
echo -n password: ; read -s PGPASSWORD; export PGPASSWORD; echo
psql 'postgres://academia:@psql.k8s.local:5432/academia'
psql 'postgres://postgres:@psql.k8s.local:5432/postgres'
|
Uninstall
helm uninstall -n pgadmin pgadmin
kubectl delete namespace pgadmin
Swiss Knife
kubectl -n postgresql run -i --tty --rm psql --image=alpine --restart=Never -- sh
echo -n password: ; read -s PGPASSWORD; export PGPASSWORD; echo
apk --update add --no-cache postgresql-client inetutils-telnet
psql -d postgres -U postgres -h postgresql.postgresql.svc.cluster.local
psql -d postgres -U postgres -h postgresql.postgresql.svc
psql -d postgres -U postgres -h postgresql.postgresql
psql -d postgres -U postgres -h postgresql
Playground
helm -n pgadmin install pgadmin runix/pgadmin4 --version=1.30.0
helm -n pgadmin upgrade -i pgadmin runix/pgadmin4 --version=1.31.0
helm show values runix/pgadmin4 --version=1.31.0|less
|
|
kubectl -n pgadmin exec -it svc/pgadmin -c pgadmin4 -- ls -lah /var/lib/pgadmin/storage
kubectl -n pgadmin exec -it svc/pgadmin -c pgadmin4 -- ls -lah /var/lib/pgadmin
kubectl -n pgadmin exec -it svc/pgadmin -c pgadmin4 -- python -V
kubectl -n pgadmin exec -it svc/pgadmin -c pgadmin4 -- pip -V
kubectl -n pgadmin exec -it svc/pgadmin -c pgadmin4 -- sh
|
|
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 pgadmin delete all --all
kubectl -n pgadmin delete ing --all
kubectl -n pgadmin delete sts --all
|
kubectl -n pgadmin delete svc --all
kubectl -n pgadmin delete pvc --all
kubectl -n pgadmin delete pv --all
|
|
kubectl -n pgadmin rollout history deploy pgadmin
kubectl -n pgadmin rollout restart deploy pgadmin
kubectl -n pgadmin rollout status deploy pgadmin
|
kubectl -n pgadmin logs -f svc/pgadmin -c pgadmin4
kubectl -n pgadmin exec -it svc/pgadmin -- sh
kubectl -n pgadmin logs -f svc/pgadmin
|
References