Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions internal/controller/humiobootstraptoken_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,10 @@ func (r *HumioBootstrapTokenReconciler) constructBootstrapPod(ctx context.Contex
Namespace: bootstrapConfig.Namespace(),
},
Spec: corev1.PodSpec{
ImagePullSecrets: bootstrapConfig.imagePullSecrets(),
Affinity: bootstrapConfig.affinity(),
Tolerations: bootstrapConfig.tolerations(),
ServiceAccountName: bootstrapConfig.humioServiceAccountName(),
ImagePullSecrets: bootstrapConfig.imagePullSecrets(),
Affinity: bootstrapConfig.affinity(),
Tolerations: bootstrapConfig.tolerations(),
Containers: []corev1.Container{
{
Name: HumioContainerName,
Expand Down
10 changes: 10 additions & 0 deletions internal/controller/humiobootstraptoken_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ func (b *HumioBootstrapTokenConfig) resources() corev1.ResourceRequirements {
}
}

func (b *HumioBootstrapTokenConfig) humioServiceAccountName() string {
// If the HumioCluster spec has a service account name set, use that
if b.ManagedHumioCluster.Spec.HumioServiceAccountName != "" {
return b.ManagedHumioCluster.Spec.HumioServiceAccountName
}
// Otherwise, generate the default service account name based on cluster name
// This matches the default behavior when no node pool name is specified
return fmt.Sprintf("%s-%s", b.ManagedHumioCluster.Name, HumioServiceAccountNameSuffix)
}

func (b *HumioBootstrapTokenConfig) PodName() string {
return fmt.Sprintf("%s-%s", b.BootstrapToken.Name, bootstrapTokenPodNameSuffix)
}
Expand Down
9 changes: 9 additions & 0 deletions internal/controller/humiocluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ func (r *HumioClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request
}
}

// ensure service accounts exist for all node pools before creating bootstrap token
// the bootstrap pod needs to reference the service account, so it must exist first
for _, pool := range humioNodePools.Items {
if err := r.ensureHumioPodPermissions(ctx, hc, pool); err != nil {
return r.updateStatus(ctx, r.Status(), hc, statusOptions().
withMessage(err.Error()))
}
}

// create HumioBootstrapToken and block until we have a hashed bootstrap token
if result, err := r.ensureHumioClusterBootstrapToken(ctx, hc); result != emptyResult || err != nil {
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ var _ = Describe("HumioBootstrapToken Controller", func() {

Expect(bootstrapTokenOneTimePod.Name).To(Equal(bootstrapTokenConfig.PodName()))

// Verify service account matches the Humio service account
expectedServiceAccountName := toCreateHumioCluster.Name + "-humio"
Expect(bootstrapTokenOneTimePod.Spec.ServiceAccountName).To(Equal(expectedServiceAccountName))

// Verify node affinity matches
Expect(bootstrapTokenOneTimePod.Spec.Affinity).ToNot(BeNil())
Expect(bootstrapTokenOneTimePod.Spec.Affinity.NodeAffinity).ToNot(BeNil())
Expand Down