/
service.go
35 lines (29 loc) · 909 Bytes
/
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
// File: zot/service.go
package zot
import (
corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func ExposeZotService(ctx *pulumi.Context, opts ...pulumi.ResourceOption) (*corev1.Service, error) {
ctx.Log.Info("Publishing Zot service...", nil)
servicePorts := corev1.ServicePortArray{}
servicePorts = append(servicePorts, &corev1.ServicePortArgs{
Port: pulumi.Int(5000),
TargetPort: pulumi.Int(5000),
NodePort: pulumi.Int(30000),
})
serviceRes, err := corev1.NewService(ctx, "zot-service", &corev1.ServiceArgs{
Spec: corev1.ServiceSpecArgs{
Selector: pulumi.StringMap{
"app": pulumi.String("zot"),
},
Ports: servicePorts,
Type: pulumi.String("NodePort"),
},
}, opts...)
if err != nil {
return nil, err
}
ctx.Log.Info("Zot OCI Registry Service generated", nil)
return serviceRes, nil
}