Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #1568 #2456

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ rules:
- apiGroups:
- networking.k8s.io
resources:
- ingressclasses
- ingresses
verbs:
- create
Expand Down
2 changes: 1 addition & 1 deletion controllers/jaegertracing/jaeger_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewReconciler(client client.Client, clientReader client.Reader, scheme *run
// +kubebuilder:rbac:groups=apps,resources=deployments;daemonsets;replicasets;statefulsets,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=extensions,resources=ingresses,verbs=get;list;watch;create;update;patch;delete
// +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=networking.k8s.io,resources=ingresses;ingressclasses,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=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
Expand Down
36 changes: 35 additions & 1 deletion pkg/ingress/query.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package ingress

import (
"context"
"fmt"

networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

v1 "github.com/jaegertracing/jaeger-operator/apis/v1"
"github.com/jaegertracing/jaeger-operator/pkg/service"
Expand Down Expand Up @@ -52,6 +54,38 @@ func (i *QueryIngress) Get() *networkingv1.Ingress {

if i.jaeger.Spec.Ingress.IngressClassName != nil {
spec.IngressClassName = i.jaeger.Spec.Ingress.IngressClassName
} else {
class := ""
nginxIngressAvailable := false
config, err := rest.InClusterConfig()
if err == nil {
clientSet, err := kubernetes.NewForConfig(config)
if err == nil {
ingressList, err := clientSet.NetworkingV1().IngressClasses().List(context.Background(), metav1.ListOptions{})
if err == nil {
for _, ingress := range ingressList.Items {
if ingress.Name == "nginx" {
nginxIngressAvailable = true
}
for k, v := range ingress.Annotations {
if k == "ingressclass.kubernetes.io/is-default-class" {
if v == "true" {
class = ingress.Name
break
}
}
}
}
}
}
}

if len(class) > 0 {
spec.IngressClassName = &class
} else if nginxIngressAvailable {
class = "nginx"
spec.IngressClassName = &class
}
}

return &networkingv1.Ingress{
Expand Down