2

I have deployed postgresql pod on kubernetes pod, and want to know how can I access postgresql gui. I am not able to access it with ingress path, as I got to know ingress are meant for https purpose only whereas postgres follows TCP protocol. Any lead how can I access through GUI?

deployment.yaml

---
  apiVersion: "apps/v1"
  kind: "Deployment"
  metadata: 
    name: "postgresql-development"
    namespace: "development"
  spec: 
    selector: 
      matchLabels: 
        app: "postgresql-development"
    replicas: 1
    strategy: 
      type: "RollingUpdate"
      rollingUpdate: 
        maxSurge: 1
        maxUnavailable: 1
    minReadySeconds: 5
    template: 
      metadata: 
        labels: 
          app: "postgresql-development"
          tier: "mysql"
      spec: 
        containers: 
          - 
            name: "postgresql-development"
            image: "postgresql:12.6"
            imagePullPolicy: "Always"
            env: 
              - 
                name: "POSTGRES_USER"
                value: "postgres"
            ports: 
              - 
                containerPort: 5432
                name: "postgres"
                
            volumeMounts: 
              - 
                name: "postgresql-persistent-storage"
                mountPath: "/var/lib/postgresql"
                
        volumes: 
          - 
            name: "postgresql-persistent-storage"
            persistentVolumeClaim: 
              claimName: "postgresql-pvc-development"


                
        imagePullSecrets: 
          - 
            name: "postgresql"

service.yaml

---
  apiVersion: "v1"
  kind: "Service"
  metadata: 
    name: "postgresql-development"
    namespace: "development"
    labels: 
      app: "postgresql-development"
      app.kubernetes.io/name: ingress-nginx
      app.kubernetes.io/part-of: ingress-nginx
  spec: 
    ports: 
      - 
        port: 59799
        targetPort: 5432
        protocol: TCP
    selector: 
      app: "postgresql-development"
      app.kubernetes.io/name: ingress-nginx
      app.kubernetes.io/part-of: ingress-nginx
      tier: mysql

ingress.yaml

---
  apiVersion: "networking.k8s.io/v1beta1"
  kind: "Ingress"
  metadata: 
    name: "postgresql-development-ingress"
    namespace: "development"
    annotations: 
      nginx.ingress.kubernetes.io/rewrite-target: "/$1"
  spec: 
    rules: 
      - 
        host: "localhost"
        http: 
          paths: 
            - 
              backend: 
                serviceName: "postgresql-development"
                servicePort: 59799
              path: "postgresql-development/(.*)"
1
  • You will want to read up on NodePort, or it may also be possible to use the tcp port exposure of nginx-ingress, if you're using that one. Depending on how permanent this need is, kubectl port-forward also works great. Separately, you will also want to exercise extreme caution trying to use Deployment for something that is actually a StatefulSet Commented Apr 29, 2021 at 15:20

1 Answer 1

5

Ingress API are only for Layer 7 (HTTP). In your case you want to access Layer 4 (TCP).

To achieve you goal, you can:

Sign up to request clarification or add additional context in comments.

4 Comments

the far more common nginx ingress controller also supports TCP and UDP, if you wish to include that in your answer
Yes, but not as easy as Traefik
I have updated the service.yaml file in my question can you please check if it's correct. Also wanted to know what would be the url to access the GUI?
If you use nginx, you also need to create a configmap with the right mapping. stackoverflow.com/questions/53060092/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.