Switch from list of resources to monitor to list of resources to ignore

This commit is contained in:
hstanley
2019-07-03 16:01:15 +01:00
parent 8cf105726f
commit 3e6c4a3f60
6 changed files with 20 additions and 20 deletions
@@ -16,10 +16,10 @@ rules:
- apiGroups:
- ""
resources:
{{- if eq .Values.reloader.watchSecrets true }}
{{- if .Values.reloader.ignoreSecrets }}{{- else }}
- secrets
{{- end }}
{{- if eq .Values.reloader.watchConfigMaps true }}
{{- if .Values.reloader.ignoreConfigMaps }}{{- else }}
- configmaps
{{- end }}
verbs:
@@ -93,11 +93,11 @@ spec:
- "--auto-annotation"
- "{{ .Values.reloader.custom_annotations.auto }}"
{{- end }}
{{- if eq .Values.reloader.watchSecrets true }}
- "--resources-to-watch=secrets"
{{- if eq .Values.reloader.ignoreSecrets true }}
- "--resources-to-ignore=secrets"
{{- end }}
{{- if eq .Values.reloader.watchConfigMaps true }}
- "--resources-to-watch=configMaps"
{{- if eq .Values.reloader.ignoreConfigMaps true }}
- "--resources-to-ignore=configMaps"
{{- end }}
{{- end }}
serviceAccountName: {{ template "reloader-serviceAccountName" . }}
@@ -16,12 +16,12 @@ rules:
- apiGroups:
- ""
resources:
{{- if .Values.reloader.watchSecrets }}
{{- if .Values.reloader.ignoreSecrets }}{{- else }}
- secrets
{{- end }}
{{- if .Values.reloader.watchConfigMaps }}
{{- end }}
{{- if .Values.reloader.ignoreConfigMaps }}{{- else }}
- configmaps
{{- end }}
{{- end }}
verbs:
- list
- get
@@ -4,8 +4,8 @@ kubernetes:
host: https://kubernetes.default
reloader:
watchSecrets: true
watchConfigMaps: true
ignoreSecrets: false
ignoreConfigMaps: false
watchGlobally: true
# Set to true if you have a pod security policy that enforces readOnlyRootFilesystem
readOnlyRootFileSystem: false
@@ -4,8 +4,8 @@ kubernetes:
host: https://kubernetes.default
reloader:
watchSecrets: true
watchConfigMaps: true
ignoreSecrets: false
ignoreConfigMaps: false
watchGlobally: true
# Set to true if you have a pod security policy that enforces readOnlyRootFilesystem
readOnlyRootFileSystem: false
+6 -6
View File
@@ -24,13 +24,13 @@ func NewReloaderCommand() *cobra.Command {
cmd.PersistentFlags().StringVar(&options.ConfigmapUpdateOnChangeAnnotation, "configmap-annotation", "configmap.reloader.stakater.com/reload", "annotation to detect changes in configmaps")
cmd.PersistentFlags().StringVar(&options.SecretUpdateOnChangeAnnotation, "secret-annotation", "secret.reloader.stakater.com/reload", "annotation to detect changes in secrets")
cmd.PersistentFlags().StringVar(&options.ReloaderAutoAnnotation, "auto-annotation", "reloader.stakater.com/auto", "annotation to detect changes in secrets")
cmd.PersistentFlags().StringSlice("resources-to-watch", []string{"configMaps", "secrets"}, "list of resources to watch (valid options 'configMaps', 'secrets')")
cmd.PersistentFlags().StringSlice("resources-to-ignore", []string{}, "list of resources to ignore (valid options 'configMaps', 'secrets')")
return cmd
}
func startReloader(cmd *cobra.Command, args []string) {
var watchList util.List
var ignoreList util.List
var err error
logrus.Info("Starting Reloader")
@@ -46,19 +46,19 @@ func startReloader(cmd *cobra.Command, args []string) {
logrus.Fatal(err)
}
watchList, err = cmd.Flags().GetStringSlice("resources-to-watch")
ignoreList, err = cmd.Flags().GetStringSlice("resources-to-ignore")
if err != nil {
logrus.Fatal(err)
}
for _, v := range watchList {
for _, v := range ignoreList {
if v != "configMaps" && v != "secrets" {
logrus.Fatalf("'resources-to-watch' only accepts 'configMaps' and 'secrets', not '%s'", v)
logrus.Fatalf("'resources-to-ignore' only accepts 'configMaps' or 'secrets', not '%s'", v)
}
}
for k := range kube.ResourceMap {
if !watchList.Contains(k) {
if ignoreList.Contains(k) {
continue
}