Skip to content

Commit

Permalink
Fix haproxy selector labels
Browse files Browse the repository at this point in the history
  • Loading branch information
indiebrain committed Jan 3, 2024
1 parent 0915ebf commit 6523c76
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ Also check this project's [releases](https://github.com/powerhome/redis-operator

## Unreleased

### Added

- Expose harproxy prometheus exporter metrics on port

### Changed
- [Use the new docker bake tooling to build the developer tools image and remove vestigial development targets from the Makefile](https://github.com/powerhome/redis-operator/pull/31).

### Fixed

- Fix haproxy pod labels so they aren't included in the redis headless service

## [v1.8.0-rc2] - 2023-12-20

### Changed
Expand Down
13 changes: 6 additions & 7 deletions operator/redisfailover/service/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ func generateHAProxyDeployment(rf *redisfailoverv1.RedisFailover, labels map[str

namespace := rf.Namespace

selectorLabels := generateSelectorLabels(haproxyRoleName, rf.Name)
labels = util.MergeLabels(labels, selectorLabels)
labels = util.MergeLabels(labels, generateComponentLabel(haproxyRoleName))
selectorLabels := util.MergeLabels(labels)

volumeMounts := []corev1.VolumeMount{
{
Expand Down Expand Up @@ -97,7 +98,7 @@ func generateHAProxyDeployment(rf *redisfailoverv1.RedisFailover, labels map[str
},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: selectorLabels,
Labels: labels,
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
Expand Down Expand Up @@ -250,11 +251,9 @@ func generateHAProxyService(rf *redisfailoverv1.RedisFailover, labels map[string
}
namespace := rf.Namespace
redisTargetPort := intstr.FromInt(int(rf.Spec.Redis.Port))
selectorLabels := map[string]string{
"app.kubernetes.io/component": "redis",
}
selectorLabels = util.MergeLabels(selectorLabels, generateComponentLabel("haproxy"))
selectorLabels = util.MergeLabels(labels, selectorLabels)
selectorLabels := generateSelectorLabels(haproxyRoleName, rf.Name)
selectorLabels = util.MergeLabels(selectorLabels, generateComponentLabel(haproxyRoleName))
labels = util.MergeLabels(labels, selectorLabels)

spec := corev1.ServiceSpec{
Selector: selectorLabels,
Expand Down
20 changes: 18 additions & 2 deletions operator/redisfailover/service/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1319,11 +1319,19 @@ func TestHaproxyService(t *testing.T) {
Name: "testing",
},
},
Labels: map[string]string{
"app.kubernetes.io/component": "haproxy",
"app.kubernetes.io/name": name,
"app.kubernetes.io/part-of": "redis-failover",
"redisfailovers.databases.spotahome.com/component": "haproxy",
},
},
Spec: corev1.ServiceSpec{
Type: corev1.ServiceTypeClusterIP,
Selector: map[string]string{
"app.kubernetes.io/component": "redis",
"app.kubernetes.io/component": "haproxy",
"app.kubernetes.io/name": name,
"app.kubernetes.io/part-of": "redis-failover",
"redisfailovers.databases.spotahome.com/component": "haproxy",
},
Ports: []corev1.ServicePort{
Expand Down Expand Up @@ -1361,12 +1369,20 @@ func TestHaproxyService(t *testing.T) {
Name: "testing",
},
},
Labels: map[string]string{
"app.kubernetes.io/component": "haproxy",
"app.kubernetes.io/name": name,
"app.kubernetes.io/part-of": "redis-failover",
"redisfailovers.databases.spotahome.com/component": "haproxy",
},
},
Spec: corev1.ServiceSpec{
Type: corev1.ServiceTypeClusterIP,
ClusterIP: "10.1.1.100",
Selector: map[string]string{
"app.kubernetes.io/component": "redis",
"app.kubernetes.io/component": "haproxy",
"app.kubernetes.io/name": name,
"app.kubernetes.io/part-of": "redis-failover",
"redisfailovers.databases.spotahome.com/component": "haproxy",
},
Ports: []corev1.ServicePort{
Expand Down

0 comments on commit 6523c76

Please sign in to comment.