Skip to content

Commit 8542150

Browse files
committed
Allow logging to be toggled
1 parent 6942978 commit 8542150

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

README.md

+14-9
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,20 @@ General usage is as follows:
2323
```
2424
$ k8s-node-label-monitor --help
2525
Node Label Monitor for Kubernetes
26-
Usage: k8s-node-label-monitor [flags]
27-
28-
-c string
29-
Manually trigger named CronJob on label changes
30-
-kubeconfig string
31-
Paths to a kubeconfig. Only required if out-of-cluster.
32-
-l Only track changes to the local node
33-
-n string
34-
Notification endpoint to POST updates to
26+
Usage: k8s-node-label-monitor [flags]
27+
28+
-cronjob string
29+
Manually trigger named CronJob on label changes
30+
-endpoint string
31+
Notification endpoint to POST updates to
32+
-kubeconfig string
33+
Paths to a kubeconfig. Only required if out-of-cluster.
34+
-local
35+
Only track changes to the local node
36+
-logging
37+
Enable/disable logging (default true)
38+
-master --kubeconfig
39+
(Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
3540
```
3641

3742
### Running Node-Local via Docker

k8s-node-label-monitor-node-local-daemonset.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ spec:
5353
name: node-label-monitor
5454
args:
5555
# Run in node-local mode
56-
- "-l"
56+
- "-local"

main.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
var (
2323
monitorName = "k8s-node-label-monitor"
2424
nodeLocal = false
25+
logging = true
2526
cronjob = ""
2627
log = logf.Log.WithName(monitorName)
2728
nodeLabels = map[string]map[string]string{}
@@ -210,9 +211,10 @@ func enqueueNodeUpdate(nodeName string, queue workqueue.RateLimitingInterface) {
210211
func main() {
211212
var endpoint string
212213

213-
flag.BoolVar(&nodeLocal, "l", false, "Only track changes to the local node")
214-
flag.StringVar(&cronjob, "c", "", "Manually trigger named CronJob on label changes")
215-
flag.StringVar(&endpoint, "n", "", "Notification endpoint to POST updates to")
214+
flag.BoolVar(&nodeLocal, "local", false, "Only track changes to the local node")
215+
flag.BoolVar(&logging, "logging", true, "Enable/disable logging")
216+
flag.StringVar(&cronjob, "cronjob", "", "Manually trigger named CronJob on label changes")
217+
flag.StringVar(&endpoint, "endpoint", "", "Notification endpoint to POST updates to")
216218

217219
flag.Usage = func() {
218220
fmt.Fprintf(os.Stderr, "Node Label Monitor for Kubernetes\n")
@@ -274,8 +276,10 @@ func main() {
274276
controller := NewController(queue, indexer, informer)
275277

276278
// Set up the notifiers for this controller
277-
log.Info("Enabling Logging notifier")
278-
controller.notifiers = append(controller.notifiers, notifiers.LogNotifier{})
279+
if logging {
280+
log.Info("Enabling Logging notifier")
281+
controller.notifiers = append(controller.notifiers, notifiers.LogNotifier{})
282+
}
279283

280284
if len(endpoint) > 0 {
281285
notifier, err := notifiers.NewEndpointNotifier(log, endpoint)

0 commit comments

Comments
 (0)