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

Register routes scheme when setting up the k8s client #44

Merged
merged 1 commit into from
Aug 2, 2022
Merged
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/sirupsen/logrus v1.8.1
k8s.io/api v0.23.5
k8s.io/apimachinery v0.23.5
k8s.io/client-go v0.23.0
sigs.k8s.io/controller-runtime v0.11.1
)

Expand Down Expand Up @@ -45,6 +44,7 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/client-go v0.23.0 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
Expand Down
14 changes: 10 additions & 4 deletions pkg/metrics/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
v1 "k8s.io/api/core/v1"
k8serr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
logf "sigs.k8s.io/controller-runtime/pkg/log"
Expand Down Expand Up @@ -295,7 +295,7 @@ func createOrUpdateServiceMonitor(ctx context.Context, client client.Client, sm
log.Info("Error retrieving service object", "Error", err)
return nil, err
}

// update the Service Monitor
sm.ResourceVersion = existingServiceMonitor.ResourceVersion
if err = client.Update(ctx, sm); err != nil {
Expand All @@ -317,12 +317,18 @@ func createClient() (client.Client, error) {
return nil, err
}

err = monitoringv1.AddToScheme(scheme.Scheme)
scheme := runtime.NewScheme()
err = monitoringv1.AddToScheme(scheme)
if err != nil {
return nil, err
}

err = routev1.Install(scheme)
if err != nil {
return nil, err
}

client, err := client.New(config, client.Options{Scheme: scheme.Scheme})
client, err := client.New(config, client.Options{Scheme: scheme})
if err != nil {
return nil, err
}
Expand Down