Adds 'useIpFromEnv' parameter to registrator #544
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why does it require to use IP from environment variable?
The
registratorwill 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).HostConfig.NetworkModevalue.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
registratoris provided with the capability to use IP address from the environment variables, then it helps to pass the service IP address (in theconsulperspective) 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_IPis the environment variable.Run the
registratorservice as shown:$ registrator -useIpFromEnv=POD_IP consul://<consul-agent-ip>:8500Add the following k8s spec configuration to the service to be registered:
When the
registratorrun with the flag-useIpFromEnv=POD_IP, theregistratoruses this IP address (the value ofPOD_IPenv) as container IP address and registers with consul agent service.