forked from goharbor/harbor-operator
/
services.go
39 lines (34 loc) · 1.01 KB
/
services.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
package notarysigner
import (
"context"
goharborv1 "github.com/plotly/harbor-operator/apis/goharbor.io/v1beta1"
harbormetav1 "github.com/plotly/harbor-operator/apis/meta/v1alpha1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
const (
PublicPort = 80
)
func (r *Reconciler) GetService(ctx context.Context, notary *goharborv1.NotarySigner) (*corev1.Service, error) {
name := r.NormalizeName(ctx, notary.GetName())
namespace := notary.GetNamespace()
return &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{{
Name: harbormetav1.NotarySignerAPIPortName,
Port: goharborv1.NotarySignerAPIPort,
TargetPort: intstr.FromString(harbormetav1.NotarySignerAPIPortName),
Protocol: corev1.ProtocolTCP,
}},
Selector: map[string]string{
r.Label("name"): name,
r.Label("namespace"): namespace,
},
},
}, nil
}