func getService(namespace string, service string) (*corev1.Service, error) {
	logger := serviceLogger(namespace, service)
	serviceInfo, err := generateK8sClient().CoreV1().Services(namespace).Get(context.TODO(), service, metav1.GetOptions{})
	if err != nil {
		logger.Info("Redis service get action is failed")
		return nil, err
	}
	logger.Info("Redis service get action is successful")
	return serviceInfo, nil
}
getService is a method to get service is Kubernetes
package k8sutils
import (
	"context"
	"github.com/banzaicloud/k8s-objectmatcher/patch"
	"github.com/go-logr/logr"
	corev1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/api/errors"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/util/intstr"
)
const (
	redisPort         = 6379
	redisExporterPort = 9121
)
var (
	serviceType corev1.ServiceType
)
func generateHeadlessServiceDef(serviceMeta metav1.ObjectMeta, labels map[string]string, ownerDef metav1.OwnerReference) *corev1.Service {
	service := &corev1.Service{
		TypeMeta:   generateMetaInformation("Service", "core/v1"),
		ObjectMeta: serviceMeta,
		Spec: corev1.ServiceSpec{
			ClusterIP: "None",
			Selector:  labels,
			Ports: []corev1.ServicePort{
				{
					Name:       "redis-client",
					Port:       redisPort,
					TargetPort: intstr.FromInt(int(redisPort)),
					Protocol:   corev1.ProtocolTCP,
				},
			},
		},
	}
	AddOwnerRefToObject(service, ownerDef)
	return service
}
func generateServiceDef(serviceMeta metav1.ObjectMeta, labels map[string]string, enableMetrics bool, ownerDef metav1.OwnerReference) *corev1.Service {
	service := &corev1.Service{
		TypeMeta:   generateMetaInformation("Service", "core/v1"),
		ObjectMeta: serviceMeta,
		Spec: corev1.ServiceSpec{
			Type:     generateServiceType("ClusterIP"),
			Selector: labels,
			Ports: []corev1.ServicePort{
				{
					Name:       "redis-client",
					Port:       redisPort,
					TargetPort: intstr.FromInt(int(redisPort)),
					Protocol:   corev1.ProtocolTCP,
				},
			},
		},
	}
	if enableMetrics {
		redisExporterService := enableMetricsPort()
		service.Spec.Ports = append(service.Spec.Ports, *redisExporterService)
	}
	AddOwnerRefToObject(service, ownerDef)
	return service
}
func enableMetricsPort() *corev1.ServicePort {
	return &corev1.ServicePort{
		Name:       "redis-exporter",
		Port:       redisExporterPort,
		TargetPort: intstr.FromInt(int(redisExporterPort)),
		Protocol:   corev1.ProtocolTCP,
	}
}
func generateServiceType(k8sServiceType string) corev1.ServiceType {
	switch k8sServiceType {
	case "LoadBalancer":
		serviceType = corev1.ServiceTypeLoadBalancer
	case "NodePort":
		serviceType = corev1.ServiceTypeNodePort
	case "ClusterIP":
		serviceType = corev1.ServiceTypeClusterIP
	default:
		serviceType = corev1.ServiceTypeClusterIP
	}
	return serviceType
}
func createService(namespace string, service *corev1.Service) error {
	logger := serviceLogger(namespace, service.Name)
	_, err := generateK8sClient().CoreV1().Services(namespace).Create(context.TODO(), service, metav1.CreateOptions{})
	if err != nil {
		logger.Error(err, "Redis service creation is failed")
		return err
	}
	logger.Info("Redis service creation is successful")
	return nil
}
func updateService(namespace string, service *corev1.Service) error {
	logger := serviceLogger(namespace, service.Name)
	_, err := generateK8sClient().CoreV1().Services(namespace).Update(context.TODO(), service, metav1.UpdateOptions{})
	if err != nil {
		logger.Error(err, "Redis service updation is failed")
		return err
	}
	logger.Info("Redis service updation is successful")
	return nil
}