summaryrefslogtreecommitdiffstats
path: root/src/monitor/cmd/manager/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/monitor/cmd/manager/main.go')
-rw-r--r--src/monitor/cmd/manager/main.go54
1 files changed, 2 insertions, 52 deletions
diff --git a/src/monitor/cmd/manager/main.go b/src/monitor/cmd/manager/main.go
index 9e7419ed..67783f83 100644
--- a/src/monitor/cmd/manager/main.go
+++ b/src/monitor/cmd/manager/main.go
@@ -7,23 +7,13 @@ import (
"os"
"runtime"
- // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
- _ "k8s.io/client-go/plugin/pkg/client/auth"
- "k8s.io/client-go/rest"
-
"github.com/onap/multicloud-k8s/src/monitor/pkg/apis"
"github.com/onap/multicloud-k8s/src/monitor/pkg/controller"
-
"github.com/operator-framework/operator-sdk/pkg/k8sutil"
- kubemetrics "github.com/operator-framework/operator-sdk/pkg/kube-metrics"
"github.com/operator-framework/operator-sdk/pkg/leader"
- "github.com/operator-framework/operator-sdk/pkg/log/zap"
- "github.com/operator-framework/operator-sdk/pkg/metrics"
"github.com/operator-framework/operator-sdk/pkg/restmapper"
sdkVersion "github.com/operator-framework/operator-sdk/version"
"github.com/spf13/pflag"
- v1 "k8s.io/api/core/v1"
- "k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
@@ -47,7 +37,7 @@ func printVersion() {
func main() {
// Add the zap logger flag set to the CLI. The flag set must
// be added before calling pflag.Parse().
- pflag.CommandLine.AddFlagSet(zap.FlagSet())
+ //pflag.CommandLine.AddFlagSet(zap.FlagSet())
// Add flags registered by imported packages (e.g. glog and
// controller-runtime)
@@ -63,7 +53,7 @@ func main() {
// implementing the logr.Logger interface. This logger will
// be propagated through the whole operator, generating
// uniform and structured logs.
- logf.SetLogger(zap.Logger())
+ //logf.SetLogger(zap.Logger())
printVersion()
@@ -112,22 +102,6 @@ func main() {
log.Error(err, "")
os.Exit(1)
}
-
- if err = serveCRMetrics(cfg); err != nil {
- log.Info("Could not generate and serve custom resource metrics", "error", err.Error())
- }
-
- // Add to the below struct any other metrics ports you want to expose.
- servicePorts := []v1.ServicePort{
- {Port: metricsPort, Name: metrics.OperatorPortName, Protocol: v1.ProtocolTCP, TargetPort: intstr.IntOrString{Type: intstr.Int, IntVal: metricsPort}},
- {Port: operatorMetricsPort, Name: metrics.CRPortName, Protocol: v1.ProtocolTCP, TargetPort: intstr.IntOrString{Type: intstr.Int, IntVal: operatorMetricsPort}},
- }
- // Create Service object to expose the metrics port(s).
- _, err = metrics.CreateMetricsService(ctx, cfg, servicePorts)
- if err != nil {
- log.Info(err.Error())
- }
-
log.Info("Starting the Cmd.")
// Start the Cmd
@@ -136,27 +110,3 @@ func main() {
os.Exit(1)
}
}
-
-// serveCRMetrics gets the Operator/CustomResource GVKs and generates metrics based on those types.
-// It serves those metrics on "http://metricsHost:operatorMetricsPort".
-func serveCRMetrics(cfg *rest.Config) error {
- // Below function returns filtered operator/CustomResource specific GVKs.
- // For more control override the below GVK list with your own custom logic.
- filteredGVK, err := k8sutil.GetGVKsFromAddToScheme(apis.AddToScheme)
- if err != nil {
- return err
- }
- // Get the namespace the operator is currently deployed in.
- operatorNs, err := k8sutil.GetOperatorNamespace()
- if err != nil {
- return err
- }
- // To generate metrics in other namespaces, add the values below.
- ns := []string{operatorNs}
- // Generate and serve custom resource specific metrics.
- err = kubemetrics.GenerateAndServeCRMetrics(cfg, ns, filteredGVK, metricsHost, operatorMetricsPort)
- if err != nil {
- return err
- }
- return nil
-}