From e448604c7f59183d5c9bca82f014202661b3b896 Mon Sep 17 00:00:00 2001 From: Brian Grant Date: Mon, 24 Nov 2014 18:01:56 +0000 Subject: [PATCH] Clarify format of service environment variables. Fixes #1936. --- docs/services.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/services.md b/docs/services.md index 4a367a49ee5..3a29d21b3ff 100644 --- a/docs/services.md +++ b/docs/services.md @@ -62,8 +62,21 @@ according to a policy, but the only policy supported for now is round-robin). When a `pod` is scheduled, the master adds a set of environment variables for each active `service`. We support both [Docker-links-compatible](https://docs.docker.com/userguide/dockerlinks/) -variables and simpler {SVCNAME}_SERVICE_HOST and {SVCNAME}_SERVICE_PORT -variables. This does imply an ordering requirement - any `service` that a `pod` +variables (see [makeLinkVariables](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/pkg/kubelet/envvars/envvars.go#L49)) and simpler {SVCNAME}_SERVICE_HOST and {SVCNAME}_SERVICE_PORT +variables, where the service name is upper-cased and dashes are converted to underscores. +For example, the service "redis-master" exposed on TCP port 6379 and allocated IP address +10.0.0.11 produces the following environment variables: +``` +REDIS_MASTER_SERVICE_HOST=10.0.0.11 +REDIS_MASTER_SERVICE_PORT=6379 +REDIS_MASTER_PORT=tcp://10.0.0.11:6379 +REDIS_MASTER_PORT_6379_TCP=tcp://10.0.0.11:6379 +REDIS_MASTER_PORT_6379_TCP_PROTO=tcp +REDIS_MASTER_PORT_6379_TCP_PORT=6379 +REDIS_MASTER_PORT_6379_TCP_ADDR=10.0.0.11 +``` + +This does imply an ordering requirement - any `service` that a `pod` wants to access must be created before the `pod` itself, or else the environment variables will not be populated. This restriction will be removed once DNS for `services` is supported.