Home > other >  How to reach PostgresCluster in Azure Cloud with a client from local?
How to reach PostgresCluster in Azure Cloud with a client from local?

Time:01-03

I want to access my postgres cluster within my kubernetes within azure cloud with a client (e.g. pgadmin) to search manuelly through data.

At the moment my complete cluster only has 1 ingress that is pointing to a self written api gateway.

I found a few ideas online and tried to add a load balancer in kubernetesd without success.

My postgress cluster in terraform:

resource "helm_release" "postgres-cluster" {
  name       = "postgres-cluster"
  repository = "https://charts.bitnami.com/bitnami"
  chart      = "postgresql-ha"
  namespace  = var.kube_namespace

  set {
    name  = "global.postgresql.username"
    value = var.postgresql_username
  }

  set {
    name  = "global.postgresql.password"
    value = var.postgresql_password
  }
}

Results in a running cluster:

enter image description here

Now my try to add a load balancer:

resource "kubernetes_manifest" "postgresql-loadbalancer" {
  manifest = {
    "apiVersion" = "v1"
    "kind"       = "Service"
    "metadata"   = {
      "name"      = "postgres-db-lb"
      "namespace" = "${var.kube_namespace}"
    }
    "spec" = {
      "selector" = {
        "app.kubernetes.io/name" = "postgresql-ha"
      }
      "type" = "LoadBalancer"
      "ports" = [{
        "port"       = "5432"
        "targetPort" = "5432"
      }]
    }
  }
}

Will result in: enter image description here

But still no success if I try to connect to the external IP and Port:

enter image description here

CodePudding user response:

Found the answer - it was an internal Firewall I was never thinking of. The code is absolutly correct, a loadbalancer do work here.

  • Related