Skip to content

Commit

Permalink
Use the host set in the Ingess field for the OpenShift Route (#2409)
Browse files Browse the repository at this point in the history
* Use the custom host for OpenShift Routes

Signed-off-by: Israel Blancas <iblancasa@gmail.com>

* Fix autogenerated content

Signed-off-by: Israel Blancas <iblancasa@gmail.com>

---------

Signed-off-by: Israel Blancas <iblancasa@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Co-authored-by: Ruben Vargas <ruben.vp8510@gmail.com>
  • Loading branch information
iblancasa and rubenvp8510 authored Mar 7, 2024
1 parent 173ad1e commit 2583d2a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
6 changes: 6 additions & 0 deletions bundle/manifests/jaeger-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,12 @@ spec:
- patch
- update
- watch
- apiGroups:
- route.openshift.io
resources:
- routes/custom-host
verbs:
- create
serviceAccountName: jaeger-operator
deployments:
- label:
Expand Down
6 changes: 6 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,9 @@ rules:
- patch
- update
- watch
- apiGroups:
- route.openshift.io
resources:
- routes/custom-host
verbs:
- create
1 change: 1 addition & 0 deletions controllers/jaegertracing/jaeger_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func NewReconciler(client client.Client, clientReader client.Reader, scheme *run
// +kubebuilder:rbac:groups=autoscaling,resources=horizontalpodautoscalers,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=networking.k8s.io,resources=ingresses,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=route.openshift.io,resources=routes,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=route.openshift.io,resources=routes/custom-host,verbs=create
// +kubebuilder:rbac:groups=console.openshift.io,resources=consolelinks,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=batch,resources=jobs;cronjobs,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=monitoring.coreos.com,resources=servicemonitors,verbs=get;list;watch;create;update;patch;delete
Expand Down
18 changes: 14 additions & 4 deletions pkg/route/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,27 @@ func (r *QueryRoute) Get() *corev1.Route {
}

var name string

host := ""
if len(r.jaeger.Spec.Ingress.Hosts) > 0 {
host = r.jaeger.Spec.Ingress.Hosts[0]
}

if len(r.jaeger.Namespace) >= 63 {
// the route is doomed already, nothing we can do...
name = r.jaeger.Name
r.jaeger.Logger().V(1).Info(
"the route's hostname will have more than 63 chars and will not be valid",
"name", name,
)
if host == "" {
r.jaeger.Logger().V(1).Info(
"the route's hostname will have more than 63 chars and will not be valid",
"name", name,
)
}
} else {
// -namespace is added to the host by OpenShift
name = util.Truncate(r.jaeger.Name, 62-len(r.jaeger.Namespace))
}
name = util.DNSName(name)

return &corev1.Route{
TypeMeta: metav1.TypeMeta{
Kind: "Route",
Expand Down Expand Up @@ -78,6 +87,7 @@ func (r *QueryRoute) Get() *corev1.Route {
TLS: &corev1.TLSConfig{
Termination: termination,
},
Host: host,
},
}
}

0 comments on commit 2583d2a

Please sign in to comment.