From e27551206604db13bad51c9dd44d978d3616538f Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Mon, 18 Mar 2024 19:03:59 +0800 Subject: [PATCH] Support Sidecar container --- kustomize/stage/pod/fast/pod-ready.yaml | 7 +++++++ test/e2e/helper/pod.go | 23 +++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/kustomize/stage/pod/fast/pod-ready.yaml b/kustomize/stage/pod/fast/pod-ready.yaml index 253f00cb2..33fb573a5 100644 --- a/kustomize/stage/pod/fast/pod-ready.yaml +++ b/kustomize/stage/pod/fast/pod-ready.yaml @@ -49,12 +49,19 @@ spec: name: {{ .name | Quote }} ready: true restartCount: 0 + {{ if eq .restartPolicy "Always" }} + started: true + state: + running: + startedAt: {{ $now | Quote }} + {{ else }} state: terminated: exitCode: 0 finishedAt: {{ $now | Quote }} reason: Completed startedAt: {{ $now | Quote }} + {{ end }} {{ end }} hostIP: {{ NodeIPWith .spec.nodeName | Quote }} diff --git a/test/e2e/helper/pod.go b/test/e2e/helper/pod.go index 42efaaa57..24ec3113d 100644 --- a/test/e2e/helper/pod.go +++ b/test/e2e/helper/pod.go @@ -19,6 +19,8 @@ package helper import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "sigs.k8s.io/kwok/pkg/utils/format" ) // PodBuilder is a builder for pod. @@ -35,10 +37,23 @@ func NewPodBuilder(name string) *PodBuilder { Namespace: "default", }, Spec: corev1.PodSpec{ - Containers: []corev1.Container{{ - Name: "container", - Image: "image", - }}, + InitContainers: []corev1.Container{ + { + Name: "init", + Image: "image", + }, + { + Name: "sidecar", + Image: "image", + RestartPolicy: format.Ptr(corev1.ContainerRestartPolicyAlways), + }, + }, + Containers: []corev1.Container{ + { + Name: "container", + Image: "image", + }, + }, }, }, }