From e8a2d4be2e21d24203fe369dc16a872273a67b0b Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Sat, 5 Oct 2019 10:42:01 +0300 Subject: [PATCH 1/2] Fix port discovery diff Sort service ports by port number before comparing slices --- pkg/router/kubernetes.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/router/kubernetes.go b/pkg/router/kubernetes.go index 07710fcc6..3d6fd6301 100644 --- a/pkg/router/kubernetes.go +++ b/pkg/router/kubernetes.go @@ -3,6 +3,7 @@ package router import ( "fmt" "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" flaggerv1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha3" clientset "github.com/weaveworks/flagger/pkg/client/clientset/versioned" "go.uber.org/zap" @@ -128,7 +129,10 @@ func (c *KubernetesRouter) reconcileService(canary *flaggerv1.Canary, name strin } if svc != nil { - portsDiff := cmp.Diff(svcSpec.Ports, svc.Spec.Ports) + sortPorts := func(a, b interface{}) bool { + return a.(corev1.ServicePort).Port < b.(corev1.ServicePort).Port + } + portsDiff := cmp.Diff(svcSpec.Ports, svc.Spec.Ports, cmpopts.SortSlices(sortPorts)) selectorsDiff := cmp.Diff(svcSpec.Selector, svc.Spec.Selector) if portsDiff != "" || selectorsDiff != "" { From 2141d88ce1cc6be220dab34171c215a334ecde24 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Sat, 5 Oct 2019 10:45:35 +0300 Subject: [PATCH 2/2] Enable Prometheus scraping of Flagger metrics --- charts/flagger/values.yaml | 4 +++- kustomize/base/flagger/deployment.yaml | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/charts/flagger/values.yaml b/charts/flagger/values.yaml index 2c135187c..42af79ce3 100644 --- a/charts/flagger/values.yaml +++ b/charts/flagger/values.yaml @@ -6,7 +6,9 @@ image: pullPolicy: IfNotPresent pullSecret: -podAnnotations: {} +podAnnotations: + prometheus.io/scrape: "true" + prometheus.io/port: "8080" metricsServer: "http://prometheus:9090" diff --git a/kustomize/base/flagger/deployment.yaml b/kustomize/base/flagger/deployment.yaml index ab02b0e89..241f91f15 100644 --- a/kustomize/base/flagger/deployment.yaml +++ b/kustomize/base/flagger/deployment.yaml @@ -15,6 +15,7 @@ spec: app: flagger annotations: prometheus.io/scrape: "true" + prometheus.io/port: "8080" spec: serviceAccountName: flagger containers: