diff --git a/README.md b/README.md index 07911e4..f8fce1c 100644 --- a/README.md +++ b/README.md @@ -94,8 +94,8 @@ Flags: --slack-channel string slack channel for reboot notfications --slack-hook-url string slack hook URL for reboot notfications --slack-username string slack username for reboot notfications (default "kured") - --slack-message-drain string slack message template when notifying about a node being drained (default "Draining node %s") - --slack-message-reboot string slack message template when notifying about a node being rebooted (default "Rebooting node %s") + --message-template-drain string message template used to notify about a node being drained (default "Draining node %s") + --message-template-reboot string message template used to notify about a node being rebooted (default "Rebooting node %s") --start-time string only reboot after this time of day (default "0:00") --time-zone string use this timezone to calculate allowed reboot time (default "UTC") ``` @@ -220,7 +220,10 @@ you immediately prior to rebooting a node: We recommend setting `--slack-username` to be the name of the environment, e.g. `dev` or `prod`. -Alternatively you can use the `--slack-message-reboot` and `--slack-message-reboot` to customize the text of the message, e.g. `"Draining node %s part of my-cluster in region xyz"` +Alternatively you can use the `--message-template-drain` and `--message-template-reboot` to customize the text of the message, e.g. +``` +--message-template-drain="Draining node %s part of *my-cluster* in region *xyz*" +``` ### Overriding Lock Configuration diff --git a/charts/kured/README.md b/charts/kured/README.md index 2655394..7facd67 100644 --- a/charts/kured/README.md +++ b/charts/kured/README.md @@ -55,8 +55,8 @@ The following changes have been made compared to the stable chart: | `configuration.slackChannel` | cli-parameter `--slack-channel` | `""` | | `configuration.slackHookUrl` | cli-parameter `--slack-hook-url` | `""` | | `configuration.slackUsername` | cli-parameter `--slack-username` | `""` | -| `configuration.slackMessageDrain` | cli-parameter `--slack-message-drain` | `""` | -| `configuration.slackMessageReboot` | cli-parameter `--slack-message-reboot` | `""` | +| `configuration.messageTemplateDrain` | cli-parameter `--message-template-drain` | `""` | +| `configuration.messageTemplateReboot` | cli-parameter `--message-template-reboot` | `""` | | `configuration.startTime` | cli-parameter `--start-time` | `""` | | `configuration.timeZone` | cli-parameter `--time-zone` | `""` | | `rbac.create` | Create RBAC roles | `true` | diff --git a/charts/kured/templates/daemonset.yaml b/charts/kured/templates/daemonset.yaml index ffd8083..f6ba661 100644 --- a/charts/kured/templates/daemonset.yaml +++ b/charts/kured/templates/daemonset.yaml @@ -81,11 +81,11 @@ spec: {{- if .Values.configuration.slackUsername }} - --slack-username={{ .Values.configuration.slackUsername }} {{- end }} - {{- if .Values.configuration.slackMessageDrain }} - - --slack-message-drain={{ .Values.configuration.slackMessageDrain }} + {{- if .Values.configuration.messageTemplateDrain }} + - --message-template-drain={{ .Values.configuration.messageTemplateDrain }} {{- end }} - {{- if .Values.configuration.slackMessageReboot }} - - --slack-message-reboot={{ .Values.configuration.slackMessageReboot }} + {{- if .Values.configuration.messageTemplateReboot }} + - --message-template-reboot={{ .Values.configuration.messageTemplateReboot }} {{- end }} {{- if .Values.configuration.startTime }} - --start-time={{ .Values.configuration.startTime }} diff --git a/charts/kured/values.minikube.yaml b/charts/kured/values.minikube.yaml index 0f3ab85..9b27635 100644 --- a/charts/kured/values.minikube.yaml +++ b/charts/kured/values.minikube.yaml @@ -15,7 +15,7 @@ configuration: # slackChannel: "" # slack channel for reboot notfications # slackHookUrl: "" # slack hook URL for reboot notfications # slackUsername: "" # slack username for reboot notfications (default "kured") - # slackMessageDrain: "" # slack message template when notifying about a node being drained (default "Draining node %s") - # slackMessageReboot: "" # slack message template when notifying about a node being rebooted (default "Rebooted node %s") + # messageTemplateDrain: "" # slack message template when notifying about a node being drained (default "Draining node %s") + # messageTemplateReboot: "" # slack message template when notifying about a node being rebooted (default "Rebooted node %s") # startTime: "" # only reboot after this time of day (default "0:00") # timeZone: "" # time-zone to use (valid zones from "time" golang package) diff --git a/charts/kured/values.yaml b/charts/kured/values.yaml index 4533b37..f999e14 100644 --- a/charts/kured/values.yaml +++ b/charts/kured/values.yaml @@ -32,8 +32,8 @@ configuration: slackChannel: "" # slack channel for reboot notfications slackHookUrl: "" # slack hook URL for reboot notfications slackUsername: "" # slack username for reboot notfications (default "kured") - slackMessageDrain: "" # slack message template when notifying about a node being drained (default "Draining node %s") - slackMessageReboot: "" # slack message template when notifying about a node being rebooted (default "Rebooted node %s") + messageTemplateDrain: "" # slack message template when notifying about a node being drained (default "Draining node %s") + messageTemplateReboot: "" # slack message template when notifying about a node being rebooted (default "Rebooted node %s") startTime: "" # only reboot after this time of day (default "0:00") timeZone: "" # time-zone to use (valid zones from "time" golang package) diff --git a/cmd/kured/main.go b/cmd/kured/main.go index 6f8977c..fd876ea 100644 --- a/cmd/kured/main.go +++ b/cmd/kured/main.go @@ -31,20 +31,20 @@ var ( version = "unreleased" // Command line flags - period time.Duration - dsNamespace string - dsName string - lockAnnotation string - lockTTL time.Duration - prometheusURL string - alertFilter *regexp.Regexp - rebootSentinel string - slackHookURL string - slackUsername string - slackChannel string - slackMessageDrain string - slackMessageReboot string - podSelectors []string + period time.Duration + dsNamespace string + dsName string + lockAnnotation string + lockTTL time.Duration + prometheusURL string + alertFilter *regexp.Regexp + rebootSentinel string + slackHookURL string + slackUsername string + slackChannel string + messageTemplateDrain string + messageTemplateReboot string + podSelectors []string rebootDays []string rebootStart string @@ -92,10 +92,10 @@ func main() { "slack username for reboot notfications") rootCmd.PersistentFlags().StringVar(&slackChannel, "slack-channel", "", "slack channel for reboot notfications") - rootCmd.PersistentFlags().StringVar(&slackMessageDrain, "slack-message-drain", "Draining node %s", - "slack message template when notifying about a node being drained") - rootCmd.PersistentFlags().StringVar(&slackMessageReboot, "slack-message-reboot", "Rebooting node %s", - "slack message template when notifying about a node being rebooted") + rootCmd.PersistentFlags().StringVar(&messageTemplateDrain, "message-template-drain", "Draining node %s", + "message template used to notify about a node being drained") + rootCmd.PersistentFlags().StringVar(&messageTemplateReboot, "message-template-reboot", "Rebooting node %s", + "message template used to notify about a node being rebooted") rootCmd.PersistentFlags().StringArrayVar(&podSelectors, "blocking-pod-selector", nil, "label selector identifying pods whose presence should prevent reboots") @@ -243,7 +243,7 @@ func drain(client *kubernetes.Clientset, node *v1.Node) { log.Infof("Draining node %s", nodename) if slackHookURL != "" { - if err := slack.NotifyDrain(slackHookURL, slackUsername, slackChannel, slackMessageDrain, nodename); err != nil { + if err := slack.NotifyDrain(slackHookURL, slackUsername, slackChannel, messageTemplateDrain, nodename); err != nil { log.Warnf("Error notifying slack: %v", err) } } @@ -283,7 +283,7 @@ func commandReboot(nodeID string) { log.Infof("Commanding reboot for node: %s", nodeID) if slackHookURL != "" { - if err := slack.NotifyReboot(slackHookURL, slackUsername, slackChannel, slackMessageReboot, nodeID); err != nil { + if err := slack.NotifyReboot(slackHookURL, slackUsername, slackChannel, messageTemplateReboot, nodeID); err != nil { log.Warnf("Error notifying slack: %v", err) } } diff --git a/kured-ds.yaml b/kured-ds.yaml index 6cfa443..2e0ffae 100644 --- a/kured-ds.yaml +++ b/kured-ds.yaml @@ -59,7 +59,7 @@ spec: # - --slack-hook-url=https://hooks.slack.com/... # - --slack-username=prod # - --slack-channel=alerting -# - --slack-message-drain=Draining node %s -# - --slack-message-drain=Rebooting node %s +# - --message-template-drain=Draining node %s +# - --message-template-drain=Rebooting node %s # - --start-time=0:00 # - --time-zone=UTC