Skip to content

Commit

Permalink
rte: add toggle to disable prometheus
Browse files Browse the repository at this point in the history
make it configurable

Signed-off-by: Francesco Romani <[email protected]>
  • Loading branch information
ffromani committed Oct 19, 2023
1 parent 0a8bbd7 commit 02c385f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions rte/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ const (
)

type localArgs struct {
ConfigPath string
PodExcludes podexclude.List
ConfigPath string
PodExcludes podexclude.List
PrometheusEnable bool
}

type ProgArgs struct {
Expand Down Expand Up @@ -97,9 +98,12 @@ func main() {

cli = sharedcpuspool.NewFromLister(cli, parsedArgs.RTE.Debug, parsedArgs.RTE.ReferenceContainer)

err = prometheus.InitPrometheus()
if err != nil {
klog.Fatalf("failed to start prometheus server: %v", err)
if parsedArgs.LocalArgs.PrometheusEnable {
klog.Infof("serving prometheus metrics endpoint")
err = prometheus.InitPrometheus()
if err != nil {
klog.Fatalf("failed to start prometheus server: %v", err)
}
}

// TODO: recycled flag (no big deal, but still)
Expand Down Expand Up @@ -145,6 +149,7 @@ func parseArgs(args ...string) (ProgArgs, error) {
flags.StringVar(&pArgs.RTE.PodResourcesSocketPath, "podresources-socket", "unix:///podresources/kubelet.sock", "Pod Resource Socket path to use.")
flags.BoolVar(&pArgs.RTE.PodReadinessEnable, "podreadiness", true, "Custom condition injection using Podreadiness.")
flags.BoolVar(&pArgs.RTE.AddNRTOwnerEnable, "add-nrt-owner", true, "RTE will inject NRT's related node as OwnerReference to ensure cleanup if the node is deleted.")
flags.BoolVar(&pArgs.LocalArgs.PrometheusEnable, "prometheus", false, "Expose prometheus metrics endpoint.")

refCnt := flags.String("reference-container", "", "Reference container, used to learn about the shared cpu pool\n See: https://github.com/kubernetes/kubernetes/issues/102190\n format of spec is namespace/podname/containername.\n Alternatively, you can use the env vars REFERENCE_NAMESPACE, REFERENCE_POD_NAME, REFERENCE_CONTAINER_NAME.")

Expand Down

0 comments on commit 02c385f

Please sign in to comment.