Helm/PgAdmin4
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 <<-'JSN' | kubectl -n pgadmin create secret generic server-definitions --from-file=servers.json=/dev/stdin
{
"Servers": {
"1": {
"Name": "psql.k8s.local/academia",
"Group": "www.k8s.local",
"Port": 5432,
"Username": "academia",
"MaintenanceDB": "academia",
"Host": "postgresql.postgresql.svc"
},
"2": {
"Name": "host.k8s.local/keycloak",
"Group": "host.k8s.local",
"Port": 5432,
"Username": "keycloak",
"MaintenanceDB": "keycloak",
"Host": "host.minikube.internal"
},
"3": {
"Name": "host.k8s.local/gitlab",
"Group": "host.k8s.local",
"Port": 5432,
"Username": "gitlab",
"MaintenanceDB": "gitlab",
"Host": "host.minikube.internal"
}
}
}
JSN
| |
| |
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
env:
email: [email protected]
enhanced_cookie_protection: "True"
serverDefinitions:
enabled: true
resourceType: Secret
existingSecret: server-definitions
YML
| |
| |
xdg-open http://pgadmin.k8s.local &>/dev/null &
gnome-open http://pgadmin.k8s.local &>/dev/null &
|
x-www-browser http://pgadmin.k8s.local &>/dev/null &
sensible-browser http://pgadmin.k8s.local &>/dev/null &
|
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
| ||