Skip to content

Commit

Permalink
Merge pull request #94 from lianglli/fix-ingressclass-master
Browse files Browse the repository at this point in the history
K8s: add cmd flag controller-class
  • Loading branch information
lianglli authored Oct 24, 2023
2 parents f2b4fea + 9ddbae3 commit 94a364d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cmd/nginx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
"github.com/prometheus/client_golang/prometheus/promhttp"

"k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -119,15 +120,25 @@ func main() {
klog.Fatalf("tengine-ingress requires Kubernetes v1.19.0 or higher")
}

_, err = kubeClient.NetworkingV1().IngressClasses().List(context.TODO(), metav1.ListOptions{})
if err != nil {
if !errors.IsNotFound(err) {
if errors.IsForbidden(err) {
klog.Warningf("No permissions to list and get Ingress Classes: %v, IngressClass feature will be disabled", err)
conf.IngressClassConfiguration.IgnoreIngressClass = true
}
}
}

conf.Client = kubeClient
conf.ClientIng = kubeIngClient
conf.ClientIngCheck = kubeIngCheckClient
conf.ClientSecretCheck = kubeSecretCheckClient

reg := prometheus.NewRegistry()

reg.MustRegister(prometheus.NewGoCollector())
reg.MustRegister(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{
reg.MustRegister(collectors.NewGoCollector())
reg.MustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{
PidFn: func() (int, error) { return os.Getpid(), nil },
ReportErrors: true,
}))
Expand Down

0 comments on commit 94a364d

Please sign in to comment.