Skip to content

Commit be66f1b

Browse files
committed
Allow ingresses enable to be called multiple times.
1 parent c5eb07e commit be66f1b

1 file changed

Lines changed: 38 additions & 28 deletions

File tree

deployment/caodeploy/deployer.go

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -501,46 +501,56 @@ func (d *Deployer) EnableIngresses(ctx context.Context, clusterID string) error
501501
return err
502502
}
503503

504-
d.logger.Info("creating ui route")
505-
506-
// this must be a short name or we hit dns name length limits
507-
err = d.client.CreateRoute(ctx, namespace, "ui", map[string]interface{}{
508-
"tls": map[string]interface{}{
509-
"termination": "edge",
510-
},
511-
"to": map[string]interface{}{
512-
"kind": "Service",
513-
"name": UiServiceName,
514-
},
515-
"port": map[string]interface{}{
516-
"targetPort": 8091,
517-
},
518-
})
519-
if err != nil {
520-
return errors.Wrap(err, "failed to create ui route")
521-
}
522-
523-
_, err = d.client.GetService(ctx, namespace, CngServiceName)
504+
_, err = d.client.GetRouteHost(ctx, namespace, "ui")
524505
if err != nil {
525-
d.logger.Info("no cng service detected")
526-
} else {
527-
d.logger.Info("cng service detected, creating cng route")
506+
d.logger.Info("creating ui route")
528507

529508
// this must be a short name or we hit dns name length limits
530-
err = d.client.CreateRoute(ctx, namespace, "cng", map[string]interface{}{
509+
err = d.client.CreateRoute(ctx, namespace, "ui", map[string]interface{}{
531510
"tls": map[string]interface{}{
532-
"termination": "passthrough",
511+
"termination": "edge",
533512
},
534513
"to": map[string]interface{}{
535514
"kind": "Service",
536-
"name": CngServiceName,
515+
"name": UiServiceName,
537516
},
538517
"port": map[string]interface{}{
539-
"targetPort": 18098,
518+
"targetPort": 8091,
540519
},
541520
})
542521
if err != nil {
543-
return errors.Wrap(err, "failed to create cng route")
522+
return errors.Wrap(err, "failed to create ui route")
523+
}
524+
} else {
525+
d.logger.Info("ui route already exists, skipping creation")
526+
}
527+
528+
_, err = d.client.GetService(ctx, namespace, CngServiceName)
529+
if err != nil {
530+
d.logger.Info("no cng service detected")
531+
} else {
532+
_, err = d.client.GetRouteHost(ctx, namespace, "cng")
533+
if err != nil {
534+
d.logger.Info("cng service detected, creating cng route")
535+
536+
// this must be a short name or we hit dns name length limits
537+
err = d.client.CreateRoute(ctx, namespace, "cng", map[string]interface{}{
538+
"tls": map[string]interface{}{
539+
"termination": "passthrough",
540+
},
541+
"to": map[string]interface{}{
542+
"kind": "Service",
543+
"name": CngServiceName,
544+
},
545+
"port": map[string]interface{}{
546+
"targetPort": 18098,
547+
},
548+
})
549+
if err != nil {
550+
return errors.Wrap(err, "failed to create cng route")
551+
}
552+
} else {
553+
d.logger.Info("cng route already exists, skipping creation")
544554
}
545555
}
546556

0 commit comments

Comments
 (0)