Skip to content

Commit

Permalink
Set the ingressClassName based on flags, default to nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
John Wregglesworth committed Dec 11, 2024
1 parent 96f8ed0 commit d9840ca
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
3 changes: 2 additions & 1 deletion external/ingresser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 5 additions & 7 deletions internal/ingresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
3 changes: 2 additions & 1 deletion internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ type Init struct {
KeycloakClientID string
KeycloakClientSecret string
IRODSZone string
IngressClass string
NATSEncodedConn *nats.EncodedConn
}

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

0 comments on commit d9840ca

Please sign in to comment.