mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
tests: Refactors agnhost image pod usage - network
A previous commit created a few agnhost related functions that creates agnhost pods / containers for general purposes. Refactors tests to use those functions.
This commit is contained in:
parent
131f42d263
commit
d37cbeb388
@ -134,7 +134,7 @@ var _ = SIGDescribe("Conntrack", func() {
|
|||||||
|
|
||||||
// Create a pod in one node to create the UDP traffic against the NodePort service every 5 seconds
|
// Create a pod in one node to create the UDP traffic against the NodePort service every 5 seconds
|
||||||
ginkgo.By("creating a client pod for probing the service " + serviceName)
|
ginkgo.By("creating a client pod for probing the service " + serviceName)
|
||||||
clientPod := newAgnhostPod(podClient, "")
|
clientPod := e2epod.NewAgnhostPod(ns, podClient, nil, nil, nil)
|
||||||
clientPod.Spec.NodeName = clientNodeInfo.name
|
clientPod.Spec.NodeName = clientNodeInfo.name
|
||||||
cmd := fmt.Sprintf(`date; for i in $(seq 1 3000); do echo "$(date) Try: ${i}"; echo hostname | nc -u -w 5 -p %d %s %d; echo; done`, srcPort, serverNodeInfo.nodeIP, udpService.Spec.Ports[0].NodePort)
|
cmd := fmt.Sprintf(`date; for i in $(seq 1 3000); do echo "$(date) Try: ${i}"; echo hostname | nc -u -w 5 -p %d %s %d; echo; done`, srcPort, serverNodeInfo.nodeIP, udpService.Spec.Ports[0].NodePort)
|
||||||
clientPod.Spec.Containers[0].Command = []string{"/bin/sh", "-c", cmd}
|
clientPod.Spec.Containers[0].Command = []string{"/bin/sh", "-c", cmd}
|
||||||
@ -148,7 +148,7 @@ var _ = SIGDescribe("Conntrack", func() {
|
|||||||
|
|
||||||
// Add a backend pod to the service in the other node
|
// Add a backend pod to the service in the other node
|
||||||
ginkgo.By("creating a backend pod " + podBackend1 + " for the service " + serviceName)
|
ginkgo.By("creating a backend pod " + podBackend1 + " for the service " + serviceName)
|
||||||
serverPod1 := newAgnhostPod(podBackend1, "netexec", fmt.Sprintf("--udp-port=%d", 80))
|
serverPod1 := e2epod.NewAgnhostPod(ns, podBackend1, nil, nil, nil, "netexec", fmt.Sprintf("--udp-port=%d", 80))
|
||||||
serverPod1.Labels = udpJig.Labels
|
serverPod1.Labels = udpJig.Labels
|
||||||
serverPod1.Spec.NodeName = serverNodeInfo.name
|
serverPod1.Spec.NodeName = serverNodeInfo.name
|
||||||
fr.PodClient().CreateSync(serverPod1)
|
fr.PodClient().CreateSync(serverPod1)
|
||||||
@ -172,7 +172,7 @@ var _ = SIGDescribe("Conntrack", func() {
|
|||||||
|
|
||||||
// Create a second pod
|
// Create a second pod
|
||||||
ginkgo.By("creating a second backend pod " + podBackend2 + " for the service " + serviceName)
|
ginkgo.By("creating a second backend pod " + podBackend2 + " for the service " + serviceName)
|
||||||
serverPod2 := newAgnhostPod(podBackend2, "netexec", fmt.Sprintf("--udp-port=%d", 80))
|
serverPod2 := e2epod.NewAgnhostPod(ns, podBackend2, nil, nil, nil, "netexec", fmt.Sprintf("--udp-port=%d", 80))
|
||||||
serverPod2.Labels = udpJig.Labels
|
serverPod2.Labels = udpJig.Labels
|
||||||
serverPod2.Spec.NodeName = serverNodeInfo.name
|
serverPod2.Spec.NodeName = serverNodeInfo.name
|
||||||
fr.PodClient().CreateSync(serverPod2)
|
fr.PodClient().CreateSync(serverPod2)
|
||||||
@ -214,7 +214,7 @@ var _ = SIGDescribe("Conntrack", func() {
|
|||||||
|
|
||||||
// Create a pod in one node to create the UDP traffic against the ClusterIP service every 5 seconds
|
// Create a pod in one node to create the UDP traffic against the ClusterIP service every 5 seconds
|
||||||
ginkgo.By("creating a client pod for probing the service " + serviceName)
|
ginkgo.By("creating a client pod for probing the service " + serviceName)
|
||||||
clientPod := newAgnhostPod(podClient, "")
|
clientPod := e2epod.NewAgnhostPod(ns, podClient, nil, nil, nil)
|
||||||
clientPod.Spec.NodeName = clientNodeInfo.name
|
clientPod.Spec.NodeName = clientNodeInfo.name
|
||||||
cmd := fmt.Sprintf(`date; for i in $(seq 1 3000); do echo "$(date) Try: ${i}"; echo hostname | nc -u -w 5 -p %d %s %d; echo; done`, srcPort, udpService.Spec.ClusterIP, udpService.Spec.Ports[0].Port)
|
cmd := fmt.Sprintf(`date; for i in $(seq 1 3000); do echo "$(date) Try: ${i}"; echo hostname | nc -u -w 5 -p %d %s %d; echo; done`, srcPort, udpService.Spec.ClusterIP, udpService.Spec.Ports[0].Port)
|
||||||
clientPod.Spec.Containers[0].Command = []string{"/bin/sh", "-c", cmd}
|
clientPod.Spec.Containers[0].Command = []string{"/bin/sh", "-c", cmd}
|
||||||
@ -228,7 +228,7 @@ var _ = SIGDescribe("Conntrack", func() {
|
|||||||
|
|
||||||
// Add a backend pod to the service in the other node
|
// Add a backend pod to the service in the other node
|
||||||
ginkgo.By("creating a backend pod " + podBackend1 + " for the service " + serviceName)
|
ginkgo.By("creating a backend pod " + podBackend1 + " for the service " + serviceName)
|
||||||
serverPod1 := newAgnhostPod(podBackend1, "netexec", fmt.Sprintf("--udp-port=%d", 80))
|
serverPod1 := e2epod.NewAgnhostPod(ns, podBackend1, nil, nil, nil, "netexec", fmt.Sprintf("--udp-port=%d", 80))
|
||||||
serverPod1.Labels = udpJig.Labels
|
serverPod1.Labels = udpJig.Labels
|
||||||
serverPod1.Spec.NodeName = serverNodeInfo.name
|
serverPod1.Spec.NodeName = serverNodeInfo.name
|
||||||
fr.PodClient().CreateSync(serverPod1)
|
fr.PodClient().CreateSync(serverPod1)
|
||||||
@ -252,7 +252,7 @@ var _ = SIGDescribe("Conntrack", func() {
|
|||||||
|
|
||||||
// Create a second pod
|
// Create a second pod
|
||||||
ginkgo.By("creating a second backend pod " + podBackend2 + " for the service " + serviceName)
|
ginkgo.By("creating a second backend pod " + podBackend2 + " for the service " + serviceName)
|
||||||
serverPod2 := newAgnhostPod(podBackend2, "netexec", fmt.Sprintf("--udp-port=%d", 80))
|
serverPod2 := e2epod.NewAgnhostPod(ns, podBackend2, nil, nil, nil, "netexec", fmt.Sprintf("--udp-port=%d", 80))
|
||||||
serverPod2.Labels = udpJig.Labels
|
serverPod2.Labels = udpJig.Labels
|
||||||
serverPod2.Spec.NodeName = serverNodeInfo.name
|
serverPod2.Spec.NodeName = serverNodeInfo.name
|
||||||
fr.PodClient().CreateSync(serverPod2)
|
fr.PodClient().CreateSync(serverPod2)
|
||||||
|
@ -409,7 +409,7 @@ var _ = SIGDescribe("DNS", func() {
|
|||||||
ginkgo.By("Creating a pod with dnsPolicy=None and customized dnsConfig...")
|
ginkgo.By("Creating a pod with dnsPolicy=None and customized dnsConfig...")
|
||||||
testServerIP := "1.1.1.1"
|
testServerIP := "1.1.1.1"
|
||||||
testSearchPath := "resolv.conf.local"
|
testSearchPath := "resolv.conf.local"
|
||||||
testAgnhostPod := newAgnhostPod(f.Namespace.Name, "pause")
|
testAgnhostPod := e2epod.NewAgnhostPod(f.Namespace.Name, "test-dns-nameservers", nil, nil, nil)
|
||||||
testAgnhostPod.Spec.DNSPolicy = v1.DNSNone
|
testAgnhostPod.Spec.DNSPolicy = v1.DNSNone
|
||||||
testAgnhostPod.Spec.DNSConfig = &v1.PodDNSConfig{
|
testAgnhostPod.Spec.DNSConfig = &v1.PodDNSConfig{
|
||||||
Nameservers: []string{testServerIP},
|
Nameservers: []string{testServerIP},
|
||||||
@ -433,7 +433,7 @@ var _ = SIGDescribe("DNS", func() {
|
|||||||
Command: cmd,
|
Command: cmd,
|
||||||
Namespace: f.Namespace.Name,
|
Namespace: f.Namespace.Name,
|
||||||
PodName: testAgnhostPod.Name,
|
PodName: testAgnhostPod.Name,
|
||||||
ContainerName: "agnhost",
|
ContainerName: testAgnhostPod.Spec.Containers[0].Name,
|
||||||
CaptureStdout: true,
|
CaptureStdout: true,
|
||||||
CaptureStderr: true,
|
CaptureStderr: true,
|
||||||
})
|
})
|
||||||
@ -493,7 +493,7 @@ var _ = SIGDescribe("DNS", func() {
|
|||||||
framework.Logf("testServerIP is %s", testServerIP)
|
framework.Logf("testServerIP is %s", testServerIP)
|
||||||
|
|
||||||
ginkgo.By("Creating a pod with dnsPolicy=None and customized dnsConfig...")
|
ginkgo.By("Creating a pod with dnsPolicy=None and customized dnsConfig...")
|
||||||
testUtilsPod := generateDNSUtilsPod()
|
testUtilsPod := e2epod.NewAgnhostPod(f.Namespace.Name, "e2e-dns-utils", nil, nil, nil)
|
||||||
testUtilsPod.Spec.DNSPolicy = v1.DNSNone
|
testUtilsPod.Spec.DNSPolicy = v1.DNSNone
|
||||||
testNdotsValue := "2"
|
testNdotsValue := "2"
|
||||||
testUtilsPod.Spec.DNSConfig = &v1.PodDNSConfig{
|
testUtilsPod.Spec.DNSConfig = &v1.PodDNSConfig{
|
||||||
@ -525,7 +525,7 @@ var _ = SIGDescribe("DNS", func() {
|
|||||||
Command: cmd,
|
Command: cmd,
|
||||||
Namespace: f.Namespace.Name,
|
Namespace: f.Namespace.Name,
|
||||||
PodName: testUtilsPod.Name,
|
PodName: testUtilsPod.Name,
|
||||||
ContainerName: "util",
|
ContainerName: testUtilsPod.Spec.Containers[0].Name,
|
||||||
CaptureStdout: true,
|
CaptureStdout: true,
|
||||||
CaptureStderr: true,
|
CaptureStderr: true,
|
||||||
})
|
})
|
||||||
@ -545,7 +545,7 @@ var _ = SIGDescribe("DNS", func() {
|
|||||||
Command: cmd,
|
Command: cmd,
|
||||||
Namespace: f.Namespace.Name,
|
Namespace: f.Namespace.Name,
|
||||||
PodName: testUtilsPod.Name,
|
PodName: testUtilsPod.Name,
|
||||||
ContainerName: "util",
|
ContainerName: testUtilsPod.Spec.Containers[0].Name,
|
||||||
CaptureStdout: true,
|
CaptureStdout: true,
|
||||||
CaptureStderr: true,
|
CaptureStderr: true,
|
||||||
})
|
})
|
||||||
|
@ -199,29 +199,9 @@ func (t *dnsTestCommon) deleteConfigMap() {
|
|||||||
func (t *dnsTestCommon) createUtilPodLabel(baseName string) {
|
func (t *dnsTestCommon) createUtilPodLabel(baseName string) {
|
||||||
// Actual port # doesn't matter, just needs to exist.
|
// Actual port # doesn't matter, just needs to exist.
|
||||||
const servicePort = 10101
|
const servicePort = 10101
|
||||||
|
podName := fmt.Sprintf("%s-%s", baseName, string(uuid.NewUUID()))
|
||||||
t.utilPod = &v1.Pod{
|
ports := []v1.ContainerPort{{ContainerPort: servicePort, Protocol: v1.ProtocolTCP}}
|
||||||
TypeMeta: metav1.TypeMeta{
|
t.utilPod = e2epod.NewAgnhostPod(t.f.Namespace.Name, podName, nil, nil, ports)
|
||||||
Kind: "Pod",
|
|
||||||
},
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Namespace: t.f.Namespace.Name,
|
|
||||||
Labels: map[string]string{"app": baseName},
|
|
||||||
GenerateName: baseName + "-",
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: "util",
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
|
||||||
Command: []string{"sleep", "10000"},
|
|
||||||
Ports: []v1.ContainerPort{
|
|
||||||
{ContainerPort: servicePort, Protocol: v1.ProtocolTCP},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
t.utilPod, err = t.c.CoreV1().Pods(t.f.Namespace.Name).Create(context.TODO(), t.utilPod, metav1.CreateOptions{})
|
t.utilPod, err = t.c.CoreV1().Pods(t.f.Namespace.Name).Create(context.TODO(), t.utilPod, metav1.CreateOptions{})
|
||||||
@ -280,15 +260,8 @@ func (t *dnsTestCommon) deleteCoreDNSPods() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func generateCoreDNSServerPod(corednsConfig *v1.ConfigMap) *v1.Pod {
|
func generateCoreDNSServerPod(corednsConfig *v1.ConfigMap) *v1.Pod {
|
||||||
return &v1.Pod{
|
podName := fmt.Sprintf("e2e-configmap-dns-server-%s", string(uuid.NewUUID()))
|
||||||
TypeMeta: metav1.TypeMeta{
|
volumes := []v1.Volume{
|
||||||
Kind: "Pod",
|
|
||||||
},
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
GenerateName: "e2e-dns-configmap-dns-server-",
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
Volumes: []v1.Volume{
|
|
||||||
{
|
{
|
||||||
Name: "coredns-config",
|
Name: "coredns-config",
|
||||||
VolumeSource: v1.VolumeSource{
|
VolumeSource: v1.VolumeSource{
|
||||||
@ -299,27 +272,19 @@ func generateCoreDNSServerPod(corednsConfig *v1.ConfigMap) *v1.Pod {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
Containers: []v1.Container{
|
mounts := []v1.VolumeMount{
|
||||||
{
|
|
||||||
Name: "dns",
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
|
||||||
Command: []string{
|
|
||||||
"/coredns",
|
|
||||||
"-conf", "/etc/coredns/Corefile",
|
|
||||||
},
|
|
||||||
VolumeMounts: []v1.VolumeMount{
|
|
||||||
{
|
{
|
||||||
Name: "coredns-config",
|
Name: "coredns-config",
|
||||||
MountPath: "/etc/coredns",
|
MountPath: "/etc/coredns",
|
||||||
ReadOnly: true,
|
ReadOnly: true,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
DNSPolicy: "Default",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pod := e2epod.NewAgnhostPod("", podName, volumes, mounts, nil, "-conf", "/etc/coredns/Corefile")
|
||||||
|
pod.Spec.Containers[0].Command = []string{"/coredns"}
|
||||||
|
pod.Spec.DNSPolicy = "Default"
|
||||||
|
return pod
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateCoreDNSConfigmap(namespaceName string, aRecords map[string]string) *v1.ConfigMap {
|
func generateCoreDNSConfigmap(namespaceName string, aRecords map[string]string) *v1.ConfigMap {
|
||||||
@ -390,69 +355,37 @@ func (t *dnsTestCommon) deleteDNSServerPod() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createDNSPod(namespace, wheezyProbeCmd, jessieProbeCmd, podHostName, serviceName string) *v1.Pod {
|
func createDNSPod(namespace, wheezyProbeCmd, jessieProbeCmd, podHostName, serviceName string) *v1.Pod {
|
||||||
dnsPod := &v1.Pod{
|
podName := "dns-test-" + string(uuid.NewUUID())
|
||||||
TypeMeta: metav1.TypeMeta{
|
volumes := []v1.Volume{
|
||||||
Kind: "Pod",
|
|
||||||
APIVersion: "v1",
|
|
||||||
},
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "dns-test-" + string(uuid.NewUUID()),
|
|
||||||
Namespace: namespace,
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
Volumes: []v1.Volume{
|
|
||||||
{
|
{
|
||||||
Name: "results",
|
Name: "results",
|
||||||
VolumeSource: v1.VolumeSource{
|
VolumeSource: v1.VolumeSource{
|
||||||
EmptyDir: &v1.EmptyDirVolumeSource{},
|
EmptyDir: &v1.EmptyDirVolumeSource{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
Containers: []v1.Container{
|
mounts := []v1.VolumeMount{
|
||||||
// TODO: Consider scraping logs instead of running a webserver.
|
|
||||||
{
|
|
||||||
Name: "webserver",
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
|
||||||
Args: []string{"test-webserver"},
|
|
||||||
Ports: []v1.ContainerPort{
|
|
||||||
{
|
|
||||||
Name: "http",
|
|
||||||
ContainerPort: 80,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
VolumeMounts: []v1.VolumeMount{
|
|
||||||
{
|
{
|
||||||
Name: "results",
|
Name: "results",
|
||||||
MountPath: "/results",
|
MountPath: "/results",
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "querier",
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
|
||||||
Command: []string{"sh", "-c", wheezyProbeCmd},
|
|
||||||
VolumeMounts: []v1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "results",
|
|
||||||
MountPath: "/results",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "jessie-querier",
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.JessieDnsutils),
|
|
||||||
Command: []string{"sh", "-c", jessieProbeCmd},
|
|
||||||
VolumeMounts: []v1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "results",
|
|
||||||
MountPath: "/results",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Consider scraping logs instead of running a webserver.
|
||||||
|
dnsPod := e2epod.NewAgnhostPod(namespace, podName, volumes, mounts, nil, "test-webserver")
|
||||||
|
dnsPod.Spec.Containers[0].Name = "webserver"
|
||||||
|
|
||||||
|
querier := e2epod.NewAgnhostContainer("querier", mounts, nil, wheezyProbeCmd)
|
||||||
|
querier.Command = []string{"sh", "-c"}
|
||||||
|
|
||||||
|
jessieQuerier := v1.Container{
|
||||||
|
Name: "jessie-querier",
|
||||||
|
Image: imageutils.GetE2EImage(imageutils.JessieDnsutils),
|
||||||
|
Command: []string{"sh", "-c", jessieProbeCmd},
|
||||||
|
VolumeMounts: mounts,
|
||||||
|
}
|
||||||
|
|
||||||
|
dnsPod.Spec.Containers = append(dnsPod.Spec.Containers, querier, jessieQuerier)
|
||||||
dnsPod.Spec.Hostname = podHostName
|
dnsPod.Spec.Hostname = podHostName
|
||||||
dnsPod.Spec.Subdomain = serviceName
|
dnsPod.Spec.Subdomain = serviceName
|
||||||
|
|
||||||
@ -625,23 +558,3 @@ func validateTargetedProbeOutput(f *framework.Framework, pod *v1.Pod, fileNames
|
|||||||
|
|
||||||
framework.Logf("DNS probes using %s succeeded\n", pod.Name)
|
framework.Logf("DNS probes using %s succeeded\n", pod.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateDNSUtilsPod() *v1.Pod {
|
|
||||||
return &v1.Pod{
|
|
||||||
TypeMeta: metav1.TypeMeta{
|
|
||||||
Kind: "Pod",
|
|
||||||
},
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
GenerateName: "e2e-dns-utils-",
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: "util",
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
|
||||||
Command: []string{"sleep", "10000"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -147,7 +147,7 @@ var _ = SIGDescribe("Firewall rule", func() {
|
|||||||
podName := fmt.Sprintf("netexec%v", i)
|
podName := fmt.Sprintf("netexec%v", i)
|
||||||
|
|
||||||
framework.Logf("Creating netexec pod %q on node %v in namespace %q", podName, nodeName, ns)
|
framework.Logf("Creating netexec pod %q on node %v in namespace %q", podName, nodeName, ns)
|
||||||
pod := newAgnhostPod(podName,
|
pod := e2epod.NewAgnhostPod(ns, podName, nil, nil, nil,
|
||||||
"netexec",
|
"netexec",
|
||||||
fmt.Sprintf("--http-port=%d", firewallTestHTTPPort),
|
fmt.Sprintf("--http-port=%d", firewallTestHTTPPort),
|
||||||
fmt.Sprintf("--udp-port=%d", firewallTestUDPPort))
|
fmt.Sprintf("--udp-port=%d", firewallTestUDPPort))
|
||||||
|
@ -42,8 +42,6 @@ import (
|
|||||||
//
|
//
|
||||||
// An empty nodeName will use the schedule to choose where the pod is executed.
|
// An empty nodeName will use the schedule to choose where the pod is executed.
|
||||||
func checkConnectivityToHost(f *framework.Framework, nodeName, podName, host string, port, timeout int) error {
|
func checkConnectivityToHost(f *framework.Framework, nodeName, podName, host string, port, timeout int) error {
|
||||||
contName := fmt.Sprintf("%s-container", podName)
|
|
||||||
|
|
||||||
command := []string{
|
command := []string{
|
||||||
"nc",
|
"nc",
|
||||||
"-vz",
|
"-vz",
|
||||||
@ -52,22 +50,11 @@ func checkConnectivityToHost(f *framework.Framework, nodeName, podName, host str
|
|||||||
strconv.Itoa(port),
|
strconv.Itoa(port),
|
||||||
}
|
}
|
||||||
|
|
||||||
pod := &v1.Pod{
|
pod := e2epod.NewAgnhostPod(f.Namespace.Name, podName, nil, nil, nil)
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
pod.Spec.Containers[0].Command = command
|
||||||
Name: podName,
|
pod.Spec.NodeName = nodeName
|
||||||
},
|
pod.Spec.RestartPolicy = v1.RestartPolicyNever
|
||||||
Spec: v1.PodSpec{
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: contName,
|
|
||||||
Image: agnHostImage,
|
|
||||||
Command: command,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
NodeName: nodeName,
|
|
||||||
RestartPolicy: v1.RestartPolicyNever,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
podClient := f.ClientSet.CoreV1().Pods(f.Namespace.Name)
|
podClient := f.ClientSet.CoreV1().Pods(f.Namespace.Name)
|
||||||
_, err := podClient.Create(context.TODO(), pod, metav1.CreateOptions{})
|
_, err := podClient.Create(context.TODO(), pod, metav1.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -76,7 +63,7 @@ func checkConnectivityToHost(f *framework.Framework, nodeName, podName, host str
|
|||||||
err = e2epod.WaitForPodSuccessInNamespace(f.ClientSet, podName, f.Namespace.Name)
|
err = e2epod.WaitForPodSuccessInNamespace(f.ClientSet, podName, f.Namespace.Name)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs, logErr := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, contName)
|
logs, logErr := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, pod.Spec.Containers[0].Name)
|
||||||
if logErr != nil {
|
if logErr != nil {
|
||||||
framework.Logf("Warning: Failed to get logs from pod %q: %v", pod.Name, logErr)
|
framework.Logf("Warning: Failed to get logs from pod %q: %v", pod.Name, logErr)
|
||||||
} else {
|
} else {
|
||||||
|
@ -986,7 +986,7 @@ var _ = SIGDescribe("Services", func() {
|
|||||||
|
|
||||||
ginkgo.By("Creating a webserver pod to be part of the TCP service which echoes back source ip")
|
ginkgo.By("Creating a webserver pod to be part of the TCP service which echoes back source ip")
|
||||||
serverPodName := "echo-sourceip"
|
serverPodName := "echo-sourceip"
|
||||||
pod := newAgnhostPod(serverPodName, "netexec", "--http-port", strconv.Itoa(servicePort))
|
pod := e2epod.NewAgnhostPod(ns, serverPodName, nil, nil, nil, "netexec", "--http-port", strconv.Itoa(servicePort))
|
||||||
pod.Labels = jig.Labels
|
pod.Labels = jig.Labels
|
||||||
_, err = cs.CoreV1().Pods(ns).Create(context.TODO(), pod, metav1.CreateOptions{})
|
_, err = cs.CoreV1().Pods(ns).Create(context.TODO(), pod, metav1.CreateOptions{})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
@ -1044,7 +1044,7 @@ var _ = SIGDescribe("Services", func() {
|
|||||||
|
|
||||||
ginkgo.By("creating a client/server pod")
|
ginkgo.By("creating a client/server pod")
|
||||||
serverPodName := "hairpin"
|
serverPodName := "hairpin"
|
||||||
podTemplate := newAgnhostPod(serverPodName, "netexec", "--http-port", strconv.Itoa(servicePort))
|
podTemplate := e2epod.NewAgnhostPod(ns, serverPodName, nil, nil, nil, "netexec", "--http-port", strconv.Itoa(servicePort))
|
||||||
podTemplate.Labels = jig.Labels
|
podTemplate.Labels = jig.Labels
|
||||||
pod, err := cs.CoreV1().Pods(ns).Create(context.TODO(), podTemplate, metav1.CreateOptions{})
|
pod, err := cs.CoreV1().Pods(ns).Create(context.TODO(), podTemplate, metav1.CreateOptions{})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
@ -3667,22 +3667,8 @@ func checkReachabilityFromPod(expectToBeReachable bool, timeout time.Duration, n
|
|||||||
|
|
||||||
// proxyMode returns a proxyMode of a kube-proxy.
|
// proxyMode returns a proxyMode of a kube-proxy.
|
||||||
func proxyMode(f *framework.Framework) (string, error) {
|
func proxyMode(f *framework.Framework) (string, error) {
|
||||||
pod := &v1.Pod{
|
pod := e2epod.NewAgnhostPod(f.Namespace.Name, "kube-proxy-mode-detector", nil, nil, nil)
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
pod.Spec.HostNetwork = true
|
||||||
Name: "kube-proxy-mode-detector",
|
|
||||||
Namespace: f.Namespace.Name,
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
HostNetwork: true,
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: "detector",
|
|
||||||
Image: agnHostImage,
|
|
||||||
Args: []string{"pause"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
f.PodClient().CreateSync(pod)
|
f.PodClient().CreateSync(pod)
|
||||||
defer f.PodClient().DeleteSync(pod.Name, metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout)
|
defer f.PodClient().DeleteSync(pod.Name, metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout)
|
||||||
|
|
||||||
@ -3965,32 +3951,8 @@ var _ = SIGDescribe("SCTP [Feature:SCTP] [LinuxOnly]", func() {
|
|||||||
|
|
||||||
ginkgo.By("creating a pod with hostport on the selected node")
|
ginkgo.By("creating a pod with hostport on the selected node")
|
||||||
podName := "hostport"
|
podName := "hostport"
|
||||||
|
ports := []v1.ContainerPort{{Protocol: v1.ProtocolSCTP, ContainerPort: 5060, HostPort: 5060}}
|
||||||
podSpec := &v1.Pod{
|
podSpec := e2epod.NewAgnhostPod(f.Namespace.Name, podName, nil, nil, ports)
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: podName,
|
|
||||||
Namespace: f.Namespace.Name,
|
|
||||||
Labels: map[string]string{"app": "hostport-pod"},
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
NodeName: node.Name,
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: "hostport",
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
|
||||||
Args: []string{"pause"},
|
|
||||||
Ports: []v1.ContainerPort{
|
|
||||||
{
|
|
||||||
Protocol: v1.ProtocolSCTP,
|
|
||||||
ContainerPort: 5060,
|
|
||||||
HostPort: 5060,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ImagePullPolicy: "IfNotPresent",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
ginkgo.By(fmt.Sprintf("Launching the pod on node %v", node.Name))
|
ginkgo.By(fmt.Sprintf("Launching the pod on node %v", node.Name))
|
||||||
f.PodClient().CreateSync(podSpec)
|
f.PodClient().CreateSync(podSpec)
|
||||||
|
@ -31,17 +31,11 @@ import (
|
|||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
e2enetwork "k8s.io/kubernetes/test/e2e/framework/network"
|
e2enetwork "k8s.io/kubernetes/test/e2e/framework/network"
|
||||||
"k8s.io/kubernetes/test/e2e/storage/utils"
|
"k8s.io/kubernetes/test/e2e/storage/utils"
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// secondNodePortSvcName is the name of the secondary node port service
|
// secondNodePortSvcName is the name of the secondary node port service
|
||||||
const secondNodePortSvcName = "second-node-port-service"
|
const secondNodePortSvcName = "second-node-port-service"
|
||||||
|
|
||||||
var (
|
|
||||||
// agnHostImage is the image URI of AgnHost
|
|
||||||
agnHostImage = imageutils.GetE2EImage(imageutils.Agnhost)
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetHTTPContent returns the content of the given url by HTTP.
|
// GetHTTPContent returns the content of the given url by HTTP.
|
||||||
func GetHTTPContent(host string, port int, timeout time.Duration, url string) bytes.Buffer {
|
func GetHTTPContent(host string, port int, timeout time.Duration, url string) bytes.Buffer {
|
||||||
var body bytes.Buffer
|
var body bytes.Buffer
|
||||||
@ -83,27 +77,6 @@ func DescribeSvc(ns string) {
|
|||||||
framework.Logf(desc)
|
framework.Logf(desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// newAgnhostPod returns a pod that uses the agnhost image. The image's binary supports various subcommands
|
|
||||||
// that behave the same, no matter the underlying OS.
|
|
||||||
func newAgnhostPod(name string, args ...string) *v1.Pod {
|
|
||||||
zero := int64(0)
|
|
||||||
return &v1.Pod{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: name,
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
TerminationGracePeriodSeconds: &zero,
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: "agnhost",
|
|
||||||
Image: agnHostImage,
|
|
||||||
Args: args,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckSCTPModuleLoadedOnNodes checks whether any node on the list has the
|
// CheckSCTPModuleLoadedOnNodes checks whether any node on the list has the
|
||||||
// sctp.ko module loaded
|
// sctp.ko module loaded
|
||||||
// For security reasons, and also to allow clusters to use userspace SCTP implementations,
|
// For security reasons, and also to allow clusters to use userspace SCTP implementations,
|
||||||
|
Loading…
Reference in New Issue
Block a user