Skip to content

Commit

Permalink
Merge pull request ucloud#69 from ucloud/feature/svc-exporter-port
Browse files Browse the repository at this point in the history
Feature/svc exporter port
  • Loading branch information
gaopenghigh authored Oct 22, 2020
2 parents a01fa97 + 12f703c commit 6eecca8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/resources/services/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,16 @@ func NewHeadLessSvcForCR(cluster *redisv1alpha1.DistributedRedisCluster, name st
}

func NewSvcForCR(cluster *redisv1alpha1.DistributedRedisCluster, name string, labels map[string]string) *corev1.Service {
var ports []corev1.ServicePort
clientPort := corev1.ServicePort{Name: "client", Port: 6379}
gossipPort := corev1.ServicePort{Name: "gossip", Port: 16379}
if cluster.Spec.Monitor == nil {
ports = append(ports, clientPort, gossipPort)
} else {
ports = append(ports, clientPort, gossipPort,
corev1.ServicePort{Name: "prom-http", Port: cluster.Spec.Monitor.Prometheus.Port})
}

svc := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
Expand All @@ -39,7 +47,7 @@ func NewSvcForCR(cluster *redisv1alpha1.DistributedRedisCluster, name string, la
OwnerReferences: redisv1alpha1.DefaultOwnerReferences(cluster),
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{clientPort, gossipPort},
Ports: ports,
Selector: labels,
},
}
Expand Down

0 comments on commit 6eecca8

Please sign in to comment.