Make the pod selector configurable

- default labels: app, name and app.kubernetes.io/name
This commit is contained in:
stefanprodan
2019-04-15 12:57:25 +03:00
parent 60f51ad7d5
commit 6ef72e2550
9 changed files with 76 additions and 41 deletions
+9
View File
@@ -18,6 +18,7 @@ import (
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/clientcmd"
"log"
"strings"
"time"
)
@@ -36,6 +37,7 @@ var (
zapEncoding string
namespace string
meshProvider string
selectorLabels string
)
func init() {
@@ -53,6 +55,7 @@ func init() {
flag.StringVar(&zapEncoding, "zap-encoding", "json", "Zap logger encoding.")
flag.StringVar(&namespace, "namespace", "", "Namespace that flagger would watch canary object")
flag.StringVar(&meshProvider, "mesh-provider", "istio", "Service mesh provider, can be istio or appmesh")
flag.StringVar(&selectorLabels, "selector-labels", "app,name,app.kubernetes.io/name", "List of pod labels that Flagger uses to create pod selectors")
}
func main() {
@@ -101,6 +104,11 @@ func main() {
logger.Fatalf("Error calling Kubernetes API: %v", err)
}
labels := strings.Split(selectorLabels, ",")
if len(labels) < 1 {
logger.Fatalf("At least one selector label is required")
}
logger.Infof("Connected to Kubernetes API %s", ver)
if namespace != "" {
logger.Infof("Watching namespace %s", namespace)
@@ -137,6 +145,7 @@ func main() {
slack,
meshProvider,
version.VERSION,
labels,
)
flaggerInformerFactory.Start(stopCh)