Skip to content

Commit

Permalink
connectivity: add echo-external deployment
Browse files Browse the repository at this point in the history
add a new echo-external deployment for a JSON mock pod targeting all
external nodes (i.e. nodes that are not running Cilium)

Signed-off-by: Gilberto Bertin <[email protected]>
  • Loading branch information
jibi committed May 5, 2023
1 parent d8b236f commit d541be5
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 7 deletions.
6 changes: 6 additions & 0 deletions connectivity/check/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
}
Expand Down
67 changes: 60 additions & 7 deletions connectivity/check/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
},
},
Expand Down Expand Up @@ -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)
}
}
}
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d541be5

Please sign in to comment.