Skip to content

Commit

Permalink
Adds new flag --metrics-host (#811)
Browse files Browse the repository at this point in the history
* Replaces flag --metrics-port with --metrics-addresss

Signed-off-by: Nathan Kinkade <[email protected]>

* Revert "Replaces flag --metrics-port with --metrics-addresss"

This reverts commit 528c7bb.

Signed-off-by: Nathan Kinkade <[email protected]>

* Adds new --metrics-host flag

The flag --metrics-port already exists. While not as clean, to avoid
introducing a backward incompatible change to flags, this commit adds a
new --metrics-host flag, which in combination with the existing
--metrics-port flag can define a complete listen address for the metrics
server as "<metrics-host>:<metrics-port>"

Signed-off-by: Nathan Kinkade <[email protected]>

* Adds new, commented flags --metrics-{port,host}

Signed-off-by: Nathan Kinkade <[email protected]>

---------

Signed-off-by: Nathan Kinkade <[email protected]>
  • Loading branch information
nkinkade authored Aug 8, 2023
1 parent 16dc5e3 commit 351ca71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/kured/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
drainTimeout time.Duration
rebootDelay time.Duration
period time.Duration
metricsHost string
metricsPort int
drainGracePeriod int
drainPodSelector string
Expand Down Expand Up @@ -126,6 +127,8 @@ func NewRootCommand() *cobra.Command {
"node name kured runs on, should be passed down from spec.nodeName via KURED_NODE_ID environment variable")
rootCmd.PersistentFlags().BoolVar(&forceReboot, "force-reboot", false,
"force a reboot even if the drain fails or times out")
rootCmd.PersistentFlags().StringVar(&metricsHost, "metrics-host", "",
"host where metrics will listen")
rootCmd.PersistentFlags().IntVar(&metricsPort, "metrics-port", 8080,
"port number where metrics will listen")
rootCmd.PersistentFlags().IntVar(&drainGracePeriod, "drain-grace-period", -1,
Expand Down Expand Up @@ -844,5 +847,5 @@ func root(cmd *cobra.Command, args []string) {
go maintainRebootRequiredMetric(nodeID, hostSentinelCommand)

http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", metricsPort), nil))
log.Fatal(http.ListenAndServe(fmt.Sprintf("%s:%d", metricsHost, metricsPort), nil))
}
2 changes: 2 additions & 0 deletions kured-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,5 @@ spec:
# - --annotate-nodes=false
# - --lock-release-delay=30m
# - --log-format=text
# - --metrics-host=""
# - --metrics-port=8080

0 comments on commit 351ca71

Please sign in to comment.