Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add namespace flag #78

Merged
merged 1 commit into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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