Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds 'useIpFromEnv' parameter to registrator #544

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ganeshkaila
Copy link

Why does it require to use IP from environment variable?

The 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).

  • The docker containers which are managed by the kubernetes will not show up the container IP address under docker inspect information. In such environments, the docker containers network information will be offloaded to another container who's reference will be given under HostConfig.NetworkMode value.

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.

If the registrator is provided with the capability to use IP address from the environment variables, then it helps to pass the service IP address (in the consul perspective) whether the pod or node IP address as an environment variable based on the requirement.

How to use the flag useIpFromEnv?

This example information is given based on the consul service discovery perspective.

The POD_IP is the environment variable.

Run the 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
...

When the registrator run with the flag -useIpFromEnv=POD_IP, the registrator uses this IP address (the value of POD_IP env) as container IP address and registers with consul agent service.

* Adds the capability to read container IP from environment variable for registration with Consul

* Updated documentation for new parameter 'useIpFromEnv'
@progrium
Copy link
Contributor

progrium commented Sep 1, 2017

I never liked that we never switched to purely env based configuration. I would prefer we use environment. As such, I think this could be simplified by just having an environment variable that, if set, would be used for IP. No need for argument to specify what environment variable. Also, thanks for adding to the docs.

@shubhamitc
Copy link

do we have an image for this pull request?

shubhamitc pushed a commit to shubhamitc/registrator that referenced this pull request Jan 14, 2020
shubhamitc pushed a commit to shubhamitc/registrator that referenced this pull request Jan 14, 2020
@shubhamitc shubhamitc mentioned this pull request Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants