Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connectivity: allow to restrict connectivity test pods using nodeSelector #1446

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions connectivity/check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Parameters struct {
DNSTestServerImage string
Datapath bool
AgentPodSelector string
NodeSelector map[string]string
ExternalTarget string
ExternalCIDR string
ExternalIP string
Expand Down
26 changes: 17 additions & 9 deletions connectivity/check/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ type deploymentParameters struct {
HostPort int
Command []string
Affinity *corev1.Affinity
NodeSelector map[string]string
ReadinessProbe *corev1.Probe
Labels map[string]string
HostNetwork bool
Expand Down Expand Up @@ -146,6 +147,7 @@ func newDeployment(p deploymentParameters) *appsv1.Deployment {
},
},
Affinity: p.Affinity,
NodeSelector: p.NodeSelector,
HostNetwork: p.HostNetwork,
ServiceAccountName: p.Name,
},
Expand Down Expand Up @@ -396,7 +398,8 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
},
},
},
HostNetwork: ct.params.PerfHostNet,
NodeSelector: ct.params.NodeSelector,
HostNetwork: ct.params.PerfHostNet,
})
_, err = ct.clients.src.CreateServiceAccount(ctx, ct.params.TestNamespace, k8s.NewServiceAccount(nm.ClientName()), metav1.CreateOptions{})
if err != nil {
Expand Down Expand Up @@ -446,7 +449,8 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
},
},
},
HostNetwork: ct.params.PerfHostNet,
NodeSelector: ct.params.NodeSelector,
HostNetwork: ct.params.PerfHostNet,
})
_, err = ct.clients.src.CreateServiceAccount(ctx, ct.params.TestNamespace, k8s.NewServiceAccount(nm.ServerName()), metav1.CreateOptions{})
if err != nil {
Expand Down Expand Up @@ -493,7 +497,8 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
{Key: "name", Operator: metav1.LabelSelectorOpIn, Values: []string{nm.ClientName()}}}},
TopologyKey: "kubernetes.io/hostname"}}}},
},
HostNetwork: ct.params.PerfHostNet,
NodeSelector: ct.params.NodeSelector,
HostNetwork: ct.params.PerfHostNet,
})
_, err = ct.clients.src.CreateServiceAccount(ctx, ct.params.TestNamespace, k8s.NewServiceAccount(nm.ClientAcrossName()), metav1.CreateOptions{})
if err != nil {
Expand Down Expand Up @@ -629,12 +634,13 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
if err != nil {
ct.Logf("✨ [%s] Deploying %s deployment...", ct.clients.src.ClusterName(), clientDeploymentName)
clientDeployment := newDeployment(deploymentParameters{
Name: clientDeploymentName,
Kind: kindClientName,
NamedPort: "http-8080",
Port: 8080,
Image: ct.params.CurlImage,
Command: []string{"/bin/ash", "-c", "sleep 10000000"},
Name: clientDeploymentName,
Kind: kindClientName,
NamedPort: "http-8080",
Port: 8080,
Image: ct.params.CurlImage,
Command: []string{"/bin/ash", "-c", "sleep 10000000"},
NodeSelector: ct.params.NodeSelector,
})
_, err = ct.clients.src.CreateServiceAccount(ctx, ct.params.TestNamespace, k8s.NewServiceAccount(clientDeploymentName), metav1.CreateOptions{})
if err != nil {
Expand Down Expand Up @@ -672,6 +678,7 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
},
},
},
NodeSelector: ct.params.NodeSelector,
})
_, err = ct.clients.src.CreateServiceAccount(ctx, ct.params.TestNamespace, k8s.NewServiceAccount(client2DeploymentName), metav1.CreateOptions{})
if err != nil {
Expand Down Expand Up @@ -727,6 +734,7 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
},
},
},
NodeSelector: ct.params.NodeSelector,
ReadinessProbe: newLocalReadinessProbe(containerPort, "/"),
}, ct.params.DNSTestServerImage)
_, err = ct.clients.dst.CreateServiceAccount(ctx, ct.params.TestNamespace, k8s.NewServiceAccount(echoOtherNodeDeploymentName), metav1.CreateOptions{})
Expand Down
1 change: 1 addition & 0 deletions internal/cli/cmd/connectivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func newCmdConnectivityTest() *cobra.Command {
cmd.Flags().StringVar(&params.TestNamespace, "test-namespace", defaults.ConnectivityCheckNamespace, "Namespace to perform the connectivity test in")
cmd.Flags().StringVar(&params.AgentDaemonSetName, "agent-daemonset-name", defaults.AgentDaemonSetName, "Name of cilium agent daemonset")
cmd.Flags().StringVar(&params.AgentPodSelector, "agent-pod-selector", defaults.AgentPodSelector, "Label on cilium-agent pods to select with")
cmd.Flags().StringToStringVar(&params.NodeSelector, "node-selector", map[string]string{}, "Restrict connectivity test pods to nodes matching this label")
cmd.Flags().StringVar(&params.MultiCluster, "multi-cluster", "", "Test across clusters to given context")
cmd.Flags().StringSliceVar(&tests, "test", []string{}, "Run tests that match one of the given regular expressions, skip tests by starting the expression with '!', target Scenarios with e.g. '/pod-to-cidr'")
cmd.Flags().StringVar(&params.FlowValidation, "flow-validation", check.FlowValidationModeWarning, "Enable Hubble flow validation { disabled | warning | strict }")
Expand Down