mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
Merge pull request #75245 from aojea/e2e_ipv6_lifecyclehook
Add IPv6 support to the Container Lifecycle tests
This commit is contained in:
commit
5f1a3a98d4
@ -17,6 +17,8 @@ limitations under the License.
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
@ -38,7 +40,7 @@ var _ = framework.KubeDescribe("Container Lifecycle Hook", func() {
|
|||||||
preStopWaitTimeout = 30 * time.Second
|
preStopWaitTimeout = 30 * time.Second
|
||||||
)
|
)
|
||||||
Context("when create a pod with lifecycle hook", func() {
|
Context("when create a pod with lifecycle hook", func() {
|
||||||
var targetIP string
|
var targetIP, targetURL string
|
||||||
podHandleHookRequest := &v1.Pod{
|
podHandleHookRequest := &v1.Pod{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "pod-handle-http-request",
|
Name: "pod-handle-http-request",
|
||||||
@ -63,6 +65,10 @@ var _ = framework.KubeDescribe("Container Lifecycle Hook", func() {
|
|||||||
By("create the container to handle the HTTPGet hook request.")
|
By("create the container to handle the HTTPGet hook request.")
|
||||||
newPod := podClient.CreateSync(podHandleHookRequest)
|
newPod := podClient.CreateSync(podHandleHookRequest)
|
||||||
targetIP = newPod.Status.PodIP
|
targetIP = newPod.Status.PodIP
|
||||||
|
targetURL = targetIP
|
||||||
|
if strings.Contains(targetIP, ":") {
|
||||||
|
targetURL = fmt.Sprintf("[%s]", targetIP)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
testPodWithHook := func(podWithHook *v1.Pod) {
|
testPodWithHook := func(podWithHook *v1.Pod) {
|
||||||
By("create the pod with lifecycle hook")
|
By("create the pod with lifecycle hook")
|
||||||
@ -93,7 +99,7 @@ var _ = framework.KubeDescribe("Container Lifecycle Hook", func() {
|
|||||||
lifecycle := &v1.Lifecycle{
|
lifecycle := &v1.Lifecycle{
|
||||||
PostStart: &v1.Handler{
|
PostStart: &v1.Handler{
|
||||||
Exec: &v1.ExecAction{
|
Exec: &v1.ExecAction{
|
||||||
Command: []string{"sh", "-c", "curl http://" + targetIP + ":8080/echo?msg=poststart"},
|
Command: []string{"sh", "-c", "curl http://" + targetURL + ":8080/echo?msg=poststart"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -109,7 +115,7 @@ var _ = framework.KubeDescribe("Container Lifecycle Hook", func() {
|
|||||||
lifecycle := &v1.Lifecycle{
|
lifecycle := &v1.Lifecycle{
|
||||||
PreStop: &v1.Handler{
|
PreStop: &v1.Handler{
|
||||||
Exec: &v1.ExecAction{
|
Exec: &v1.ExecAction{
|
||||||
Command: []string{"sh", "-c", "curl http://" + targetIP + ":8080/echo?msg=prestop"},
|
Command: []string{"sh", "-c", "curl http://" + targetURL + ":8080/echo?msg=prestop"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user