Skip to content

Commit

Permalink
Merge pull request #78 from huydinhle/namespace-watcher
Browse files Browse the repository at this point in the history
Add namespace flag
  • Loading branch information
stefanprodan authored Mar 6, 2019
2 parents eda97f3 + d8cb8f1 commit a5d4382
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions charts/flagger/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ spec:
- ./flagger
- -log-level=info
- -metrics-server={{ .Values.metricsServer }}
{{- if .Values.namespace }}
- -namespace={{ .Values.namespace }}
{{- end }}
{{- if .Values.slack.url }}
- -slack-url={{ .Values.slack.url }}
- -slack-user={{ .Values.slack.user }}
Expand Down
3 changes: 3 additions & 0 deletions charts/flagger/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ image:

metricsServer: "http://prometheus.istio-system.svc.cluster.local:9090"

# Namespace that flagger will watch for Canary objects
namespace: ""

slack:
user: flagger
channel:
Expand Down
11 changes: 10 additions & 1 deletion cmd/flagger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var (
threadiness int
zapReplaceGlobals bool
zapEncoding string
namespace string
)

func init() {
Expand All @@ -50,6 +51,7 @@ func init() {
flag.IntVar(&threadiness, "threadiness", 2, "Worker concurrency.")
flag.BoolVar(&zapReplaceGlobals, "zap-replace-globals", false, "Whether to change the logging level of the global zap logger.")
flag.StringVar(&zapEncoding, "zap-encoding", "json", "Zap logger encoding.")
flag.StringVar(&namespace, "namespace", "", "Namespace that flagger would watch canary object")
}

func main() {
Expand Down Expand Up @@ -87,7 +89,14 @@ func main() {
logger.Fatalf("Error building example clientset: %s", err.Error())
}

flaggerInformerFactory := informers.NewSharedInformerFactory(flaggerClient, time.Second*30)
if namespace == "" {
logger.Infof("Flagger Canary's Watcher is on all namespace")
} else {
logger.Infof("Flagger Canary's Watcher is on namespace %s", namespace)
}

flaggerInformerFactory := informers.NewSharedInformerFactoryWithOptions(flaggerClient, time.Second*30, informers.WithNamespace(namespace))

canaryInformer := flaggerInformerFactory.Flagger().V1alpha3().Canaries()

logger.Infof("Starting flagger version %s revision %s", version.VERSION, version.REVISION)
Expand Down

0 comments on commit a5d4382

Please sign in to comment.