-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
The example in the Port definitions section shows the Pod manifest before the Service manifest.
While both orders work, the Discovering services section later mentions that creating the Service before Pods helps with environment variable setup.
Note:
When you have a Pod that needs to access a Service, and you are using the environment variable method to publish the port and cluster IP to the client Pods, you must create the Service before the client Pods come into existence. Otherwise, those client Pods won't have their environment variables populated.
If you only use DNS to discover the cluster IP for a Service, you don't need to worry about this ordering issue.
It would be more consistent to show the Service first in this example, matching the recommendation given later in the page.