Cannot resolve host "postgresql"; lookup postgresql on 10.23.0.05:53: no such host

I am running rke2 cluster and deployed postgresql container with its cluster-ip service on port 5432 and now trying to deploy keycloak container within same cluster however, keycloak pod logs shows:
cannot resolve host “postgresql”; lookup postgresql on 10.23.0.05:53: no such host

my keycloak config in keycloak deployment yaml file:
KC_DB: “postgres”
KC_DB_URL: “jdbc:postgresql://localhost:5432/keycloak”
KC_DB_USERNAME: “*****”
KC_DB_PASSWORD: “****”
KC_DB_URL_DATABASE: “keycloak”

I have tried with different values in KC_DB_URL but still not working, not sure what causing this?
rke2 coredns service is working fine.
Am I missing something here?

KC_DB=postgres
KC_DB_URL=jdbc:postgresql://postgres:5432/keycloak → thi

if you run app in docker, try to use container name as above.

Also you don’t need:
KC_DB_URL_DATABASE: “keycloak”
the database name is define in URL

@djordje , I am not using docker, I am deploying keycloak using yaml file, it uses containerd not docker to create the containers in rke2 kubernetes cluster.

I tried to use your config specially, still same error:

try not using the quotation marks,

KC_DB: postgres
KC_DB_URL: jdbc:postgresql://localhost:5432/keycloak
KC_DB_USERNAME: *****
KC_DB_PASSWORD: ****
KC_DB_URL_DATABASE: keycloak

let me know if this works.

That’s unlikely to resolve the issue.

What is the name of the service for the database, or is there even one.

The jdbc url needs to point at the database. It’s most likely not in the same container.
The container runtime environment is irrelevant for this.

@ThoreKr , yes there is a clusterIP service running for postgresqDB on port 5432, I did not get you when you said container runtime environment is irrevelvant for this?

to make it more clear, let me rephrase the issue here: I am deploying postgresql and keycloak container image via kubernetes deployment yaml files on RKE2 cluster. of course, both (postgresql and keycloak) are on different pods .i.e different contianers.

It looks like Keycloak unable to resolve the DNS hostname, not sure, what I need to do ?

Then you need to use the name of the postgres service in your KC_DB_URL.

I tried this putting the postgresql service name (even with port and without port 5432) in keycloak deployment file in the format of “jdbc:postgresql://keycloak-postgres-svc/keycloak”, it was errored out:
"cannot resolve host “postgresql”: lookup postgresql on 10.43.0.10:53: no such host

Do you think it is issue with coreDNS as I just found it one of coreDNS is working but not coreDNS is not working as I have two CoreDNS pod in my rke2 cluster

you say you put

but the error says cannot resolve postgresql, the configuration from the jdbc url seems not to be applied correctly.