Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

931
Vistas
How to create keycloak with operator and external database

I follow this but it is not working.

I created custom secret:

apiVersion: v1
kind: Secret
metadata:
    name: keycloak-db-secret
data:
    POSTGRES_DATABASE: ...
    POSTGRES_EXTERNAL_ADDRESS: ...
    POSTGRES_EXTERNAL_PORT: ...
    POSTGRES_HOST: ...
    POSTGRES_USERNAME: ...
    POSTGRES_PASSWORD: ...

and keycloak with external db:

apiVersion: keycloak.org/v1alpha1
kind: Keycloak
metadata:
  labels:
      app: keycloak
  name: keycloak
spec:
  externalDatabase:
    enabled: true
  instances: 1

but when I check log, keycloak can not connect to db. It is still using default vaule: keycloak-postgresql.keycloak not value defined in my custom secret ? Why it is not using my value from secrets ?

UPDATE

when I check keycloak pod which was created by operator I can see:

  env:
    - name: DB_VENDOR
      value: POSTGRES
    - name: DB_SCHEMA
      value: public
    - name: DB_ADDR
      value: keycloak-postgresql.keycloak
    - name: DB_PORT
      value: '5432'
    - name: DB_DATABASE
      value: keycloak
    - name: DB_USER
      valueFrom:
        secretKeyRef:
          name: keycloak-db-secret
          key: POSTGRES_USERNAME
    - name: DB_PASSWORD
      valueFrom:
        secretKeyRef:
          name: keycloak-db-secret
          key: POSTGRES_PASSWORD

so now I know why I can not connect to db. It use different DB_ADDR. How I can use address: my-app.postgres (db in another namespace).

I dont know why POSTGRES_HOST in secret not working and pod still using default service name

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

To connect with service in another namespace you can use.

<servicename>.<namespace>.svc.cluster.local

suppose your Postgres deployment and service running in test namespace it will go like

postgres.test.svc.cluster.local

this is what i am using : https://github.com/harsh4870/Keycloack-postgres-kubernetes-deployment/blob/main/keycload-deployment.yaml

i have also attached the Postgres file you can use it however in my case i have setup both in the same namespace keycloak and Postgres so working like charm.

over 4 years ago · Santiago Trujillo Denunciar

0

keycloak-postgresql.keycloak this is the another service created by Keycloak Operator, which is used to connect to Postgresql's service.

You can check its endpoint.

$ kubectl get endpoints keycloak-postgresql -n keycloak
NAME                  ENDPOINTS           AGE
keycloak-postgresql   {postgresql's service ip}:5432   4m31s

However, the reason why it fails is due to the selector of this service:

selector:
  app: keycloak
  component: database

So if your DB Pod has the different Label, the selector will not work. I reported this issue to the community. If they reply me, I will try to fix this bug by submitting a patch.

over 4 years ago · Santiago Trujillo Denunciar

0

I'm using Azure PostgreSQL for that, and it works correctly. In pod configuration, it also uses keycloak-postgresql.keycloak as DB_ADDR, but this is pointing to my internal service created by operator based on keycloak-db-secret.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda