In this guide, we will enable the Talos feature to access the Talos API from within Kubernetes.
Enable the feature
This feature can only be enabled on control plane machines.
Enable the feature via machine configuration, specifying the Kubernetes namespaces
from which the Talos API can be accessed and the allowed Talos API roles. How you
configure this depends on your Talos version.
On Talos v1.14 and above, use the KubeTalosAPIAccessConfig document:
For Talos versions earlier than v1.14, use the kubernetesTalosAPIAccess field under machine.features:
Inject Talos ServiceAccount into manifests
Create the following manifest file deployment.yaml. The pod uses the Kubernetes Downward API to discover the IP of the node it’s running on:
Use the talosctl inject serviceaccount command to inject the Talos ServiceAccount into the manifest:
Inspect the generated manifest:
As you can notice, your deployment manifest is now injected with the Talos ServiceAccount.
Test API access
Apply the new manifest into the default namespace:
Follow the logs of the pods belonging to the deployment:
You’ll see a repeating output similar to the following:
This means that the pod can talk to the Talos API of the node it’s running on successfully, whichever node that happens to be.