This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
/
master_service.go
57 lines (53 loc) · 1.71 KB
/
master_service.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
49
50
51
52
53
54
55
56
57
package service
import (
"github.com/giantswarm/apiextensions/v3/pkg/apis/provider/v1alpha1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/giantswarm/kvm-operator/service/controller/key"
)
func newMasterService(customObject v1alpha1.KVMConfig) *corev1.Service {
service := &corev1.Service{
TypeMeta: metav1.TypeMeta{
Kind: "service",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: key.MasterID,
Namespace: key.ClusterID(customObject),
Labels: map[string]string{
key.LegacyLabelCluster: key.ClusterID(customObject),
key.LabelCustomer: key.ClusterCustomer(customObject),
key.LabelApp: key.MasterID,
key.LabelCluster: key.ClusterID(customObject),
key.LabelOrganization: key.ClusterCustomer(customObject),
key.LabelVersionBundle: key.OperatorVersion(customObject),
},
Annotations: map[string]string{
key.AnnotationEtcdDomain: key.ClusterEtcdDomain(customObject),
key.AnnotationPrometheusCluster: key.ClusterID(customObject),
"prometheus.io/path": "/healthz",
"prometheus.io/port": "30010",
"prometheus.io/scheme": "http",
"prometheus.io/scrape": "true",
},
},
Spec: corev1.ServiceSpec{
Type: corev1.ServiceTypeClusterIP,
Ports: []corev1.ServicePort{
{
Name: "etcd",
Port: int32(2379),
Protocol: "TCP",
},
{
Name: "api",
Port: int32(customObject.Spec.Cluster.Kubernetes.API.SecurePort),
Protocol: "TCP",
},
},
// Note that we do not use a selector definition on purpose to be able to
// manually set the IP address of the actual VM.
},
}
return service
}