File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 1515 V1Namespace ,
1616 V1Pod ,
1717 V1PodList ,
18- V1TokenRequestSpec ,
1918)
2019from kubernetes .client .rest import ApiException
2120from kubernetes .dynamic import DynamicClient
@@ -574,14 +573,15 @@ def get_warnet_user_service_accounts_in_namespace(namespace):
574573
575574
576575def 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
587587def can_delete_pods (namespace : Optional [str ] = None ) -> bool :
You can’t perform that action at this time.
0 commit comments