Skip to content

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

@tobybellwood

Description

@tobybellwood

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions