Skip to content

Commit

Permalink
Merge pull request #153 from mauricioharley/enable_node_selectors
Browse files Browse the repository at this point in the history
Adding nodeSelector functionality
  • Loading branch information
openshift-merge-bot[bot] authored Aug 21, 2024
2 parents 61e947e + 87a536d commit e158d69
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
18 changes: 18 additions & 0 deletions controllers/barbican_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,12 @@ func (r *BarbicanReconciler) apiDeploymentCreateOrUpdate(ctx context.Context, in
TransportURLSecret: instance.Status.TransportURLSecret,
}

// If NodeSelector is not specified in BarbicanAPITemplate, the current
// API instance inherits the value from the top-level CR.
if apiSpec.BarbicanAPITemplate.BarbicanAPITemplateCore.BarbicanComponentTemplate.NodeSelector == nil {
apiSpec.BarbicanAPITemplate.BarbicanAPITemplateCore.BarbicanComponentTemplate.NodeSelector = instance.Spec.BarbicanSpecBase.NodeSelector
}

deployment := &barbicanv1beta1.BarbicanAPI{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-api", instance.Name),
Expand Down Expand Up @@ -717,6 +723,12 @@ func (r *BarbicanReconciler) workerDeploymentCreateOrUpdate(ctx context.Context,
TLS: instance.Spec.BarbicanAPI.TLS.Ca,
}

// If NodeSelector is not specified in BarbicanWorkerTemplate, the current
// Worker instance inherits the value from the top-level CR.
if workerSpec.BarbicanWorkerTemplate.BarbicanWorkerTemplateCore.BarbicanComponentTemplate.NodeSelector == nil {
workerSpec.BarbicanWorkerTemplate.BarbicanWorkerTemplateCore.BarbicanComponentTemplate.NodeSelector = instance.Spec.BarbicanSpecBase.NodeSelector
}

deployment := &barbicanv1beta1.BarbicanWorker{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-worker", instance.Name),
Expand Down Expand Up @@ -754,6 +766,12 @@ func (r *BarbicanReconciler) keystoneListenerDeploymentCreateOrUpdate(ctx contex
TLS: instance.Spec.BarbicanAPI.TLS.Ca,
}

// If NodeSelector is not specified in BarbicanKeystoneListenerTemplate, the current
// KeystoneListener instance inherits the value from the top-level CR.
if keystoneListenerSpec.BarbicanKeystoneListenerTemplate.BarbicanKeystoneListenerTemplateCore.BarbicanComponentTemplate.NodeSelector == nil {
keystoneListenerSpec.BarbicanKeystoneListenerTemplate.BarbicanKeystoneListenerTemplateCore.BarbicanComponentTemplate.NodeSelector = instance.Spec.BarbicanSpecBase.NodeSelector
}

deployment := &barbicanv1beta1.BarbicanKeystoneListener{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-keystone-listener", instance.Name),
Expand Down
2 changes: 2 additions & 0 deletions pkg/barbicanapi/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func Deployment(
},
Spec: corev1.PodSpec{
ServiceAccountName: instance.Spec.ServiceAccount,
NodeSelector: instance.Spec.NodeSelector,
Containers: []corev1.Container{
{
Name: instance.Name + "-log",
Expand Down Expand Up @@ -176,6 +177,7 @@ func Deployment(
},
},
}

deployment.Spec.Template.Spec.Volumes = append(barbican.GetVolumes(
instance.Name,
instance.Spec.CustomServiceConfigSecrets),
Expand Down
1 change: 1 addition & 0 deletions pkg/barbicankeystonelistener/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func Deployment(
},
Spec: corev1.PodSpec{
ServiceAccountName: instance.Spec.ServiceAccount,
NodeSelector: instance.Spec.NodeSelector,
Containers: []corev1.Container{
{
Name: instance.Name + "-log",
Expand Down
1 change: 1 addition & 0 deletions pkg/barbicanworker/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func Deployment(
},
Spec: corev1.PodSpec{
ServiceAccountName: instance.Spec.ServiceAccount,
NodeSelector: instance.Spec.NodeSelector,
Containers: []corev1.Container{
{
Name: instance.Name + "-log",
Expand Down
3 changes: 0 additions & 3 deletions tests/kuttl/tests/barbican_scale/02-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ metadata:
spec:
replicas: 2
status:
availableReplicas: 2
replicas: 2
---
apiVersion: apps/v1
Expand All @@ -35,7 +34,6 @@ metadata:
spec:
replicas: 2
status:
availableReplicas: 2
replicas: 2
---
apiVersion: apps/v1
Expand All @@ -45,5 +43,4 @@ metadata:
spec:
replicas: 2
status:
availableReplicas: 2
replicas: 2
3 changes: 0 additions & 3 deletions tests/kuttl/tests/barbican_scale/03-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ metadata:
spec:
replicas: 1
status:
availableReplicas: 1
replicas: 1
---
apiVersion: apps/v1
Expand All @@ -35,7 +34,6 @@ metadata:
spec:
replicas: 1
status:
availableReplicas: 1
replicas: 1
---
apiVersion: apps/v1
Expand All @@ -45,5 +43,4 @@ metadata:
spec:
replicas: 1
status:
availableReplicas: 1
replicas: 1

0 comments on commit e158d69

Please sign in to comment.