Skip to content

Commit 243ff47

Browse files
authored
Merge pull request #495 from jiuker/feature_keep_rf_annotations
[feature]add rf Annotations to sts
2 parents 94cea5b + af99b4f commit 243ff47

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

operator/redisfailover/service/generator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ func generateRedisStatefulSet(rf *redisfailoverv1.RedisFailover, labels map[stri
280280

281281
ss := &appsv1.StatefulSet{
282282
ObjectMeta: metav1.ObjectMeta{
283+
Annotations: rf.Annotations,
283284
Name: name,
284285
Namespace: namespace,
285286
Labels: labels,

operator/redisfailover/util/label.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,15 @@ func MergeLabels(allLabels ...map[string]string) map[string]string {
1111
}
1212
return res
1313
}
14+
15+
// MergeAnnotations merges all the annotations maps received as argument into a single new label map.
16+
func MergeAnnotations(allMergeAnnotations ...map[string]string) map[string]string {
17+
res := map[string]string{}
18+
19+
for _, labels := range allMergeAnnotations {
20+
for k, v := range labels {
21+
res[k] = v
22+
}
23+
}
24+
return res
25+
}

service/k8s/statefulset.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"fmt"
66
"strings"
77

8+
"github.com/spotahome/redis-operator/operator/redisfailover/util"
9+
810
appsv1 "k8s.io/api/apps/v1"
911
corev1 "k8s.io/api/core/v1"
1012
"k8s.io/apimachinery/pkg/api/errors"
@@ -105,6 +107,7 @@ func (s *StatefulSetService) CreateOrUpdateStatefulSet(namespace string, statefu
105107
// namespace is our spec(https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#concurrency-control-and-consistency),
106108
// we will replace the current namespace state.
107109
statefulSet.ResourceVersion = storedStatefulSet.ResourceVersion
110+
statefulSet.Annotations = util.MergeAnnotations(statefulSet.Annotations, storedStatefulSet.Annotations)
108111
return s.UpdateStatefulSet(namespace, statefulSet)
109112
}
110113

0 commit comments

Comments
 (0)