|
|
|
@ -181,7 +181,8 @@ class KubernetesServerRunner(base_runner.KubernetesBaseRunner): |
|
|
|
|
reuse_service=False, |
|
|
|
|
reuse_namespace=False, |
|
|
|
|
namespace_template=None, |
|
|
|
|
debug_use_port_forwarding=False): |
|
|
|
|
debug_use_port_forwarding=False, |
|
|
|
|
enable_workload_identity=False): |
|
|
|
|
super().__init__(k8s_namespace, namespace_template, reuse_namespace) |
|
|
|
|
|
|
|
|
|
# Settings |
|
|
|
@ -200,10 +201,16 @@ class KubernetesServerRunner(base_runner.KubernetesBaseRunner): |
|
|
|
|
self.service_template = service_template |
|
|
|
|
self.reuse_service = reuse_service |
|
|
|
|
self.debug_use_port_forwarding = debug_use_port_forwarding |
|
|
|
|
self.enable_workload_identity = enable_workload_identity |
|
|
|
|
# Service account settings: |
|
|
|
|
# Kubernetes service account |
|
|
|
|
if self.enable_workload_identity: |
|
|
|
|
self.service_account_name = service_account_name or deployment_name |
|
|
|
|
self.service_account_template = service_account_template |
|
|
|
|
else: |
|
|
|
|
self.service_account_name = None |
|
|
|
|
self.service_account_template = None |
|
|
|
|
|
|
|
|
|
# GCP. |
|
|
|
|
self.gcp_project = gcp_project |
|
|
|
|
self.gcp_ui_url = gcp_api_manager.gcp_ui_url |
|
|
|
@ -271,6 +278,7 @@ class KubernetesServerRunner(base_runner.KubernetesBaseRunner): |
|
|
|
|
test_port=test_port) |
|
|
|
|
self._wait_service_neg(self.service_name, test_port) |
|
|
|
|
|
|
|
|
|
if self.enable_workload_identity: |
|
|
|
|
# Allow Kubernetes service account to use the GCP service account |
|
|
|
|
# identity. |
|
|
|
|
self._grant_workload_identity_user( |
|
|
|
@ -351,7 +359,7 @@ class KubernetesServerRunner(base_runner.KubernetesBaseRunner): |
|
|
|
|
if (self.service and not self.reuse_service) or force: |
|
|
|
|
self._delete_service(self.service_name) |
|
|
|
|
self.service = None |
|
|
|
|
if self.service_account or force: |
|
|
|
|
if self.enable_workload_identity and (self.service_account or force): |
|
|
|
|
self._revoke_workload_identity_user( |
|
|
|
|
gcp_iam=self.gcp_iam, |
|
|
|
|
gcp_service_account=self.gcp_service_account, |
|
|
|
|