Skip to content

Commit 24843ac

Browse files
authored
Merge pull request #797 from bitcoin-dev-project/token-duration
fix token duration
2 parents f35286d + d4634b3 commit 24843ac

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/warnet/k8s.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
V1Namespace,
1616
V1Pod,
1717
V1PodList,
18-
V1TokenRequestSpec,
1918
)
2019
from kubernetes.client.rest import ApiException
2120
from kubernetes.dynamic import DynamicClient
@@ -574,14 +573,15 @@ def get_warnet_user_service_accounts_in_namespace(namespace):
574573

575574

576575
def get_token_for_service_acount(sa, duration):
577-
sclient = get_static_client()
578-
spec = V1TokenRequestSpec(
579-
audiences=["https://kubernetes.default.svc"], expiration_seconds=duration
580-
)
581-
resp = sclient.create_namespaced_service_account_token(
582-
name=sa.metadata.name, namespace=sa.metadata.namespace, body=spec
576+
# # The Kubernetes Python client’s TokenRequest calls were routed through
577+
# # DigitalOcean’s konnectivity path, which overrides the requested audience
578+
# # and enforces a 1-hour max expiration. `kubectl create token` uses a
579+
# # different control-plane path that preserves the default API audience and allows longer durations.
580+
# # `sclient.create_namespaced_service_account_token()` will NOT work :-(
581+
command = (
582+
f"kubectl create token {sa.metadata.name} -n {sa.metadata.namespace} --duration={duration}s"
583583
)
584-
return resp.status.token
584+
return run_command(command)
585585

586586

587587
def can_delete_pods(namespace: Optional[str] = None) -> bool:

0 commit comments

Comments
 (0)