mirror of
https://github.com/stakater/Reloader.git
synced 2026-08-23 22:16:45 +00:00
Switch from list of resources to monitor to list of resources to ignore
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user