-
Notifications
You must be signed in to change notification settings - Fork 24
/
gossip.go
48 lines (42 loc) · 1.4 KB
/
gossip.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package memberlist
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
k8slabels "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/intstr"
"github.com/grafana/tempo-operator/apis/tempo/v1alpha1"
"github.com/grafana/tempo-operator/internal/manifests/manifestutils"
"github.com/grafana/tempo-operator/internal/manifests/naming"
)
const (
componentName = "gossip-ring"
)
var (
// GossipSelector declares the labels for each gossip member.
GossipSelector = map[string]string{"tempo-gossip-member": "true"}
)
// BuildGossip creates Kubernetes objects that are needed for memberlist.
func BuildGossip(tempo v1alpha1.TempoStack) *corev1.Service {
labels := manifestutils.ComponentLabels(componentName, tempo.Name)
selector := k8slabels.Merge(manifestutils.CommonLabels(tempo.Name), GossipSelector)
return &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: naming.Name(componentName, tempo.Name),
Namespace: tempo.Namespace,
Labels: labels,
},
Spec: corev1.ServiceSpec{
ClusterIP: "None",
PublishNotReadyAddresses: true,
Selector: selector,
Ports: []corev1.ServicePort{
{
Name: manifestutils.HttpMemberlistPortName,
Protocol: corev1.ProtocolTCP,
Port: manifestutils.PortMemberlist,
TargetPort: intstr.FromString(manifestutils.HttpMemberlistPortName),
},
},
},
}
}