@@ -9,24 +9,24 @@ import (
99 "github.com/argoproj/argo-rollouts/pkg/apis/rollouts"
1010 rolloutv1alpha1 "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1"
1111 roclientset "github.com/argoproj/argo-rollouts/pkg/client/clientset/versioned"
12+ "github.com/pluralsh/deployment-operator/cmd/agent/args"
13+ "github.com/pluralsh/deployment-operator/internal/controller"
14+ "github.com/pluralsh/deployment-operator/pkg/cache"
15+ consoleclient "github.com/pluralsh/deployment-operator/pkg/client"
16+ consolectrl "github.com/pluralsh/deployment-operator/pkg/controller"
17+ "github.com/pluralsh/deployment-operator/pkg/controller/service"
1218 "github.com/prometheus/client_golang/prometheus/promhttp"
1319 velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
1420 "k8s.io/apimachinery/pkg/runtime/schema"
1521 "k8s.io/client-go/discovery"
1622 "k8s.io/client-go/dynamic"
1723 "k8s.io/client-go/kubernetes"
1824 "k8s.io/client-go/rest"
25+ metricsclientset "k8s.io/metrics/pkg/client/clientset/versioned"
1926 ctrl "sigs.k8s.io/controller-runtime"
2027 "sigs.k8s.io/controller-runtime/pkg/healthz"
2128 "sigs.k8s.io/controller-runtime/pkg/manager"
2229 "sigs.k8s.io/controller-runtime/pkg/metrics/server"
23-
24- "github.com/pluralsh/deployment-operator/cmd/agent/args"
25- "github.com/pluralsh/deployment-operator/internal/controller"
26- "github.com/pluralsh/deployment-operator/pkg/cache"
27- consoleclient "github.com/pluralsh/deployment-operator/pkg/client"
28- consolectrl "github.com/pluralsh/deployment-operator/pkg/controller"
29- "github.com/pluralsh/deployment-operator/pkg/controller/service"
3030)
3131
3232func initKubeManagerOrDie (config * rest.Config ) manager.Manager {
@@ -64,7 +64,7 @@ func initKubeManagerOrDie(config *rest.Config) manager.Manager {
6464 return mgr
6565}
6666
67- func initKubeClientsOrDie (config * rest.Config ) (rolloutsClient * roclientset.Clientset , dynamicClient * dynamic.DynamicClient , kubeClient * kubernetes.Clientset ) {
67+ func initKubeClientsOrDie (config * rest.Config ) (rolloutsClient * roclientset.Clientset , dynamicClient * dynamic.DynamicClient , kubeClient * kubernetes.Clientset , metricsClient metricsclientset. Interface ) {
6868 rolloutsClient , err := roclientset .NewForConfig (config )
6969 if err != nil {
7070 setupLog .Error (err , "unable to create rollouts client" )
@@ -83,7 +83,13 @@ func initKubeClientsOrDie(config *rest.Config) (rolloutsClient *roclientset.Clie
8383 os .Exit (1 )
8484 }
8585
86- return rolloutsClient , dynamicClient , kubeClient
86+ metricsClient , err = metricsclientset .NewForConfig (config )
87+ if err != nil {
88+ setupLog .Error (err , "unable to create metrics client" )
89+ os .Exit (1 )
90+ }
91+
92+ return rolloutsClient , dynamicClient , kubeClient , metricsClient
8793}
8894
8995func registerKubeReconcilersOrDie (
@@ -94,7 +100,8 @@ func registerKubeReconcilersOrDie(
94100 extConsoleClient consoleclient.Client ,
95101 discoveryClient discovery.DiscoveryInterface ,
96102) {
97- rolloutsClient , dynamicClient , kubeClient := initKubeClientsOrDie (config )
103+
104+ rolloutsClient , dynamicClient , kubeClient , metricsClient := initKubeClientsOrDie (config )
98105
99106 backupController := & controller.BackupReconciler {
100107 Client : manager .GetClient (),
@@ -217,6 +224,7 @@ func registerKubeReconcilersOrDie(
217224 Client : manager .GetClient (),
218225 Scheme : manager .GetScheme (),
219226 DiscoveryClient : discoveryClient ,
227+ MetricsClient : metricsClient ,
220228 }).SetupWithManager (ctx , manager ); err != nil {
221229 setupLog .Error (err , "unable to create controller" , "controller" , "MetricsAggregate" )
222230 }
0 commit comments