mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #105508 from claudiubelu/tests/refactor-deployments
tests: Use E2E framework deployments
This commit is contained in:
commit
1f8084789e
@ -202,7 +202,6 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl
|
|||||||
etcdImage := imageutils.GetE2EImage(imageutils.Etcd)
|
etcdImage := imageutils.GetE2EImage(imageutils.Etcd)
|
||||||
podLabels := map[string]string{"app": "sample-apiserver", "apiserver": "true"}
|
podLabels := map[string]string{"app": "sample-apiserver", "apiserver": "true"}
|
||||||
replicas := int32(1)
|
replicas := int32(1)
|
||||||
zero := int64(0)
|
|
||||||
etcdLocalhostAddress := "127.0.0.1"
|
etcdLocalhostAddress := "127.0.0.1"
|
||||||
if framework.TestContext.ClusterIsIPv6() {
|
if framework.TestContext.ClusterIsIPv6() {
|
||||||
etcdLocalhostAddress = "::1"
|
etcdLocalhostAddress = "::1"
|
||||||
@ -250,31 +249,10 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
d := &appsv1.Deployment{
|
d := e2edeployment.NewDeployment(deploymentName, replicas, podLabels, "", "", appsv1.RollingUpdateDeploymentStrategyType)
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
d.Spec.Template.Spec.Containers = containers
|
||||||
Name: deploymentName,
|
d.Spec.Template.Spec.Volumes = volumes
|
||||||
Labels: podLabels,
|
|
||||||
},
|
|
||||||
Spec: appsv1.DeploymentSpec{
|
|
||||||
Replicas: &replicas,
|
|
||||||
Selector: &metav1.LabelSelector{
|
|
||||||
MatchLabels: podLabels,
|
|
||||||
},
|
|
||||||
Strategy: appsv1.DeploymentStrategy{
|
|
||||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
|
||||||
},
|
|
||||||
Template: v1.PodTemplateSpec{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Labels: podLabels,
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
TerminationGracePeriodSeconds: &zero,
|
|
||||||
Containers: containers,
|
|
||||||
Volumes: volumes,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
deployment, err := client.AppsV1().Deployments(namespace).Create(context.TODO(), d, metav1.CreateOptions{})
|
deployment, err := client.AppsV1().Deployments(namespace).Create(context.TODO(), d, metav1.CreateOptions{})
|
||||||
framework.ExpectNoError(err, "creating deployment %s in namespace %s", deploymentName, namespace)
|
framework.ExpectNoError(err, "creating deployment %s in namespace %s", deploymentName, namespace)
|
||||||
|
|
||||||
|
@ -266,7 +266,6 @@ func deployCustomResourceWebhookAndService(f *framework.Framework, image string,
|
|||||||
// Create the deployment of the webhook
|
// Create the deployment of the webhook
|
||||||
podLabels := map[string]string{"app": "sample-crd-conversion-webhook", "crd-webhook": "true"}
|
podLabels := map[string]string{"app": "sample-crd-conversion-webhook", "crd-webhook": "true"}
|
||||||
replicas := int32(1)
|
replicas := int32(1)
|
||||||
zero := int64(0)
|
|
||||||
mounts := []v1.VolumeMount{
|
mounts := []v1.VolumeMount{
|
||||||
{
|
{
|
||||||
Name: "crd-conversion-webhook-certs",
|
Name: "crd-conversion-webhook-certs",
|
||||||
@ -311,31 +310,10 @@ func deployCustomResourceWebhookAndService(f *framework.Framework, image string,
|
|||||||
Ports: []v1.ContainerPort{{ContainerPort: containerPort}},
|
Ports: []v1.ContainerPort{{ContainerPort: containerPort}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
d := &appsv1.Deployment{
|
d := e2edeployment.NewDeployment(deploymentCRDName, replicas, podLabels, "", "", appsv1.RollingUpdateDeploymentStrategyType)
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
d.Spec.Template.Spec.Containers = containers
|
||||||
Name: deploymentCRDName,
|
d.Spec.Template.Spec.Volumes = volumes
|
||||||
Labels: podLabels,
|
|
||||||
},
|
|
||||||
Spec: appsv1.DeploymentSpec{
|
|
||||||
Replicas: &replicas,
|
|
||||||
Selector: &metav1.LabelSelector{
|
|
||||||
MatchLabels: podLabels,
|
|
||||||
},
|
|
||||||
Strategy: appsv1.DeploymentStrategy{
|
|
||||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
|
||||||
},
|
|
||||||
Template: v1.PodTemplateSpec{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Labels: podLabels,
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
TerminationGracePeriodSeconds: &zero,
|
|
||||||
Containers: containers,
|
|
||||||
Volumes: volumes,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
deployment, err := client.AppsV1().Deployments(namespace).Create(context.TODO(), d, metav1.CreateOptions{})
|
deployment, err := client.AppsV1().Deployments(namespace).Create(context.TODO(), d, metav1.CreateOptions{})
|
||||||
framework.ExpectNoError(err, "creating deployment %s in namespace %s", deploymentCRDName, namespace)
|
framework.ExpectNoError(err, "creating deployment %s in namespace %s", deploymentCRDName, namespace)
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ import (
|
|||||||
"k8s.io/apiserver/pkg/storage/names"
|
"k8s.io/apiserver/pkg/storage/names"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
|
e2edeployment "k8s.io/kubernetes/test/e2e/framework/deployment"
|
||||||
e2emetrics "k8s.io/kubernetes/test/e2e/framework/metrics"
|
e2emetrics "k8s.io/kubernetes/test/e2e/framework/metrics"
|
||||||
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
|
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
|
||||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||||
@ -126,20 +127,7 @@ func getPodTemplateSpec(labels map[string]string) v1.PodTemplateSpec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newOwnerDeployment(f *framework.Framework, deploymentName string, labels map[string]string) *appsv1.Deployment {
|
func newOwnerDeployment(f *framework.Framework, deploymentName string, labels map[string]string) *appsv1.Deployment {
|
||||||
replicas := int32(2)
|
return e2edeployment.NewDeployment(deploymentName, 2, labels, "nginx", imageutils.GetE2EImage(imageutils.Nginx), appsv1.RollingUpdateDeploymentStrategyType)
|
||||||
return &appsv1.Deployment{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: deploymentName,
|
|
||||||
},
|
|
||||||
Spec: appsv1.DeploymentSpec{
|
|
||||||
Replicas: &replicas,
|
|
||||||
Selector: &metav1.LabelSelector{MatchLabels: labels},
|
|
||||||
Strategy: appsv1.DeploymentStrategy{
|
|
||||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
|
||||||
},
|
|
||||||
Template: getPodTemplateSpec(labels),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newOwnerRC(f *framework.Framework, name string, replicas int32, labels map[string]string) *v1.ReplicationController {
|
func newOwnerRC(f *framework.Framework, name string, replicas int32, labels map[string]string) *v1.ReplicationController {
|
||||||
|
@ -767,7 +767,6 @@ func deployWebhookAndService(f *framework.Framework, image string, certCtx *cert
|
|||||||
// Create the deployment of the webhook
|
// Create the deployment of the webhook
|
||||||
podLabels := map[string]string{"app": "sample-webhook", "webhook": "true"}
|
podLabels := map[string]string{"app": "sample-webhook", "webhook": "true"}
|
||||||
replicas := int32(1)
|
replicas := int32(1)
|
||||||
zero := int64(0)
|
|
||||||
mounts := []v1.VolumeMount{
|
mounts := []v1.VolumeMount{
|
||||||
{
|
{
|
||||||
Name: "webhook-certs",
|
Name: "webhook-certs",
|
||||||
@ -812,31 +811,10 @@ func deployWebhookAndService(f *framework.Framework, image string, certCtx *cert
|
|||||||
Ports: []v1.ContainerPort{{ContainerPort: containerPort}},
|
Ports: []v1.ContainerPort{{ContainerPort: containerPort}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
d := &appsv1.Deployment{
|
d := e2edeployment.NewDeployment(deploymentName, replicas, podLabels, "", "", appsv1.RollingUpdateDeploymentStrategyType)
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
d.Spec.Template.Spec.Containers = containers
|
||||||
Name: deploymentName,
|
d.Spec.Template.Spec.Volumes = volumes
|
||||||
Labels: podLabels,
|
|
||||||
},
|
|
||||||
Spec: appsv1.DeploymentSpec{
|
|
||||||
Replicas: &replicas,
|
|
||||||
Selector: &metav1.LabelSelector{
|
|
||||||
MatchLabels: podLabels,
|
|
||||||
},
|
|
||||||
Strategy: appsv1.DeploymentStrategy{
|
|
||||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
|
||||||
},
|
|
||||||
Template: v1.PodTemplateSpec{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Labels: podLabels,
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
TerminationGracePeriodSeconds: &zero,
|
|
||||||
Containers: containers,
|
|
||||||
Volumes: volumes,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
deployment, err := client.AppsV1().Deployments(namespace).Create(context.TODO(), d, metav1.CreateOptions{})
|
deployment, err := client.AppsV1().Deployments(namespace).Create(context.TODO(), d, metav1.CreateOptions{})
|
||||||
framework.ExpectNoError(err, "creating deployment %s in namespace %s", deploymentName, namespace)
|
framework.ExpectNoError(err, "creating deployment %s in namespace %s", deploymentName, namespace)
|
||||||
ginkgo.By("Wait for the deployment to be ready")
|
ginkgo.By("Wait for the deployment to be ready")
|
||||||
|
@ -192,9 +192,6 @@ var _ = SIGDescribe("Deployment", func() {
|
|||||||
testDeploymentNoReplicas := int32(0)
|
testDeploymentNoReplicas := int32(0)
|
||||||
testDeploymentLabels := map[string]string{"test-deployment-static": "true"}
|
testDeploymentLabels := map[string]string{"test-deployment-static": "true"}
|
||||||
testDeploymentLabelsFlat := "test-deployment-static=true"
|
testDeploymentLabelsFlat := "test-deployment-static=true"
|
||||||
testDeploymentLabelSelectors := metav1.LabelSelector{
|
|
||||||
MatchLabels: testDeploymentLabels,
|
|
||||||
}
|
|
||||||
w := &cache.ListWatch{
|
w := &cache.ListWatch{
|
||||||
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
|
||||||
options.LabelSelector = testDeploymentLabelsFlat
|
options.LabelSelector = testDeploymentLabelsFlat
|
||||||
@ -205,29 +202,13 @@ var _ = SIGDescribe("Deployment", func() {
|
|||||||
framework.ExpectNoError(err, "failed to list Deployments")
|
framework.ExpectNoError(err, "failed to list Deployments")
|
||||||
|
|
||||||
ginkgo.By("creating a Deployment")
|
ginkgo.By("creating a Deployment")
|
||||||
testDeployment := appsv1.Deployment{
|
testDeployment := e2edeployment.NewDeployment(
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
testDeploymentName, testDeploymentDefaultReplicas, testDeploymentLabels,
|
||||||
Name: testDeploymentName,
|
testDeploymentName, testDeploymentInitialImage, appsv1.RollingUpdateDeploymentStrategyType)
|
||||||
Labels: map[string]string{"test-deployment-static": "true"},
|
testDeployment.ObjectMeta.Labels = map[string]string{"test-deployment-static": "true"}
|
||||||
},
|
testDeployment.Spec.Template.Spec.TerminationGracePeriodSeconds = &one
|
||||||
Spec: appsv1.DeploymentSpec{
|
|
||||||
Replicas: &testDeploymentDefaultReplicas,
|
_, err = f.ClientSet.AppsV1().Deployments(testNamespaceName).Create(context.TODO(), testDeployment, metav1.CreateOptions{})
|
||||||
Selector: &testDeploymentLabelSelectors,
|
|
||||||
Template: v1.PodTemplateSpec{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Labels: testDeploymentLabelSelectors.MatchLabels,
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
TerminationGracePeriodSeconds: &one,
|
|
||||||
Containers: []v1.Container{{
|
|
||||||
Name: testDeploymentName,
|
|
||||||
Image: testDeploymentInitialImage,
|
|
||||||
}},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
_, err = f.ClientSet.AppsV1().Deployments(testNamespaceName).Create(context.TODO(), &testDeployment, metav1.CreateOptions{})
|
|
||||||
framework.ExpectNoError(err, "failed to create Deployment %v in namespace %v", testDeploymentName, testNamespaceName)
|
framework.ExpectNoError(err, "failed to create Deployment %v in namespace %v", testDeploymentName, testNamespaceName)
|
||||||
|
|
||||||
ginkgo.By("waiting for Deployment to be created")
|
ginkgo.By("waiting for Deployment to be created")
|
||||||
|
@ -57,6 +57,7 @@ import (
|
|||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
|
e2edeployment "k8s.io/kubernetes/test/e2e/framework/deployment"
|
||||||
e2eservice "k8s.io/kubernetes/test/e2e/framework/service"
|
e2eservice "k8s.io/kubernetes/test/e2e/framework/service"
|
||||||
e2etestfiles "k8s.io/kubernetes/test/e2e/framework/testfiles"
|
e2etestfiles "k8s.io/kubernetes/test/e2e/framework/testfiles"
|
||||||
testutils "k8s.io/kubernetes/test/utils"
|
testutils "k8s.io/kubernetes/test/utils"
|
||||||
@ -1101,35 +1102,14 @@ func generateBacksideHTTPSServiceSpec() *v1.Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func generateBacksideHTTPSDeploymentSpec() *appsv1.Deployment {
|
func generateBacksideHTTPSDeploymentSpec() *appsv1.Deployment {
|
||||||
return &appsv1.Deployment{
|
labels := map[string]string{"app": "echoheaders-https"}
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
d := e2edeployment.NewDeployment("echoheaders-https", 0, labels, "echoheaders-https", imageutils.GetE2EImage(imageutils.EchoServer), appsv1.RollingUpdateDeploymentStrategyType)
|
||||||
Name: "echoheaders-https",
|
d.Spec.Replicas = nil
|
||||||
},
|
d.Spec.Template.Spec.Containers[0].Ports = []v1.ContainerPort{{
|
||||||
Spec: appsv1.DeploymentSpec{
|
ContainerPort: 8443,
|
||||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{
|
Name: "echo-443",
|
||||||
"app": "echoheaders-https",
|
}}
|
||||||
}},
|
return d
|
||||||
Template: v1.PodTemplateSpec{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Labels: map[string]string{
|
|
||||||
"app": "echoheaders-https",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: "echoheaders-https",
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.EchoServer),
|
|
||||||
Ports: []v1.ContainerPort{{
|
|
||||||
ContainerPort: 8443,
|
|
||||||
Name: "echo-443",
|
|
||||||
}},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetUpBacksideHTTPSIngress sets up deployment, service and ingress with backside HTTPS configured.
|
// SetUpBacksideHTTPSIngress sets up deployment, service and ingress with backside HTTPS configured.
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
rbacv1 "k8s.io/api/rbac/v1"
|
rbacv1 "k8s.io/api/rbac/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
|
e2edeployment "k8s.io/kubernetes/test/e2e/framework/deployment"
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
|
|
||||||
gcm "google.golang.org/api/monitoring/v3"
|
gcm "google.golang.org/api/monitoring/v3"
|
||||||
@ -104,26 +105,10 @@ func StackdriverExporterDeployment(name, namespace string, replicas int32, conta
|
|||||||
podSpec.Containers = append(podSpec.Containers, stackdriverExporterContainerSpec(containerSpec.Name, namespace, containerSpec.MetricName, containerSpec.MetricValue))
|
podSpec.Containers = append(podSpec.Containers, stackdriverExporterContainerSpec(containerSpec.Name, namespace, containerSpec.MetricName, containerSpec.MetricValue))
|
||||||
}
|
}
|
||||||
|
|
||||||
return &appsv1.Deployment{
|
d := e2edeployment.NewDeployment(name, replicas, map[string]string{"name": name}, "", "", appsv1.RollingUpdateDeploymentStrategyType)
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
d.ObjectMeta.Namespace = namespace
|
||||||
Name: name,
|
d.Spec.Template.Spec = podSpec
|
||||||
Namespace: namespace,
|
return d
|
||||||
},
|
|
||||||
Spec: appsv1.DeploymentSpec{
|
|
||||||
Selector: &metav1.LabelSelector{
|
|
||||||
MatchLabels: map[string]string{"name": name},
|
|
||||||
},
|
|
||||||
Template: v1.PodTemplateSpec{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Labels: map[string]string{
|
|
||||||
"name": name,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Spec: podSpec,
|
|
||||||
},
|
|
||||||
Replicas: &replicas,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StackdriverExporterPod is a Pod of simple application that exports a metric of fixed value to
|
// StackdriverExporterPod is a Pod of simple application that exports a metric of fixed value to
|
||||||
@ -188,26 +173,10 @@ func stackdriverExporterContainerSpec(name string, namespace string, metricName
|
|||||||
// one exposing a metric in prometheus format and second a prometheus-to-sd container
|
// one exposing a metric in prometheus format and second a prometheus-to-sd container
|
||||||
// that scrapes the metric and pushes it to stackdriver.
|
// that scrapes the metric and pushes it to stackdriver.
|
||||||
func PrometheusExporterDeployment(name, namespace string, replicas int32, metricValue int64) *appsv1.Deployment {
|
func PrometheusExporterDeployment(name, namespace string, replicas int32, metricValue int64) *appsv1.Deployment {
|
||||||
return &appsv1.Deployment{
|
d := e2edeployment.NewDeployment(name, replicas, map[string]string{"name": name}, "", "", appsv1.RollingUpdateDeploymentStrategyType)
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
d.ObjectMeta.Namespace = namespace
|
||||||
Name: name,
|
d.Spec.Template.Spec = prometheusExporterPodSpec(CustomMetricName, metricValue, 8080)
|
||||||
Namespace: namespace,
|
return d
|
||||||
},
|
|
||||||
Spec: appsv1.DeploymentSpec{
|
|
||||||
Selector: &metav1.LabelSelector{
|
|
||||||
MatchLabels: map[string]string{"name": name},
|
|
||||||
},
|
|
||||||
Template: v1.PodTemplateSpec{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Labels: map[string]string{
|
|
||||||
"name": name,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Spec: prometheusExporterPodSpec(CustomMetricName, metricValue, 8080),
|
|
||||||
},
|
|
||||||
Replicas: &replicas,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func prometheusExporterPodSpec(metricName string, metricValue int64, port int32) v1.PodSpec {
|
func prometheusExporterPodSpec(metricName string, metricValue int64, port int32) v1.PodSpec {
|
||||||
|
@ -68,38 +68,16 @@ func iperf2ServerDeployment(client clientset.Interface, namespace string, isIPV6
|
|||||||
if isIPV6 {
|
if isIPV6 {
|
||||||
args = append(args, "-V")
|
args = append(args, "-V")
|
||||||
}
|
}
|
||||||
deploymentSpec := &appsv1.Deployment{
|
deploymentSpec := e2edeployment.NewDeployment(
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
"iperf2-server-deployment", replicas, labels, "iperf2-server",
|
||||||
Name: "iperf2-server-deployment",
|
imageutils.GetE2EImage(imageutils.Agnhost), appsv1.RollingUpdateDeploymentStrategyType)
|
||||||
Labels: labels,
|
deploymentSpec.Spec.Template.Spec.TerminationGracePeriodSeconds = &one
|
||||||
},
|
deploymentSpec.Spec.Template.Spec.Containers[0].Command = []string{"iperf"}
|
||||||
Spec: appsv1.DeploymentSpec{
|
deploymentSpec.Spec.Template.Spec.Containers[0].Args = args
|
||||||
Replicas: &replicas,
|
deploymentSpec.Spec.Template.Spec.Containers[0].Ports = []v1.ContainerPort{
|
||||||
Selector: &metav1.LabelSelector{
|
{
|
||||||
MatchLabels: labels,
|
ContainerPort: iperf2Port,
|
||||||
},
|
Protocol: v1.ProtocolTCP,
|
||||||
Template: v1.PodTemplateSpec{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Labels: labels,
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
TerminationGracePeriodSeconds: &one,
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: "iperf2-server",
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
|
||||||
Command: []string{"iperf"},
|
|
||||||
Args: args,
|
|
||||||
Ports: []v1.ContainerPort{
|
|
||||||
{
|
|
||||||
ContainerPort: iperf2Port,
|
|
||||||
Protocol: v1.ProtocolTCP,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ import (
|
|||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
|
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
|
e2edeployment "k8s.io/kubernetes/test/e2e/framework/deployment"
|
||||||
e2eingress "k8s.io/kubernetes/test/e2e/framework/ingress"
|
e2eingress "k8s.io/kubernetes/test/e2e/framework/ingress"
|
||||||
"k8s.io/kubernetes/test/e2e/framework/providers/gce"
|
"k8s.io/kubernetes/test/e2e/framework/providers/gce"
|
||||||
)
|
)
|
||||||
@ -445,39 +446,21 @@ func generateScaleTestServiceSpec(suffix string) *v1.Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func generateScaleTestBackendDeploymentSpec(numReplicas int32) *appsv1.Deployment {
|
func generateScaleTestBackendDeploymentSpec(numReplicas int32) *appsv1.Deployment {
|
||||||
return &appsv1.Deployment{
|
d := e2edeployment.NewDeployment(
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
scaleTestBackendName, numReplicas, scaleTestLabels, scaleTestBackendName,
|
||||||
Name: scaleTestBackendName,
|
imageutils.GetE2EImage(imageutils.EchoServer), appsv1.RollingUpdateDeploymentStrategyType)
|
||||||
},
|
d.Spec.Template.Spec.Containers[0].Ports = []v1.ContainerPort{{ContainerPort: 8080}}
|
||||||
Spec: appsv1.DeploymentSpec{
|
d.Spec.Template.Spec.Containers[0].ReadinessProbe = &v1.Probe{
|
||||||
Replicas: &numReplicas,
|
ProbeHandler: v1.ProbeHandler{
|
||||||
Selector: &metav1.LabelSelector{MatchLabels: scaleTestLabels},
|
HTTPGet: &v1.HTTPGetAction{
|
||||||
Template: v1.PodTemplateSpec{
|
Port: intstr.FromInt(8080),
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
Path: "/healthz",
|
||||||
Labels: scaleTestLabels,
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: scaleTestBackendName,
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.EchoServer),
|
|
||||||
Ports: []v1.ContainerPort{{ContainerPort: 8080}},
|
|
||||||
ReadinessProbe: &v1.Probe{
|
|
||||||
ProbeHandler: v1.ProbeHandler{
|
|
||||||
HTTPGet: &v1.HTTPGetAction{
|
|
||||||
Port: intstr.FromInt(8080),
|
|
||||||
Path: "/healthz",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
FailureThreshold: 10,
|
|
||||||
PeriodSeconds: 1,
|
|
||||||
SuccessThreshold: 1,
|
|
||||||
TimeoutSeconds: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
FailureThreshold: 10,
|
||||||
|
PeriodSeconds: 1,
|
||||||
|
SuccessThreshold: 1,
|
||||||
|
TimeoutSeconds: 1,
|
||||||
}
|
}
|
||||||
|
return d
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user