Skip to content

Commit

Permalink
Fix cluster annotations propagation to statefulset and pods (#800)
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Pedriza <[email protected]>
Co-authored-by: Adrian Pedriza <[email protected]>
  • Loading branch information
apedriza and AdrianPedriza authored Oct 31, 2024
1 parent 9e78c1f commit 2a64a7b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions internal/controller/k0smotron.io/k0smotroncluster_statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ func (r *ClusterReconciler) findStatefulSetPod(ctx context.Context, statefulSet
func (r *ClusterReconciler) generateStatefulSet(kmc *km.Cluster) (apps.StatefulSet, error) {

labels := labelsForCluster(kmc)
annotations := annotationsForCluster(kmc)

statefulSet := apps.StatefulSet{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Kind: "StatefulSet",
},
ObjectMeta: metav1.ObjectMeta{
Name: kmc.GetStatefulSetName(),
Namespace: kmc.Namespace,
Labels: labels,
Annotations: annotationsForCluster(kmc),
Name: kmc.GetStatefulSetName(),
Namespace: kmc.Namespace,
Labels: labels,
},
Spec: apps.StatefulSetSpec{
Selector: &metav1.LabelSelector{
Expand All @@ -71,7 +71,8 @@ func (r *ClusterReconciler) generateStatefulSet(kmc *km.Cluster) (apps.StatefulS
Replicas: &kmc.Spec.Replicas,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
Labels: labels,
Annotations: annotations,
},
Spec: v1.PodSpec{
AutomountServiceAccountToken: ptr.To(false),
Expand Down Expand Up @@ -310,6 +311,9 @@ data:
statefulSet.Annotations = map[string]string{
statefulSetAnnotation: controller.ComputeHash(&statefulSet.Spec.Template, statefulSet.Status.CollisionCount),
}
for k, v := range annotations {
statefulSet.Annotations[k] = v
}

return statefulSet, err
}
Expand Down

0 comments on commit 2a64a7b

Please sign in to comment.