Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support exporter custom port #728

Merged
merged 6 commits into from
Dec 17, 2023
Merged
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
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY k8sutils/ k8sutils/
COPY pkg/ pkg/
COPY mocks/ mocks/

# Build
Expand Down
4 changes: 3 additions & 1 deletion api/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ type ExistingPasswordSecret struct {
// RedisExporter interface will have the information for redis exporter related stuff
// +k8s:deepcopy-gen=true
type RedisExporter struct {
Enabled bool `json:"enabled,omitempty"`
Enabled bool `json:"enabled,omitempty"`
// +kubebuilder:default:=9121
Port *int `json:"port,omitempty"`
Image string `json:"image"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
Expand Down
3 changes: 3 additions & 0 deletions api/v1beta2/rediscluster_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ func (r *RedisCluster) SetDefault() {
if r.Spec.Port == nil {
r.Spec.Port = pointer.Int(6379)
}
if r.Spec.RedisExporter != nil && r.Spec.RedisExporter.Port == nil {
r.Spec.RedisExporter.Port = pointer.Int(9121)
}
}
5 changes: 5 additions & 0 deletions api/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions config/crd/bases/redis.redis.opstreelabs.in_redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,9 @@ spec:
description: PullPolicy describes a policy for if/when to pull
a container image
type: string
port:
default: 9121
type: integer
resources:
description: ResourceRequirements describes the compute resource
requirements.
Expand Down Expand Up @@ -5615,6 +5618,9 @@ spec:
description: PullPolicy describes a policy for if/when to pull
a container image
type: string
port:
default: 9121
type: integer
resources:
description: ResourceRequirements describes the compute resource
requirements.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ spec:
description: PullPolicy describes a policy for if/when to pull
a container image
type: string
port:
default: 9121
type: integer
resources:
description: ResourceRequirements describes the compute resource
requirements.
Expand Down Expand Up @@ -5920,6 +5923,9 @@ spec:
description: PullPolicy describes a policy for if/when to pull
a container image
type: string
port:
default: 9121
type: integer
resources:
description: ResourceRequirements describes the compute resource
requirements.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,9 @@ spec:
description: PullPolicy describes a policy for if/when to pull
a container image
type: string
port:
default: 9121
type: integer
resources:
description: ResourceRequirements describes the compute resource
requirements.
Expand Down Expand Up @@ -5620,6 +5623,9 @@ spec:
description: PullPolicy describes a policy for if/when to pull
a container image
type: string
port:
default: 9121
type: integer
resources:
description: ResourceRequirements describes the compute resource
requirements.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3316,6 +3316,9 @@ spec:
description: PullPolicy describes a policy for if/when to pull
a container image
type: string
port:
default: 9121
type: integer
resources:
description: ResourceRequirements describes the compute resource
requirements.
Expand Down
7 changes: 6 additions & 1 deletion k8sutils/labels.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package k8sutils

import (
"strconv"

redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -111,13 +113,16 @@ func filterAnnotations(anots map[string]string, ignoreAnnots ...string) map[stri
}

// generateServiceAnots generates and returns service annotations
func generateServiceAnots(stsMeta metav1.ObjectMeta, additionalSvcAnnotations map[string]string) map[string]string {
func generateServiceAnots(stsMeta metav1.ObjectMeta, additionalSvcAnnotations map[string]string, epp exporterPortProvider) map[string]string {
anots := map[string]string{
"redis.opstreelabs.in": "true",
"redis.opstreelabs.instance": stsMeta.GetName(),
"prometheus.io/scrape": "true",
"prometheus.io/port": "9121",
}
if exporterPort, ok := epp(); ok {
anots["prometheus.io/port"] = strconv.Itoa(exporterPort)
}
for k, v := range stsMeta.GetAnnotations() {
anots[k] = v
}
Expand Down
2 changes: 1 addition & 1 deletion k8sutils/labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func TestGenerateServiceAnots(t *testing.T) {
"additional-annotation": "additional-value",
}

resultAnnotations := generateServiceAnots(stsMeta, additionalSvcAnnotations)
resultAnnotations := generateServiceAnots(stsMeta, additionalSvcAnnotations, defaultExporterPortProvider)

if !reflect.DeepEqual(resultAnnotations, expectedAnnotations) {
t.Errorf("Expected annotations to be %v but got %v", expectedAnnotations, resultAnnotations)
Expand Down
27 changes: 17 additions & 10 deletions k8sutils/redis-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import (
commonapi "github.com/OT-CONTAINER-KIT/redis-operator/api"
redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
"github.com/OT-CONTAINER-KIT/redis-operator/pkg/util"
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/pointer"
)

// RedisClusterSTS is a interface to call Redis Statefulset function
Expand Down Expand Up @@ -124,11 +126,12 @@
if cr.Spec.RedisExporter.Resources != nil {
containerProp.RedisExporterResources = cr.Spec.RedisExporter.Resources
}

if cr.Spec.RedisExporter.EnvVars != nil {
containerProp.RedisExporterEnv = cr.Spec.RedisExporter.EnvVars
}

if cr.Spec.RedisExporter.Port != nil {
containerProp.RedisExporterPort = cr.Spec.RedisExporter.Port
}

Check warning on line 134 in k8sutils/redis-cluster.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-cluster.go#L133-L134

Added lines #L133 - L134 were not covered by tests
}
if readinessProbeDef != nil {
containerProp.ReadinessProbe = readinessProbeDef
Expand Down Expand Up @@ -235,25 +238,29 @@
serviceName := cr.ObjectMeta.Name + "-" + service.RedisServiceRole
logger := serviceLogger(cr.Namespace, serviceName)
labels := getRedisLabels(serviceName, cluster, service.RedisServiceRole, cr.ObjectMeta.Labels)
annotations := generateServiceAnots(cr.ObjectMeta, nil)
if cr.Spec.RedisExporter != nil && cr.Spec.RedisExporter.Enabled {
enableMetrics = true
var epp exporterPortProvider
if cr.Spec.RedisExporter != nil {
epp = func() (port int, enable bool) {
defaultP := pointer.Int(redisExporterPort)
return *util.Coalesce(cr.Spec.RedisExporter.Port, defaultP), cr.Spec.RedisExporter.Enabled
}

Check warning on line 246 in k8sutils/redis-cluster.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-cluster.go#L241-L246

Added lines #L241 - L246 were not covered by tests
} else {
enableMetrics = false
epp = disableMetrics

Check warning on line 248 in k8sutils/redis-cluster.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-cluster.go#L248

Added line #L248 was not covered by tests
}
annotations := generateServiceAnots(cr.ObjectMeta, nil, epp)

Check warning on line 250 in k8sutils/redis-cluster.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-cluster.go#L250

Added line #L250 was not covered by tests
additionalServiceAnnotations := map[string]string{}
if cr.Spec.KubernetesConfig.Service != nil {
additionalServiceAnnotations = cr.Spec.KubernetesConfig.Service.ServiceAnnotations
}
objectMetaInfo := generateObjectMetaInformation(serviceName, cr.Namespace, labels, annotations)
headlessObjectMetaInfo := generateObjectMetaInformation(serviceName+"-headless", cr.Namespace, labels, annotations)
additionalObjectMetaInfo := generateObjectMetaInformation(serviceName+"-additional", cr.Namespace, labels, generateServiceAnots(cr.ObjectMeta, additionalServiceAnnotations))
err := CreateOrUpdateService(cr.Namespace, headlessObjectMetaInfo, redisClusterAsOwner(cr), false, true, "ClusterIP", *cr.Spec.Port)
additionalObjectMetaInfo := generateObjectMetaInformation(serviceName+"-additional", cr.Namespace, labels, generateServiceAnots(cr.ObjectMeta, additionalServiceAnnotations, epp))
err := CreateOrUpdateService(cr.Namespace, headlessObjectMetaInfo, redisClusterAsOwner(cr), disableMetrics, true, "ClusterIP", *cr.Spec.Port)

Check warning on line 258 in k8sutils/redis-cluster.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-cluster.go#L257-L258

Added lines #L257 - L258 were not covered by tests
if err != nil {
logger.Error(err, "Cannot create headless service for Redis", "Setup.Type", service.RedisServiceRole)
return err
}
err = CreateOrUpdateService(cr.Namespace, objectMetaInfo, redisClusterAsOwner(cr), enableMetrics, false, "ClusterIP", *cr.Spec.Port)
err = CreateOrUpdateService(cr.Namespace, objectMetaInfo, redisClusterAsOwner(cr), epp, false, "ClusterIP", *cr.Spec.Port)

Check warning on line 263 in k8sutils/redis-cluster.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-cluster.go#L263

Added line #L263 was not covered by tests
if err != nil {
logger.Error(err, "Cannot create service for Redis", "Setup.Type", service.RedisServiceRole)
return err
Expand All @@ -262,7 +269,7 @@
if cr.Spec.KubernetesConfig.Service != nil {
additionalServiceType = cr.Spec.KubernetesConfig.Service.ServiceType
}
err = CreateOrUpdateService(cr.Namespace, additionalObjectMetaInfo, redisClusterAsOwner(cr), false, false, additionalServiceType, *cr.Spec.Port)
err = CreateOrUpdateService(cr.Namespace, additionalObjectMetaInfo, redisClusterAsOwner(cr), disableMetrics, false, additionalServiceType, *cr.Spec.Port)

Check warning on line 272 in k8sutils/redis-cluster.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-cluster.go#L272

Added line #L272 was not covered by tests
if err != nil {
logger.Error(err, "Cannot create additional service for Redis", "Setup.Type", service.RedisServiceRole)
return err
Expand Down
26 changes: 17 additions & 9 deletions k8sutils/redis-replication.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
package k8sutils

import redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
import (
redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
"github.com/OT-CONTAINER-KIT/redis-operator/pkg/util"
"k8s.io/utils/pointer"
)

// CreateReplicationService method will create replication service for Redis
func CreateReplicationService(cr *redisv1beta2.RedisReplication) error {
logger := serviceLogger(cr.Namespace, cr.ObjectMeta.Name)
labels := getRedisLabels(cr.ObjectMeta.Name, replication, "replication", cr.ObjectMeta.Labels)
annotations := generateServiceAnots(cr.ObjectMeta, nil)
if cr.Spec.RedisExporter != nil && cr.Spec.RedisExporter.Enabled {
enableMetrics = true
var epp exporterPortProvider
if cr.Spec.RedisExporter != nil {
epp = func() (port int, enable bool) {
defaultP := pointer.Int(redisExporterPort)
return *util.Coalesce(cr.Spec.RedisExporter.Port, defaultP), cr.Spec.RedisExporter.Enabled
}

Check warning on line 18 in k8sutils/redis-replication.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-replication.go#L13-L18

Added lines #L13 - L18 were not covered by tests
} else {
enableMetrics = false
epp = disableMetrics

Check warning on line 20 in k8sutils/redis-replication.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-replication.go#L20

Added line #L20 was not covered by tests
}
annotations := generateServiceAnots(cr.ObjectMeta, nil, epp)

Check warning on line 22 in k8sutils/redis-replication.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-replication.go#L22

Added line #L22 was not covered by tests
additionalServiceAnnotations := map[string]string{}
if cr.Spec.KubernetesConfig.Service != nil {
additionalServiceAnnotations = cr.Spec.KubernetesConfig.Service.ServiceAnnotations
}
objectMetaInfo := generateObjectMetaInformation(cr.ObjectMeta.Name, cr.Namespace, labels, annotations)
headlessObjectMetaInfo := generateObjectMetaInformation(cr.ObjectMeta.Name+"-headless", cr.Namespace, labels, annotations)
additionalObjectMetaInfo := generateObjectMetaInformation(cr.ObjectMeta.Name+"-additional", cr.Namespace, labels, generateServiceAnots(cr.ObjectMeta, additionalServiceAnnotations))
err := CreateOrUpdateService(cr.Namespace, headlessObjectMetaInfo, redisReplicationAsOwner(cr), false, true, "ClusterIP", redisPort)
additionalObjectMetaInfo := generateObjectMetaInformation(cr.ObjectMeta.Name+"-additional", cr.Namespace, labels, generateServiceAnots(cr.ObjectMeta, additionalServiceAnnotations, epp))
err := CreateOrUpdateService(cr.Namespace, headlessObjectMetaInfo, redisReplicationAsOwner(cr), disableMetrics, true, "ClusterIP", redisPort)

Check warning on line 30 in k8sutils/redis-replication.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-replication.go#L29-L30

Added lines #L29 - L30 were not covered by tests
if err != nil {
logger.Error(err, "Cannot create replication headless service for Redis")
return err
}
err = CreateOrUpdateService(cr.Namespace, objectMetaInfo, redisReplicationAsOwner(cr), enableMetrics, false, "ClusterIP", redisPort)
err = CreateOrUpdateService(cr.Namespace, objectMetaInfo, redisReplicationAsOwner(cr), epp, false, "ClusterIP", redisPort)

Check warning on line 35 in k8sutils/redis-replication.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-replication.go#L35

Added line #L35 was not covered by tests
if err != nil {
logger.Error(err, "Cannot create replication service for Redis")
return err
Expand All @@ -33,7 +41,7 @@
if cr.Spec.KubernetesConfig.Service != nil {
additionalServiceType = cr.Spec.KubernetesConfig.Service.ServiceType
}
err = CreateOrUpdateService(cr.Namespace, additionalObjectMetaInfo, redisReplicationAsOwner(cr), false, false, additionalServiceType, redisPort)
err = CreateOrUpdateService(cr.Namespace, additionalObjectMetaInfo, redisReplicationAsOwner(cr), disableMetrics, false, additionalServiceType, redisPort)

Check warning on line 44 in k8sutils/redis-replication.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-replication.go#L44

Added line #L44 was not covered by tests
if err != nil {
logger.Error(err, "Cannot create additional service for Redis Replication")
return err
Expand Down
24 changes: 14 additions & 10 deletions k8sutils/redis-sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"context"
"encoding/json"
"errors"
"github.com/OT-CONTAINER-KIT/redis-operator/pkg/util"
"k8s.io/utils/pointer"

commonapi "github.com/OT-CONTAINER-KIT/redis-operator/api"
redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
Expand Down Expand Up @@ -198,29 +200,31 @@
serviceName := cr.ObjectMeta.Name + "-" + service.RedisServiceRole
logger := serviceLogger(cr.Namespace, serviceName)
labels := getRedisLabels(serviceName, sentinel, service.RedisServiceRole, cr.ObjectMeta.Labels)
annotations := generateServiceAnots(cr.ObjectMeta, nil)

if cr.Spec.RedisExporter != nil && cr.Spec.RedisExporter.Enabled {
enableMetrics = true
var epp exporterPortProvider
if cr.Spec.RedisExporter != nil {
epp = func() (port int, enable bool) {
defaultP := pointer.Int(redisExporterPort)
return *util.Coalesce(cr.Spec.RedisExporter.Port, defaultP), cr.Spec.RedisExporter.Enabled
}

Check warning on line 208 in k8sutils/redis-sentinel.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-sentinel.go#L203-L208

Added lines #L203 - L208 were not covered by tests
} else {
enableMetrics = false
epp = disableMetrics

Check warning on line 210 in k8sutils/redis-sentinel.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-sentinel.go#L210

Added line #L210 was not covered by tests
}

annotations := generateServiceAnots(cr.ObjectMeta, nil, epp)

Check warning on line 212 in k8sutils/redis-sentinel.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-sentinel.go#L212

Added line #L212 was not covered by tests
additionalServiceAnnotations := map[string]string{}
if cr.Spec.KubernetesConfig.Service != nil {
additionalServiceAnnotations = cr.Spec.KubernetesConfig.Service.ServiceAnnotations
}

objectMetaInfo := generateObjectMetaInformation(serviceName, cr.Namespace, labels, annotations)
headlessObjectMetaInfo := generateObjectMetaInformation(serviceName+"-headless", cr.Namespace, labels, annotations)
additionalObjectMetaInfo := generateObjectMetaInformation(serviceName+"-additional", cr.Namespace, labels, generateServiceAnots(cr.ObjectMeta, additionalServiceAnnotations))
additionalObjectMetaInfo := generateObjectMetaInformation(serviceName+"-additional", cr.Namespace, labels, generateServiceAnots(cr.ObjectMeta, additionalServiceAnnotations, epp))

Check warning on line 220 in k8sutils/redis-sentinel.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-sentinel.go#L220

Added line #L220 was not covered by tests

err := CreateOrUpdateService(cr.Namespace, headlessObjectMetaInfo, redisSentinelAsOwner(cr), false, true, "ClusterIP", sentinelPort)
err := CreateOrUpdateService(cr.Namespace, headlessObjectMetaInfo, redisSentinelAsOwner(cr), disableMetrics, true, "ClusterIP", sentinelPort)

Check warning on line 222 in k8sutils/redis-sentinel.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-sentinel.go#L222

Added line #L222 was not covered by tests
if err != nil {
logger.Error(err, "Cannot create headless service for Redis", "Setup.Type", service.RedisServiceRole)
return err
}
err = CreateOrUpdateService(cr.Namespace, objectMetaInfo, redisSentinelAsOwner(cr), enableMetrics, false, "ClusterIP", sentinelPort)
err = CreateOrUpdateService(cr.Namespace, objectMetaInfo, redisSentinelAsOwner(cr), epp, false, "ClusterIP", sentinelPort)

Check warning on line 227 in k8sutils/redis-sentinel.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-sentinel.go#L227

Added line #L227 was not covered by tests
if err != nil {
logger.Error(err, "Cannot create service for Redis", "Setup.Type", service.RedisServiceRole)
return err
Expand All @@ -230,7 +234,7 @@
if cr.Spec.KubernetesConfig.Service != nil {
additionalServiceType = cr.Spec.KubernetesConfig.Service.ServiceType
}
err = CreateOrUpdateService(cr.Namespace, additionalObjectMetaInfo, redisSentinelAsOwner(cr), false, false, additionalServiceType, sentinelPort)
err = CreateOrUpdateService(cr.Namespace, additionalObjectMetaInfo, redisSentinelAsOwner(cr), disableMetrics, false, additionalServiceType, sentinelPort)

Check warning on line 237 in k8sutils/redis-sentinel.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-sentinel.go#L237

Added line #L237 was not covered by tests
if err != nil {
logger.Error(err, "Cannot create additional service for Redis", "Setup.Type", service.RedisServiceRole)
return err
Expand Down
32 changes: 20 additions & 12 deletions k8sutils/redis-standalone.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
package k8sutils

import redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"

var (
enableMetrics bool
import (
redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
"github.com/OT-CONTAINER-KIT/redis-operator/pkg/util"
"k8s.io/utils/pointer"
)

//var (
// enableMetrics bool
//)

// CreateStandaloneService method will create standalone service for Redis
func CreateStandaloneService(cr *redisv1beta2.Redis) error {
logger := serviceLogger(cr.Namespace, cr.ObjectMeta.Name)
labels := getRedisLabels(cr.ObjectMeta.Name, standalone, "standalone", cr.ObjectMeta.Labels)
annotations := generateServiceAnots(cr.ObjectMeta, nil)
if cr.Spec.RedisExporter != nil && cr.Spec.RedisExporter.Enabled {
enableMetrics = true
var epp exporterPortProvider
if cr.Spec.RedisExporter != nil {
epp = func() (port int, enable bool) {
defaultP := pointer.Int(redisExporterPort)
return *util.Coalesce(cr.Spec.RedisExporter.Port, defaultP), cr.Spec.RedisExporter.Enabled
}

Check warning on line 22 in k8sutils/redis-standalone.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-standalone.go#L17-L22

Added lines #L17 - L22 were not covered by tests
} else {
enableMetrics = false
epp = disableMetrics

Check warning on line 24 in k8sutils/redis-standalone.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-standalone.go#L24

Added line #L24 was not covered by tests
}
annotations := generateServiceAnots(cr.ObjectMeta, nil, epp)

Check warning on line 26 in k8sutils/redis-standalone.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-standalone.go#L26

Added line #L26 was not covered by tests
additionalServiceAnnotations := map[string]string{}
if cr.Spec.KubernetesConfig.Service != nil {
additionalServiceAnnotations = cr.Spec.KubernetesConfig.Service.ServiceAnnotations
}
objectMetaInfo := generateObjectMetaInformation(cr.ObjectMeta.Name, cr.Namespace, labels, annotations)
headlessObjectMetaInfo := generateObjectMetaInformation(cr.ObjectMeta.Name+"-headless", cr.Namespace, labels, annotations)
additionalObjectMetaInfo := generateObjectMetaInformation(cr.ObjectMeta.Name+"-additional", cr.Namespace, labels, generateServiceAnots(cr.ObjectMeta, additionalServiceAnnotations))
err := CreateOrUpdateService(cr.Namespace, headlessObjectMetaInfo, redisAsOwner(cr), false, true, "ClusterIP", redisPort)
additionalObjectMetaInfo := generateObjectMetaInformation(cr.ObjectMeta.Name+"-additional", cr.Namespace, labels, generateServiceAnots(cr.ObjectMeta, additionalServiceAnnotations, epp))
err := CreateOrUpdateService(cr.Namespace, headlessObjectMetaInfo, redisAsOwner(cr), disableMetrics, true, "ClusterIP", redisPort)

Check warning on line 34 in k8sutils/redis-standalone.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-standalone.go#L33-L34

Added lines #L33 - L34 were not covered by tests
if err != nil {
logger.Error(err, "Cannot create standalone headless service for Redis")
return err
}
err = CreateOrUpdateService(cr.Namespace, objectMetaInfo, redisAsOwner(cr), enableMetrics, false, "ClusterIP", redisPort)
err = CreateOrUpdateService(cr.Namespace, objectMetaInfo, redisAsOwner(cr), epp, false, "ClusterIP", redisPort)

Check warning on line 39 in k8sutils/redis-standalone.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-standalone.go#L39

Added line #L39 was not covered by tests
if err != nil {
logger.Error(err, "Cannot create standalone service for Redis")
return err
Expand All @@ -37,7 +45,7 @@
if cr.Spec.KubernetesConfig.Service != nil {
additionalServiceType = cr.Spec.KubernetesConfig.Service.ServiceType
}
err = CreateOrUpdateService(cr.Namespace, additionalObjectMetaInfo, redisAsOwner(cr), false, false, additionalServiceType, redisPort)
err = CreateOrUpdateService(cr.Namespace, additionalObjectMetaInfo, redisAsOwner(cr), disableMetrics, false, additionalServiceType, redisPort)

Check warning on line 48 in k8sutils/redis-standalone.go

View check run for this annotation

Codecov / codecov/patch

k8sutils/redis-standalone.go#L48

Added line #L48 was not covered by tests
if err != nil {
logger.Error(err, "Cannot create additional service for Redis")
return err
Expand Down
Loading
Loading