From d9840cadd3cfe48587106a83878d5b0b24a8d334 Mon Sep 17 00:00:00 2001 From: John Wregglesworth Date: Wed, 11 Dec 2024 14:58:52 -0700 Subject: [PATCH] Set the ingressClassName based on flags, default to nginx --- app.go | 1 + external/ingresser.go | 3 ++- internal/ingresses.go | 12 +++++------- internal/internal.go | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app.go b/app.go index fdfcbeb..3f52f2d 100644 --- a/app.go +++ b/app.go @@ -136,6 +136,7 @@ func NewExposerApp(init *ExposerAppInit, apps *apps.Apps, c *koanf.Koanf) *Expos KeycloakClientID: c.String("keycloak.client-id"), KeycloakClientSecret: c.String("keycloak.client-secret"), IRODSZone: init.IRODSZone, + IngressClass: init.IngressClass, NATSEncodedConn: conn, } diff --git a/external/ingresser.go b/external/ingresser.go index 4f494b2..d2d8485 100644 --- a/external/ingresser.go +++ b/external/ingresser.go @@ -104,7 +104,8 @@ func (i *Ingresser) Update(ctx context.Context, opts *IngressOptions) (*netv1.In //}, }, Spec: netv1.IngressSpec{ - DefaultBackend: backend, + DefaultBackend: backend, + IngressClassName: &i.class, Rules: []netv1.IngressRule{ { Host: opts.Name, diff --git a/internal/ingresses.go b/internal/ingresses.go index 8999d5a..02e3d89 100644 --- a/internal/ingresses.go +++ b/internal/ingresses.go @@ -19,7 +19,7 @@ func IngressName(userID, invocationID string) string { // getIngress assembles and returns the Ingress needed for the VICE analysis. // It does not call the k8s API. -func (i *Internal) getIngress(ctx context.Context, job *model.Job, svc *apiv1.Service) (*netv1.Ingress, error) { +func (i *Internal) getIngress(ctx context.Context, job *model.Job, svc *apiv1.Service, class string) (*netv1.Ingress, error) { var ( rules []netv1.IngressRule defaultPort int32 @@ -82,15 +82,13 @@ func (i *Internal) getIngress(ctx context.Context, job *model.Job, svc *apiv1.Se return &netv1.Ingress{ ObjectMeta: metav1.ObjectMeta{ - Name: job.InvocationID, - // Annotations: map[string]string{ - // "kubernetes.io/ingress.class": "nginx", - // }, + Name: job.InvocationID, Labels: labels, }, Spec: netv1.IngressSpec{ - DefaultBackend: defaultBackend, // default backend, not the service backend - Rules: rules, + DefaultBackend: defaultBackend, // default backend, not the service backend + IngressClassName: &class, + Rules: rules, }, }, nil } diff --git a/internal/internal.go b/internal/internal.go index 3f612f6..edb5118 100644 --- a/internal/internal.go +++ b/internal/internal.go @@ -96,6 +96,7 @@ type Init struct { KeycloakClientID string KeycloakClientSecret string IRODSZone string + IngressClass string NATSEncodedConn *nats.EncodedConn } @@ -291,7 +292,7 @@ func (i *Internal) UpsertDeployment(ctx context.Context, deployment *appsv1.Depl } // Create the ingress for the job - ingress, err := i.getIngress(ctx, job, svc) + ingress, err := i.getIngress(ctx, job, svc, i.Init.IngressClass) if err != nil { return err }