registrator auto-registers the docker containerized services to service discovery tools such as
etcd, etc. This service auto-registration of docker containerized services is much needed feature for the environments where the docker containers are managed by orchestration tools like kubernetes, etc.
The gliderlabs/registrator:master is customized to accept the pod IP from the environment variables.
Why does it require to use IP from environment variables?
registrator will register the docker containerized services with the service discovery tools by grabbing the container IP address and exposed ports from the docker inspect information (low-level information of docker object). But, the docker containers which are managed by the kubernetes will not show up the container IP address under docker inspect information. In some kubernetes cluster managed environments, the docker containers network information will be offloaded to another container whos reference is given under
In GKE (Google Container Engine), the docker containers will not show up container IP address either in the container inspect information or in the offloaded container inspect information.
How to use this customized
This example information is given based on the consul service discovery perspective.
POD_IP is the environment variable.
registrator service as shown:
$ registrator -useIpFromEnv=POD_IP consul://<consul-agent-ip>:8500
Add the following k8s spec configuration to the service to be registered:
... env: - name: POD_IP valueFrom: fieldRef: fieldPath: status.podIP ...
registrator run with the flag
registrator uses this IP address (the value of
POD_IP env) as container IP address and registers with consul agent service.