diff --git a/connectivity/check/context.go b/connectivity/check/context.go index 5c462778e1..f94e1a62cf 100644 --- a/connectivity/check/context.go +++ b/connectivity/check/context.go @@ -51,6 +51,7 @@ type ConnectivityTest struct { ciliumPods map[string]Pod echoPods map[string]Pod + echoExternalPods map[string]Pod clientPods map[string]Pod perfClientPods map[string]Pod perfServerPod map[string]Pod @@ -179,6 +180,7 @@ func NewConnectivityTest(client *k8s.Client, p Parameters, version string) (*Con version: version, ciliumPods: make(map[string]Pod), echoPods: make(map[string]Pod), + echoExternalPods: make(map[string]Pod), clientPods: make(map[string]Pod), perfClientPods: make(map[string]Pod), perfServerPod: make(map[string]Pod), @@ -687,6 +689,10 @@ func (ct *ConnectivityTest) EchoServices() map[string]Service { return ct.echoServices } +func (ct *ConnectivityTest) ExternalEchoPods() map[string]Pod { + return ct.echoExternalPods +} + func (ct *ConnectivityTest) IngressService() map[string]Service { return ct.ingressService } diff --git a/connectivity/check/deployment.go b/connectivity/check/deployment.go index 46b99cf6ec..1189aa7065 100644 --- a/connectivity/check/deployment.go +++ b/connectivity/check/deployment.go @@ -35,13 +35,15 @@ const ( DNSTestServerContainerName = "dns-test-server" - echoSameNodeDeploymentName = "echo-same-node" - echoOtherNodeDeploymentName = "echo-other-node" - corednsConfigMapName = "coredns-configmap" - corednsConfigVolumeName = "coredns-config-volume" - kindEchoName = "echo" - kindClientName = "client" - kindPerfName = "perf" + echoSameNodeDeploymentName = "echo-same-node" + echoOtherNodeDeploymentName = "echo-other-node" + echoExternalNodeDeploymentName = "echo-external-node" + corednsConfigMapName = "coredns-configmap" + corednsConfigVolumeName = "coredns-config-volume" + kindEchoName = "echo" + kindEchoExternalNodeName = "echo-external-node" + kindClientName = "client" + kindPerfName = "perf" hostNetNSDeploymentName = "host-netns" kindHostNetNS = "host-netns" @@ -102,6 +104,7 @@ type deploymentParameters struct { ReadinessProbe *corev1.Probe Labels map[string]string HostNetwork bool + Tolerations []corev1.Toleration } func newDeployment(p deploymentParameters) *appsv1.Deployment { @@ -154,6 +157,7 @@ func newDeployment(p deploymentParameters) *appsv1.Deployment { Affinity: p.Affinity, NodeSelector: p.NodeSelector, HostNetwork: p.HostNetwork, + Tolerations: p.Tolerations, ServiceAccountName: p.Name, }, }, @@ -816,6 +820,35 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error { return fmt.Errorf("unable to create daemonset %s: %w", hostNetNSDeploymentName, err) } } + + _, err = ct.clients.src.GetDeployment(ctx, ct.params.TestNamespace, echoExternalNodeDeploymentName, metav1.GetOptions{}) + if err != nil { + ct.Logf("✨ [%s] Deploying echo-external-node deployment...", ct.clients.src.ClusterName()) + containerPort := 8080 + echoExternalDeployment := newDeployment(deploymentParameters{ + Name: echoExternalNodeDeploymentName, + Kind: kindEchoExternalNodeName, + Port: containerPort, + NamedPort: "http-8080", + HostPort: 8080, + Image: ct.params.JSONMockImage, + Labels: map[string]string{"external": "echo"}, + NodeSelector: map[string]string{"cilium.io/no-schedule": "true"}, + ReadinessProbe: newLocalReadinessProbe(containerPort, "/"), + HostNetwork: true, + Tolerations: []corev1.Toleration{ + {Operator: corev1.TolerationOpExists}, + }, + }) + _, err = ct.clients.src.CreateServiceAccount(ctx, ct.params.TestNamespace, k8s.NewServiceAccount(echoExternalNodeDeploymentName), metav1.CreateOptions{}) + if err != nil { + return fmt.Errorf("unable to create service account %s: %s", echoExternalNodeDeploymentName, err) + } + _, err = ct.clients.src.CreateDeployment(ctx, ct.params.TestNamespace, echoExternalDeployment, metav1.CreateOptions{}) + if err != nil { + return fmt.Errorf("unable to create deployment %s: %s", echoExternalNodeDeploymentName, err) + } + } } } @@ -872,6 +905,10 @@ func (ct *ConnectivityTest) deploymentList() (srcList []string, dstList []string dstList = append(dstList, echoOtherNodeDeploymentName) } + if ct.features[FeatureNodeWithoutCilium].Enabled { + dstList = append(dstList, echoExternalNodeDeploymentName) + } + return srcList, dstList } @@ -1018,6 +1055,22 @@ func (ct *ConnectivityTest) validateDeployment(ctx context.Context) error { } } + if ct.features[FeatureNodeWithoutCilium].Enabled { + echoExternalNodePods, err := ct.clients.dst.ListPods(ctx, ct.params.TestNamespace, metav1.ListOptions{LabelSelector: "name=" + echoExternalNodeDeploymentName}) + if err != nil { + return fmt.Errorf("unable to list other node pods: %w", err) + } + + for _, pod := range echoExternalNodePods.Items { + ct.echoExternalPods[pod.Name] = Pod{ + K8sClient: ct.client, + Pod: pod.DeepCopy(), + scheme: "http", + port: 8080, // listen port of the echo server inside the container + } + } + } + svcDNSCtx, svcDNSCancel := context.WithTimeout(ctx, ct.params.ipCacheTimeout()) defer svcDNSCancel() for _, cp := range ct.clientPods {