Helm/PgAdmin4: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
Line 40: Line 40:
cat <<-'JSN' | kubectl -n pgadmin create secret generic server-definitions --from-file=servers.json=/dev/stdin
cat <<-'JSN' | kubectl -n pgadmin create secret generic server-definitions --from-file=servers.json=/dev/stdin
{
{
  "Servers": {
    "Servers": {
    "1": {
        "1": {
      "Name": "psql.k8s.local/academia",
            "Name": "psql.k8s.local/academia",
      "Group": "www.k8s.local",
            "Group": "www.k8s.local",
      "Port": 5432,
            "Port": 5432,
      "Username": "academia",
            "Username": "academia",
      "MaintenanceDB": "academia",
            "MaintenanceDB": "academia",
      "Host": "postgresql.postgresql.svc"
            "Host": "postgresql.postgresql.svc"
    },
        },
    "2": {
        "2": {
      "Name": "host.k8s.local/keycloak",
            "Name": "host.k8s.local/keycloak",
      "Group": "host.k8s.local",
            "Group": "host.k8s.local",
      "Port": 5432,
            "Port": 5432,
      "Username": "keycloak",
            "Username": "keycloak",
      "MaintenanceDB": "keycloak",
            "MaintenanceDB": "keycloak",
      "Host": "host.minikube.internal"
            "Host": "host.minikube.internal"
    },
        },
    "3": {
        "3": {
      "Name": "host.k8s.local/gitlab",
            "Name": "host.k8s.local/gitlab",
      "Group": "host.k8s.local",
            "Group": "host.k8s.local",
      "Port": 5432,
            "Port": 5432,
      "Username": "gitlab",
            "Username": "gitlab",
      "MaintenanceDB": "gitlab",
            "MaintenanceDB": "gitlab",
      "Host": "host.minikube.internal"
            "Host": "host.minikube.internal"
        }
     }
     }
  }
}
}
JSN
JSN

Revision as of 02:28, 17 November 2024

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

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