Skip to content

Commit b715a67

Browse files
authored
Fix in-cluster API discovery documentation (#36691)
* Fix in-cluster API discovery documentation The documentation incorrectly describes the way that client libraries discover the Kubernetes API server. While the `kubernetes.default.svc` DNS is provided as a convenience, **all** of the officially supported API clients use environment variables to discover the address of the API server. This change updates the documentation to reflect this. Signed-off-by: Oliver Gould <[email protected]> * Review feedback * Fixup Signed-off-by: Oliver Gould <[email protected]>
1 parent 4b74154 commit b715a67

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

content/en/docs/tasks/run-application/access-api-from-pod.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,18 @@ securely with the API server.
4242

4343
### Directly accessing the REST API
4444

45-
While running in a Pod, the Kubernetes apiserver is accessible via a Service named
46-
`kubernetes` in the `default` namespace. Therefore, Pods can use the
47-
`kubernetes.default.svc` hostname to query the API server. Official client libraries
48-
do this automatically.
45+
While running in a Pod, your container can create an HTTPS URL for the Kubernetes API
46+
server by fetching the `KUBERNETES_SERVICE_HOST` and `KUBERNETES_SERVICE_PORT_HTTPS`
47+
environment variables. The API server's in-cluster address is also published to a
48+
Service named `kubernetes` in the `default` namespace so that pods may reference
49+
`kubernetes.default.svc` as a DNS name for the local API server.
50+
51+
{{< note >}}
52+
Kubernetes does not guarantee that the API server has a valid certificate for
53+
the hostname `kubernetes.default.svc`;
54+
however, the control plane **is** expected to present a valid certificate for the
55+
hostname or IP address that `$KUBERNETES_SERVICE_HOST` represents.
56+
{{< /note >}}
4957

5058
The recommended way to authenticate to the API server is with a
5159
[service account](/docs/tasks/configure-pod-container/configure-service-account/)

0 commit comments

Comments
 (0)