diff --git a/go.mod b/go.mod index 69d0f3d..d6eac51 100644 --- a/go.mod +++ b/go.mod @@ -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 ) @@ -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 diff --git a/pkg/metrics/service.go b/pkg/metrics/service.go index d6855a0..c1043af 100644 --- a/pkg/metrics/service.go +++ b/pkg/metrics/service.go @@ -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" @@ -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 { @@ -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 }