xDS interop: Generate deployment_id match label (#30596)

This fixes an issue with KubernetesNamespace.list_deployment_pods()
as well as the deployment itself would select incorrect pods
when multiple deployments share the same namespace.
pull/30602/head
Sergii Tkachenko 2 years ago committed by GitHub
parent e130c7dce3
commit 7712f93805
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      tools/run_tests/xds_k8s_test_driver/framework/test_app/runners/k8s/k8s_base_runner.py
  2. 3
      tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/client-secure.deployment.yaml
  3. 3
      tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/client.deployment.yaml
  4. 3
      tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/server-secure.deployment.yaml
  5. 3
      tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/server.deployment.yaml

@ -25,6 +25,7 @@ import yaml
import framework.helpers.datetime
import framework.helpers.highlighter
import framework.helpers.rand
from framework.infrastructure import gcp
from framework.infrastructure import k8s
from framework.test_app.runners import base_runner
@ -198,6 +199,12 @@ class KubernetesBaseRunner(base_runner.BaseRunner):
return resource
def _create_deployment(self, template, **kwargs) -> k8s.V1Deployment:
# Automatically apply random deployment_id to use in the matchLabels
# to prevent selecting pods in the same namespace belonging to
# a different deployment.
if 'deployment_id' not in kwargs:
kwargs['deployment_id'] = framework.helpers.rand.rand_string(
lowercase=True)
deployment = self._create_from_template(template, **kwargs)
if not isinstance(deployment, k8s.V1Deployment):
raise _RunnerError('Expected V1Deployment to be created '

@ -6,16 +6,19 @@ metadata:
namespace: ${namespace_name}
labels:
app: ${deployment_name}
deployment_id: ${deployment_id}
owner: xds-k8s-interop-test
spec:
replicas: 1
selector:
matchLabels:
app: ${deployment_name}
deployment_id: ${deployment_id}
template:
metadata:
labels:
app: ${deployment_name}
deployment_id: ${deployment_id}
owner: xds-k8s-interop-test
annotations:
security.cloud.google.com/use-workload-certificates: ""

@ -6,16 +6,19 @@ metadata:
namespace: ${namespace_name}
labels:
app: ${deployment_name}
deployment_id: ${deployment_id}
owner: xds-k8s-interop-test
spec:
replicas: 1
selector:
matchLabels:
app: ${deployment_name}
deployment_id: ${deployment_id}
template:
metadata:
labels:
app: ${deployment_name}
deployment_id: ${deployment_id}
owner: xds-k8s-interop-test
spec:
% if service_account_name:

@ -6,18 +6,21 @@ metadata:
namespace: ${namespace_name}
labels:
app: ${deployment_name}
deployment_id: ${deployment_id}
owner: xds-k8s-interop-test
spec:
replicas: ${replica_count}
selector:
matchLabels:
app: ${deployment_name}
deployment_id: ${deployment_id}
template:
metadata:
annotations:
security.cloud.google.com/use-workload-certificates: ""
labels:
app: ${deployment_name}
deployment_id: ${deployment_id}
owner: xds-k8s-interop-test
spec:
serviceAccountName: ${service_account_name}

@ -6,16 +6,19 @@ metadata:
namespace: ${namespace_name}
labels:
app: ${deployment_name}
deployment_id: ${deployment_id}
owner: xds-k8s-interop-test
spec:
replicas: ${replica_count}
selector:
matchLabels:
app: ${deployment_name}
deployment_id: ${deployment_id}
template:
metadata:
labels:
app: ${deployment_name}
deployment_id: ${deployment_id}
owner: xds-k8s-interop-test
spec:
% if service_account_name:

Loading…
Cancel
Save