Repository: fiaas/k8s (language: python)

Issue:
Add simple entrypoint for in-cluster config with BoundServiceAccountTokenVolume support
Provide a simple, no parameters required, entrypoint (`k8s.config.use_in_cluster_config`) for configuring the client library following the recommendations for [accessing the API for pods running in a Kubernetes cluster](https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-from-a-pod)]

When configuring the client library in this manner, read the service account API token from file every 1 minute ([as recommended](https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.21.md#api-change-2)) to work with the [BoundServiceAccountTokenVolume feature](https://github.com/kubernetes/enhancements/tree/master/keps/sig-auth/1205-bound-service-account-tokens).

Closes #98

~I'm setting this as draft as I need to test this a bit before it is entirely ready to review.~


Discussion / hints:

Fix patch:
diff --git a/k8s/models/pod.py b/k8s/models/pod.py
index dd6294a..b4e1722 100644
--- a/k8s/models/pod.py
+++ b/k8s/models/pod.py
@@ -216,6 +216,7 @@ class PodSpec(Model):
     automountServiceAccountToken = Field(bool)
     imagePullSecrets = ListField(LocalObjectReference)
     initContainers = ListField(Container)
+    enableServiceLinks = Field(bool)
 
 
 class PodTemplateSpec(Model):


Test patch:
diff --git a/tests/k8s/test_pod.py b/tests/k8s/test_pod.py
index ca849be..790bb06 100644
--- a/tests/k8s/test_pod.py
+++ b/tests/k8s/test_pod.py
@@ -90,6 +90,7 @@ def test_get_or_create_pod_not_new(self, put, get):
                 'serviceAccount': 'default',
                 'serviceAccountName': 'default',
                 'terminationGracePeriodSeconds': 30,
+                'enableServiceLinks': True,
                 'volumes': [{
                     'name': 'my-name',
                     'secret': {