-
Notifications
You must be signed in to change notification settings - Fork 62
/
route.go
46 lines (40 loc) · 1.35 KB
/
route.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
package routes
import (
routev1 "github.com/openshift/api/route/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
logf "sigs.k8s.io/controller-runtime"
)
var log = logf.Log.WithName("package routes")
// Create newRouteForCR method to create exposed route
//func NewRouteDefinitionForCR(cr *v2alpha1.ActiveMQArtemis, labels map[string]string, targetServiceName string, targetPortName string, passthroughTLS bool) *routev1.Route {
func NewRouteDefinitionForCR(namespacedName types.NamespacedName, labels map[string]string, targetServiceName string, targetPortName string, passthroughTLS bool) *routev1.Route {
route := &routev1.Route{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "Route",
},
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
Name: targetServiceName + "-rte",
Namespace: namespacedName.Namespace,
},
Spec: routev1.RouteSpec{
Port: &routev1.RoutePort{
TargetPort: intstr.FromString(targetPortName),
},
To: routev1.RouteTargetReference{
Kind: "Service",
Name: targetServiceName,
},
},
}
if passthroughTLS {
route.Spec.TLS = &routev1.TLSConfig{
Termination: routev1.TLSTerminationPassthrough,
InsecureEdgeTerminationPolicy: routev1.InsecureEdgeTerminationPolicyNone,
}
}
return route
}