0

I m trying to have cloudera manager and cloudera agents on openshift, in order to run the installation I need to get all the pods communicating with each other.

Manually, I modified the /etc/hosts on the manager and add all the agents and on the agents I added the manager and all the other agents.

Now I wanted to automate this, let suppose I add a new agent, I want it to resolve the manager and the host (I can get a part of it done, by passing the manager name as an env variable and with a shell script add it to the /etc/hosts, not the ideal way but still solution). But the second part would be more difficult, to get the manager to resolve every new agent, and also to resolve every other agent on the same service.

I was wondering if there is a way so every pod on the cluster can resolve the others names ?

I have to services cloudera-manager with one pod, and an other service cloudera-agent with -let's say- 3 agents.

do you have any idea ?

thank you.

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

0

Not sure, but it looks like you could benefit from StatefulSets.

There are other ways to get the other pods ips (like using a headless service or requesting to the serverAPI directly ) but StatefulSets provide :

  • Stable, unique network identifiers

  • Stable, persistent storage.

  • Lots of other functionality that facilitates the deployment of a special kind of clusters like distributed databases. Not sure my term 'distributed' here is correct, but it helps me remind what they are for :).

rrh
  • 808
  • 7
  • 12
  • Thank you @lhuser123 for your reply, Do you have any example of such kind of applications ? I want to see their Deployment config to understand better. I can resolve pods using their IP adresses, I want to get name resolution. thank you – Mohammed Elmehdi EZ-GHARI Jun 29 '17 at 07:42
  • Take a look at this [example](https://github.com/kubernetes/kubernetes/blob/master/examples/cockroachdb/cockroachdb-statefulset.yaml). Read the description of the second service created. It's a headless service similar to the one explained by @jbndlr. It should allow you to get name resolution for each pod. The name would be something like podName.service.namespace.svc... .In statefulSet each pod will have the stable name that won't change, even if it is rescheduled to another node. – rrh Jun 29 '17 at 14:50
0

If you want to get all Pods running under a certain Service, make sure to use a headless Service (i.e. set clusterIP: None). Then, you can query your local DNS-Server for the Service and will receive A-Records for all Pods assigned to it:

---
apiVersion: v1
kind: Service
metadata:
  name: my-sv
  namespace: my-ns
  labels:
    app: my-app
spec:
  clusterIP: None
  selector:
    app: my-app

Then start your Pods (make sure to give app: labels for assignment) and query your DNS-Server from any of them:

kubectl exec -ti my-pod --namespace=my-ns -- /bin/bash
$ nslookup my-sv.my-ns.svc.cluster.local
Server:     10.255.3.10
Address:    10.255.3.10#53

Name:   my-sv.my-ns.svc.cluster.local
Address: 10.254.24.11
Name:   my-sv.my-ns.svc.cluster.local
Address: 10.254.5.73
Name:   my-sv.my-ns.svc.cluster.local
Address: 10.254.87.6
jbndlr
  • 4,965
  • 2
  • 21
  • 31
  • thank you @jbndlr for your reply, actually I think it might be useful in my case to keep the pods in different services. I can resole every other pods within the project using IP adresses but what I need is the resolution via the host name. – Mohammed Elmehdi EZ-GHARI Jun 29 '17 at 07:39