forked from kyma-project/kyma
/
subscriber_yaml.go
74 lines (70 loc) · 1.45 KB
/
subscriber_yaml.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package util
import (
appsv1 "k8s.io/api/apps/v1"
apiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
SubscriberName = "test-core-event-bus-subscriber"
)
func NewSubscriberDeployment(sbscrImg string) *appsv1.Deployment {
var replicas int32 = 1
return &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: SubscriberName,
},
Spec: appsv1.DeploymentSpec{
Replicas: &replicas,
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"app": SubscriberName,
},
},
Template: apiv1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"app": SubscriberName,
},
Annotations: map[string]string{
"sidecar.istio.io/inject": "true",
},
},
Spec: apiv1.PodSpec{
Containers: []apiv1.Container{
{
Name: SubscriberName,
Image: sbscrImg,
ImagePullPolicy: "IfNotPresent",
Ports: []apiv1.ContainerPort{
{
ContainerPort: 9000,
},
},
},
},
},
},
},
}
}
func NewSubscriberService() *apiv1.Service {
return &apiv1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: SubscriberName,
Labels: map[string]string{
"app": SubscriberName,
},
},
Spec: apiv1.ServiceSpec{
Selector: map[string]string{
"app": SubscriberName,
},
Ports: []apiv1.ServicePort{
{
Name: "http",
Port: 9000,
},
},
},
}
}