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: Improve coverage of Ingress service #2414

Merged
merged 1 commit into from
May 6, 2024
Merged
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
42 changes: 26 additions & 16 deletions connectivity/check/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ const (
KindTestConnDisrupt = "test-conn-disrupt"

EchoServerHostPort = 4000

IngressServiceName = "ingress-service"
)

type deploymentParameters struct {
Expand Down Expand Up @@ -336,10 +334,10 @@ func newLocalReadinessProbe(port int, path string) *corev1.Probe {
}
}

func newIngress() *networkingv1.Ingress {
func newIngress(name, backend string) *networkingv1.Ingress {
return &networkingv1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: IngressServiceName,
Name: name,
Annotations: map[string]string{
"ingress.cilium.io/loadbalancer-mode": "dedicated",
"ingress.cilium.io/service-type": "NodePort",
Expand All @@ -362,7 +360,7 @@ func newIngress() *networkingv1.Ingress {
}(),
Backend: networkingv1.IngressBackend{
Service: &networkingv1.IngressServiceBackend{
Name: echoOtherNodeDeploymentName,
Name: backend,
Port: networkingv1.ServiceBackendPort{
Number: 8080,
},
Expand All @@ -378,6 +376,14 @@ func newIngress() *networkingv1.Ingress {
}
}

func (ct *ConnectivityTest) ingresses() map[string]string {
ingresses := map[string]string{"same-node": echoSameNodeDeploymentName}
if !ct.Params().SingleNode || ct.Params().MultiCluster != "" {
ingresses["other-node"] = echoOtherNodeDeploymentName
}
return ingresses
}

// deploy ensures the test Namespace, Services and Deployments are running on the cluster.
func (ct *ConnectivityTest) deploy(ctx context.Context) error {
var err error
Expand Down Expand Up @@ -868,12 +874,14 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {

// Create one Ingress service for echo deployment
if ct.Features[features.IngressController].Enabled {
_, err = ct.clients.src.GetIngress(ctx, ct.params.TestNamespace, IngressServiceName, metav1.GetOptions{})
if err != nil {
ct.Logf("✨ [%s] Deploying Ingress resource...", ct.clients.src.ClusterName())
_, err = ct.clients.src.CreateIngress(ctx, ct.params.TestNamespace, newIngress(), metav1.CreateOptions{})
for name, backend := range ct.ingresses() {
_, err = ct.clients.src.GetIngress(ctx, ct.params.TestNamespace, name, metav1.GetOptions{})
if err != nil {
return err
ct.Logf("✨ [%s] Deploying Ingress resource...", ct.clients.src.ClusterName())
_, err = ct.clients.src.CreateIngress(ctx, ct.params.TestNamespace, newIngress(name, backend), metav1.CreateOptions{})
if err != nil {
return err
}
}
}
}
Expand Down Expand Up @@ -1272,13 +1280,15 @@ func (ct *ConnectivityTest) validateDeployment(ctx context.Context) error {
}

if ct.Features[features.IngressController].Enabled {
svcName := fmt.Sprintf("cilium-ingress-%s", IngressServiceName)
svc, err := WaitForServiceRetrieval(ctx, ct, ct.client, ct.params.TestNamespace, svcName)
if err != nil {
return err
}
for name := range ct.ingresses() {
svcName := fmt.Sprintf("cilium-ingress-%s", name)
svc, err := WaitForServiceRetrieval(ctx, ct, ct.client, ct.params.TestNamespace, svcName)
if err != nil {
return err
}

ct.ingressService[svcName] = svc
ct.ingressService[svcName] = svc
}
}

if ct.params.MultiCluster == "" {
Expand Down
Loading