Skip to content
115 changes: 58 additions & 57 deletions e2e/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,19 +418,10 @@ func daemonsetDebug(ctx context.Context, deploymentName string, nodeSelector map
},
},
Spec: corev1.PodSpec{
HostNetwork: isHostNetwork,
NodeSelector: nodeSelector,
ImagePullSecrets: func() []corev1.LocalObjectReference {
if secretName == "" {
return nil
}
return []corev1.LocalObjectReference{
{
Name: secretName,
},
}
}(),
HostPID: true,
HostNetwork: isHostNetwork,
NodeSelector: nodeSelector,
ImagePullSecrets: getImagePullSecrets(secretName),
HostPID: true,
Containers: []corev1.Container{
{
Image: image,
Expand All @@ -441,34 +432,49 @@ func daemonsetDebug(ctx context.Context, deploymentName string, nodeSelector map
},
},
},
// Set Tolerations to tolerate the node with test taints "testkey1=value1:NoSchedule,testkey2=value2:NoSchedule".
// This is to ensure that the pod can be scheduled on the node with the taints.
// It won't affect other pods running on the same node.
Tolerations: []corev1.Toleration{
{
Key: "testkey1",
Operator: corev1.TolerationOpEqual,
Value: "value1",
Effect: corev1.TaintEffectNoSchedule,
},
{
Key: "testkey2",
Operator: corev1.TolerationOpEqual,
Value: "value2",
Effect: corev1.TaintEffectNoSchedule,
},
{
Key: "node.cloudprovider.kubernetes.io/uninitialized",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
},
},
Tolerations: getPodTolerations(),
},
},
},
}
}

func getImagePullSecrets(secretName string) []corev1.LocalObjectReference {
if secretName == "" {
return nil
}
return []corev1.LocalObjectReference{
{
Name: secretName,
},
}
}

func getPodTolerations() []corev1.Toleration {
// Set Tolerations to tolerate the node with test taints "testkey1=value1:NoSchedule,testkey2=value2:NoSchedule".
// This is to ensure that the pod can be scheduled on the node with the taints.
// It won't affect other pods running on the same node.
return []corev1.Toleration{
{
Key: "testkey1",
Operator: corev1.TolerationOpEqual,
Value: "value1",
Effect: corev1.TaintEffectNoSchedule,
},
{
Key: "testkey2",
Operator: corev1.TolerationOpEqual,
Value: "value2",
Effect: corev1.TaintEffectNoSchedule,
},
{
Key: "node.cloudprovider.kubernetes.io/uninitialized",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
},
}
}

func (k *Kubeclient) ensureProxyConfigMap(ctx context.Context) error {
// Minimal HTTP forward proxy in Python. Handles both:
// - CONNECT tunneling for HTTPS (curl uses this when HTTPS_PROXY is set)
Expand Down Expand Up @@ -750,31 +756,27 @@ func podHTTPServerLinux(s *Scenario) *corev1.Pod {
// Set Tolerations to tolerate the node with test taints "testkey1=value1:NoSchedule,testkey2=value2:NoSchedule".
// This is to ensure that the pod can be scheduled on the node with the taints.
// It won't affect other pods running on the same node.
Tolerations: []corev1.Toleration{
{
Key: "testkey1",
Operator: corev1.TolerationOpEqual,
Value: "value1",
Effect: corev1.TaintEffectNoSchedule,
},
{
Key: "testkey2",
Operator: corev1.TolerationOpEqual,
Value: "value2",
Effect: corev1.TaintEffectNoSchedule,
},
},
NodeSelector: map[string]string{
"kubernetes.io/hostname": s.Runtime.VM.KubeName,
},
Tolerations: getPodTolerations(),
NodeSelector: getNodeSelectorForScenario(s),
},
}
}

func podWindows(s *Scenario, podName string, imageName string) *corev1.Pod {
func getNodeSelectorForScenario(s *Scenario) map[string]string {
return map[string]string{
"kubernetes.io/hostname": s.Runtime.VM.KubeName,
}
}

func debugPodWindows(s *Scenario, podName string, imageName string) *corev1.Pod {
deploymentName := fmt.Sprintf("%s-test-%s-pod", s.Runtime.VM.KubeName, podName)
return &corev1.Pod{
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: "apps/v1",
},
Comment thread
Copilot marked this conversation as resolved.
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-test-%s-pod", s.Runtime.VM.KubeName, podName),
Name: deploymentName,
Namespace: "default",
},
Spec: corev1.PodSpec{
Expand All @@ -787,9 +789,8 @@ func podWindows(s *Scenario, podName string, imageName string) *corev1.Pod {
Command: []string{"cmd", "/c", "ping", "-t", "localhost"},
},
},
NodeSelector: map[string]string{
"kubernetes.io/hostname": s.Runtime.VM.KubeName,
},
Tolerations: getPodTolerations(),
NodeSelector: getNodeSelectorForScenario(s),
},
}
}
Expand Down
4 changes: 2 additions & 2 deletions e2e/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,12 @@ func ValidateNodeCanRunAPod(ctx context.Context, s *Scenario) {
if s.IsWindows() {
serverCorePods := components.GetServercoreImagesForVHD(s.VHD)
for i, pod := range serverCorePods {
ValidatePodRunning(ctx, s, podWindows(s, fmt.Sprintf("servercore%d", i), pod))
ValidatePodRunningWithRetry(ctx, s, debugPodWindows(s, fmt.Sprintf("servercore%d", i), pod), 3)
}

nanoServerPods := components.GetNanoserverImagesForVhd(s.VHD)
for i, pod := range nanoServerPods {
ValidatePodRunning(ctx, s, podWindows(s, fmt.Sprintf("nanoserver%d", i), pod))
ValidatePodRunningWithRetry(ctx, s, debugPodWindows(s, fmt.Sprintf("nanoserver%d", i), pod), 3)
}
Comment thread
timmy-wright marked this conversation as resolved.
} else {
ValidatePodRunningWithRetry(ctx, s, podHTTPServerLinux(s), 3)
Expand Down
Loading