Communication Between Different Services in Kubernetes Deploy

11/16/2018

I'm new to using Kubernetes (v 1.11.2-gke.18), and am trying to get Sentry running as a Kubernetes deployment. This is all being run in Google Cloud. Here's the YAML files for Postgres, Redis, and Sentry:

postgres.yml for k8s redis.yml for k8s sentry.yml for k8s

The Redis and Postgres parts seem to be up and running just fine, but Sentry fails because: could not translate host name "postgres-sentry:5432" to address: Name or service not known.

My question is this: How do I get these services to communicate properly? How do I get the Sentry container to communicate with Postgres and Redis?

-- pjlamb12
kubernetes
postgresql

2 Answers

11/16/2018

It turns out that in this case, what I needed was to change the SENTRY_REDIS_HOST and SENTRY_POSTGRES_HOST values to not have the port numbers in the env declaration. Taking those out made everything talk together as expected.

-- pjlamb12
Source: StackOverflow

11/16/2018

In Kubernetes pods generally can find other pods through services using DNS.

Your configuration looks correct if postgres-sentry is in the same namespace as your sentry app pod/deployment (which looks like the default namespace).

So it points that you may have a problem with DNS. You can check by shelling into the sentry app container/pod and trying to ping postgres-sentry:

$ kubectl exec -it <pod-id-of-your-sentry-app> sh
# ping postgres-sentry

Also, check if you have you /etc/resolv.conf looks something like this:

# cat /etc/resolv.conf
nameserver 10.96.0.10
search default.svc.cluster.local svc.cluster.local cluster.local
options ndots:5

Finally, check if your DNS pods are running:

$ kubectl -n kube-system get pods | grep dns
coredns-xxxxxxxxxxx-xxxxx                                             1/1     Running   15         116d
coredns-xxxxxxxxxxx-xxxxx                                             1/1     Running   15         116d
-- Rico
Source: StackOverflow