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

Allow services to detect other services in Kubernetes via enableServiceLinks #356

Open
tobybellwood opened this issue Aug 14, 2024 · 2 comments

Comments

@tobybellwood
Copy link
Member

In #289 we hardcoded the enableServiceLinks to true or false as per the previous templates. In practice, it may be more useful to allow a service to opt-in to having these variables created to aid in service discovery.

Setting enableServiceLinks: true in a kubernetes service creates a set of named env vars relating to the other services in the namespace.

Eg having a redis-7 service will create the following in any service that has servicelinks=true

REDIS_7_PORT=tcp://10.208.4.113:6379
REDIS_7_PORT_6379_TCP=tcp://10.208.4.113:6379
REDIS_7_PORT_6379_TCP_ADDR=10.208.4.113
REDIS_7_PORT_6379_TCP_PORT=6379
REDIS_7_PORT_6379_TCP_PROTO=tcp
REDIS_7_SERVICE_HOST=10.208.4.113
REDIS_7_SERVICE_PORT=6379
REDIS_7_SERVICE_PORT_6379_TCP=6379
@shreddedbacon
Copy link
Member

Is this something that solves a problem that exists?

@shreddedbacon
Copy link
Member

I ask mostly because the default in kubernetes is true, we just hardcoded it in our templates specifically now.
https://kubernetes.io/docs/tutorials/services/connect-applications-service/#accessing-the-service

But the k8s docs have this note which is why I'm pretty sure we set it to false in most templates.

If the service environment variables are not desired (because possible clashing with expected program ones, too many variables to process, only using DNS, etc) you can disable this mode by setting the enableServiceLinks flag to false on the pod spec.

Sure, we could make it optional, but it could cause problems for those unaware.

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

No branches or pull requests

2 participants