Skip to content

Commit f626b80

Browse files
jpolerJon Poler
and
Jon Poler
authored
feat: make ClusterIssuer optional to allow certmanager defaults (armadaproject#299)
Co-authored-by: Jon Poler <jpoler@evaav.com>
1 parent 4e1b2a6 commit f626b80

12 files changed

+36
-20
lines changed

api/install/v1alpha1/armadaserver_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type ArmadaServerSpec struct {
3434
// An array of host names to build ingress rules for
3535
HostNames []string `json:"hostNames,omitempty"`
3636
// Who is issuing certificates for CA
37-
ClusterIssuer string `json:"clusterIssuer"`
37+
ClusterIssuer string `json:"clusterIssuer,omitempty"`
3838
// Run Pulsar Init Jobs On Startup
3939
PulsarInit bool `json:"pulsarInit,omitempty"`
4040
// SecurityContext defines the security options the container should be run with

api/install/v1alpha1/binoculars_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type BinocularsSpec struct {
5858
// An array of host names to build ingress rules for
5959
HostNames []string `json:"hostNames,omitempty"`
6060
// Who is issuing certificates for CA
61-
ClusterIssuer string `json:"clusterIssuer"`
61+
ClusterIssuer string `json:"clusterIssuer,omitempty"`
6262
// SecurityContext defines the security options the container should be run with
6363
SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"`
6464
// PodSecurityContext defines the security options the pod should be run with

api/install/v1alpha1/lookout_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type LookoutSpec struct {
5858
// An array of host names to build ingress rules for
5959
HostNames []string `json:"hostNames,omitempty"`
6060
// Who is issuing certificates for CA
61-
ClusterIssuer string `json:"clusterIssuer"`
61+
ClusterIssuer string `json:"clusterIssuer,omitempty"`
6262
// Migrate toggles whether to run migrations when installed
6363
Migrate *bool `json:"migrate,omitempty"`
6464
// DbPruningEnabled when true a pruning CronJob is created

api/install/v1alpha1/scheduler_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type SchedulerSpec struct {
5656
// An array of host names to build ingress rules for
5757
HostNames []string `json:"hostNames,omitempty"`
5858
// Who is issuing certificates for CA
59-
ClusterIssuer string `json:"clusterIssuer"`
59+
ClusterIssuer string `json:"clusterIssuer,omitempty"`
6060
// Migrate toggles whether to run migrations when installed
6161
Migrate *bool `json:"migrate,omitempty"`
6262
// Pruning config for cron job

config/crd/bases/install.armadaproject.io_armadaservers.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -2368,7 +2368,6 @@ spec:
23682368
type: array
23692369
required:
23702370
- applicationConfig
2371-
- clusterIssuer
23722371
- image
23732372
type: object
23742373
status:

config/crd/bases/install.armadaproject.io_binoculars.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -2365,7 +2365,6 @@ spec:
23652365
type: array
23662366
required:
23672367
- applicationConfig
2368-
- clusterIssuer
23692368
- image
23702369
- replicas
23712370
type: object

config/crd/bases/install.armadaproject.io_lookouts.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -2374,7 +2374,6 @@ spec:
23742374
type: array
23752375
required:
23762376
- applicationConfig
2377-
- clusterIssuer
23782377
- image
23792378
type: object
23802379
status:

config/crd/bases/install.armadaproject.io_schedulers.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -2434,7 +2434,6 @@ spec:
24342434
type: array
24352435
required:
24362436
- applicationConfig
2437-
- clusterIssuer
24382437
- image
24392438
type: object
24402439
status:

internal/controller/install/armadaserver_controller.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,15 @@ func createIngressGrpc(as *installv1alpha1.ArmadaServer) (*networkingv1.Ingress,
593593
"kubernetes.io/ingress.class": as.Spec.Ingress.IngressClass,
594594
"nginx.ingress.kubernetes.io/ssl-redirect": "true",
595595
"nginx.ingress.kubernetes.io/backend-protocol": "GRPC",
596-
"certmanager.k8s.io/cluster-issuer": as.Spec.ClusterIssuer,
597-
"cert-manager.io/cluster-issuer": as.Spec.ClusterIssuer,
598596
},
599597
},
600598
}
599+
600+
if as.Spec.ClusterIssuer != "" {
601+
grpcIngress.ObjectMeta.Annotations["certmanager.k8s.io/cluster-issuer"] = as.Spec.ClusterIssuer
602+
grpcIngress.ObjectMeta.Annotations["cert-manager.io/cluster-issuer"] = as.Spec.ClusterIssuer
603+
}
604+
601605
if as.Spec.Ingress.Annotations != nil {
602606
for key, value := range as.Spec.Ingress.Annotations {
603607
grpcIngress.ObjectMeta.Annotations[key] = value
@@ -643,14 +647,17 @@ func createIngressHttp(as *installv1alpha1.ArmadaServer) (*networkingv1.Ingress,
643647
Name: restIngressName, Namespace: as.Namespace, Labels: AllLabels(as.Name, as.Labels),
644648
Annotations: map[string]string{
645649
"kubernetes.io/ingress.class": as.Spec.Ingress.IngressClass,
646-
"certmanager.k8s.io/cluster-issuer": as.Spec.ClusterIssuer,
647-
"cert-manager.io/cluster-issuer": as.Spec.ClusterIssuer,
648650
"nginx.ingress.kubernetes.io/rewrite-target": "/$2",
649651
"nginx.ingress.kubernetes.io/ssl-redirect": "true",
650652
},
651653
},
652654
}
653655

656+
if as.Spec.ClusterIssuer != "" {
657+
restIngress.ObjectMeta.Annotations["certmanager.k8s.io/cluster-issuer"] = as.Spec.ClusterIssuer
658+
restIngress.ObjectMeta.Annotations["cert-manager.io/cluster-issuer"] = as.Spec.ClusterIssuer
659+
}
660+
654661
if as.Spec.Ingress.Annotations != nil {
655662
for key, value := range as.Spec.Ingress.Annotations {
656663
restIngress.ObjectMeta.Annotations[key] = value

internal/controller/install/binoculars_controller.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,15 @@ func createBinocularsIngressGrpc(binoculars *installv1alpha1.Binoculars) (*netwo
396396
"kubernetes.io/ingress.class": binoculars.Spec.Ingress.IngressClass,
397397
"nginx.ingress.kubernetes.io/ssl-redirect": "true",
398398
"nginx.ingress.kubernetes.io/backend-protocol": "GRPC",
399-
"certmanager.k8s.io/cluster-issuer": binoculars.Spec.ClusterIssuer,
400-
"cert-manager.io/cluster-issuer": binoculars.Spec.ClusterIssuer,
401399
},
402400
},
403401
}
402+
403+
if binoculars.Spec.ClusterIssuer != "" {
404+
grpcIngress.ObjectMeta.Annotations["certmanager.k8s.io/cluster-issuer"] = binoculars.Spec.ClusterIssuer
405+
grpcIngress.ObjectMeta.Annotations["cert-manager.io/cluster-issuer"] = binoculars.Spec.ClusterIssuer
406+
}
407+
404408
if binoculars.Spec.Ingress.Annotations != nil {
405409
for key, value := range binoculars.Spec.Ingress.Annotations {
406410
grpcIngress.ObjectMeta.Annotations[key] = value
@@ -445,14 +449,17 @@ func createBinocularsIngressHttp(binoculars *installv1alpha1.Binoculars) (*netwo
445449
ObjectMeta: metav1.ObjectMeta{Name: restIngressName, Namespace: binoculars.Namespace, Labels: AllLabels(binoculars.Name, binoculars.Labels),
446450
Annotations: map[string]string{
447451
"kubernetes.io/ingress.class": binoculars.Spec.Ingress.IngressClass,
448-
"certmanager.k8s.io/cluster-issuer": binoculars.Spec.ClusterIssuer,
449-
"cert-manager.io/cluster-issuer": binoculars.Spec.ClusterIssuer,
450452
"nginx.ingress.kubernetes.io/rewrite-target": "/$2",
451453
"nginx.ingress.kubernetes.io/ssl-redirect": "true",
452454
},
453455
},
454456
}
455457

458+
if binoculars.Spec.ClusterIssuer != "" {
459+
restIngress.ObjectMeta.Annotations["certmanager.k8s.io/cluster-issuer"] = binoculars.Spec.ClusterIssuer
460+
restIngress.ObjectMeta.Annotations["cert-manager.io/cluster-issuer"] = binoculars.Spec.ClusterIssuer
461+
}
462+
456463
if binoculars.Spec.Ingress.Annotations != nil {
457464
for key, value := range binoculars.Spec.Ingress.Annotations {
458465
restIngress.ObjectMeta.Annotations[key] = value

internal/controller/install/lookout_controller.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -383,13 +383,16 @@ func createLookoutIngressHttp(lookout *installv1alpha1.Lookout) (*networking.Ing
383383
Name: ingressName, Namespace: lookout.Namespace, Labels: AllLabels(lookout.Name, lookout.Labels),
384384
Annotations: map[string]string{
385385
"kubernetes.io/ingress.class": lookout.Spec.Ingress.IngressClass,
386-
"certmanager.k8s.io/cluster-issuer": lookout.Spec.ClusterIssuer,
387-
"cert-manager.io/cluster-issuer": lookout.Spec.ClusterIssuer,
388386
"nginx.ingress.kubernetes.io/ssl-redirect": "true",
389387
},
390388
},
391389
}
392390

391+
if lookout.Spec.ClusterIssuer != "" {
392+
ingressHttp.ObjectMeta.Annotations["certmanager.k8s.io/cluster-issuer"] = lookout.Spec.ClusterIssuer
393+
ingressHttp.ObjectMeta.Annotations["cert-manager.io/cluster-issuer"] = lookout.Spec.ClusterIssuer
394+
}
395+
393396
if lookout.Spec.Ingress.Annotations != nil {
394397
for key, value := range lookout.Spec.Ingress.Annotations {
395398
ingressHttp.ObjectMeta.Annotations[key] = value

internal/controller/install/scheduler_controller.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,15 @@ func createSchedulerIngressGrpc(scheduler *installv1alpha1.Scheduler) (*networki
375375
"kubernetes.io/ingress.class": scheduler.Spec.Ingress.IngressClass,
376376
"nginx.ingress.kubernetes.io/ssl-redirect": "true",
377377
"nginx.ingress.kubernetes.io/backend-protocol": "GRPC",
378-
"certmanager.k8s.io/cluster-issuer": scheduler.Spec.ClusterIssuer,
379-
"cert-manager.io/cluster-issuer": scheduler.Spec.ClusterIssuer,
380378
},
381379
},
382380
}
383381

382+
if scheduler.Spec.ClusterIssuer != "" {
383+
ingressHttp.ObjectMeta.Annotations["certmanager.k8s.io/cluster-issuer"] = scheduler.Spec.ClusterIssuer
384+
ingressHttp.ObjectMeta.Annotations["cert-manager.io/cluster-issuer"] = scheduler.Spec.ClusterIssuer
385+
}
386+
384387
if scheduler.Spec.Ingress.Annotations != nil {
385388
for key, value := range scheduler.Spec.Ingress.Annotations {
386389
ingressHttp.ObjectMeta.Annotations[key] = value

0 commit comments

Comments
 (0)