I setup an OpenShift environment on my Mac with following versions:
Mac OS Sierra, Version:10.12.2 (16C67)
oc v1.5.0-alpha.2+e4b43ee
kubernetes v1.5.2+43a9be4
features: Basic-Auth
I was able to get the developer version running by doing a oc cluster up
and gave the developer
user administrative rights. Next, I added postgres
container by issuing the following command:
oc new-app https://github.com/MojoJojo/authenticated-payments.git --name="postgres-keycloak" -l name="postgres-keycloak" --context-dir=postgres-keycloak
The command worked as expected and created a service with a Cluster Hostname
and a Cluster IP
address. The 'Cluster Hostname` in the admin console is reflecting as:
~ ❯❯❯ oc describe service/postgres-keycloak
Name: postgres-keycloak
Namespace: authenticated-collections
Labels: app=postgres-keycloak
name=postgres-keycloak
Selector: app=postgres-keycloak,deploymentconfig=postgres-keycloak,name=postgres-keycloak
Type: ClusterIP
IP: 172.30.123.160
Port: 5432-tcp 5432/TCP
Endpoints:
Session Affinity: None
No events.
~ ❯❯❯ oc describe pods/postgres-keycloak-2-8r9n5 ⏎
Name: postgres-keycloak-2-8r9n5
Namespace: authenticated-collections
Security Policy: restricted
Node: 192.168.65.2/192.168.65.2
Start Time: Mon, 23 Jan 2017 03:24:41 +0200
Labels: app=postgres-keycloak
deployment=postgres-keycloak-2
deploymentconfig=postgres-keycloak
name=postgres-keycloak
Status: Running
Next, I created another container as below:
oc new-app https://github.com/MojoJojo/authenticated-payments.git --name="jboss-keycloak" -l name="jboss-keycloak" --context-dir=jboss-keycloak
The above Git repository has a Dockerfile
that declares the following environment variables:
POSTGRES_PORT_5432_TCP_ADDR=postgres-keycloak.authenticatedcollections.svc.cluster.local
POSTGRES_PORT_5432_TCP_PORT=5432
I verified and the above environment variables are being set properly in the second container. The problem is that the second service is not able to connect to the 'postgres-keycloak' database in the first container.
Upon further investigation, I found that while I can ping POD, Cluster IP and Cluster hostnames, the psql
client is only able to connect if I use the pod's IP address directly. My conclusion so far is that the DNS resolution is working fine - it is just the service configuration that seems a little messed up. It seems that the service proxy is not forwarding the request to the containers.
Also, I'm not sure if the Endpoint
count (Zero) in the above extract is the cause of the problem? My understand is that Endpoints
are only used when services are accessed from outside the cluster.
I've tried installing other services like a web server for testing but it seems like none of the Cluster Hostnames
or IP addresses work.
I would really appreciate any tips, hints and pointers to help troubleshoot and fix this issue.
Thank you for your help.