React when a pod is created (hook)

6/14/2018

I'd like to know if it's possible to get information from a pod when it's just created.

I'm spending time in developing a kubernetes controller process that reacts itself when a pod is created in cluster.

When a pod is just created, the service has to be able to get some basic information from pod. For example, ip, annotations...

I'd like to use a java service.

Any ideas?

-- Jordi
kubernetes

2 Answers

6/14/2018

well, if you use kubernetes API client you can just watch on changes for all pods and then get their details (assuming you have granted RBAC auth)

-- Radek 'Goblin' Pieczonka
Source: StackOverflow

6/14/2018

You can use kubernetes

api-server

to get information regarding

endpoints (service)

. Kubernetes expose its API via REST so, you can use anything to communicate. Also, verify the results using 'kubectl' tool while development. For example, if you want to monitor pods related to service say, myservice.

kubectl get endpoints <myservice_pod> --watch

This will notify you with any activity with pods related to myservice. IMO, in java you have to use polling mechanism to mimic --watch functionality.

-- Prateek Jain
Source: StackOverflow