Finding the Redis service

WIth the Redis service up and running, we can now use it from our own Pod. As we mentioned previously, there are two ways to locate the service: an environment variable with a name based on the service will be set with the host IP and port, or you can use a DNS entry based on the name of the service.

The environment variables will only be set on Pods that are created after the service. If you still have the flask Pod up and running as per our previous example, then it will not show the environment variables. If we create a new Pod, even a temporary one, then it will include the service in the environment variables. This is because environment variables are set based on the state of Kubernetes at the time that the ...

Get Kubernetes for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.