diff --git a/pkg/canary/util.go b/pkg/canary/util.go index b6ac9492a..ea7b0a372 100644 --- a/pkg/canary/util.go +++ b/pkg/canary/util.go @@ -29,8 +29,9 @@ import ( ) var sidecars = map[string]bool{ - "istio-proxy": true, - "envoy": true, + "istio-proxy": true, + "envoy": true, + "linkerd-proxy": true, } func getPorts(cd *flaggerv1.Canary, cs []corev1.Container) map[string]int32 { diff --git a/pkg/canary/util_test.go b/pkg/canary/util_test.go index b90b2cb9c..d04cb7338 100644 --- a/pkg/canary/util_test.go +++ b/pkg/canary/util_test.go @@ -20,6 +20,9 @@ import ( "testing" "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" + + flaggerv1 "github.com/fluxcd/flagger/pkg/apis/flagger/v1beta1" ) func TestIncludeLabelsByPrefix(t *testing.T) { @@ -69,6 +72,43 @@ func TestIncludeLabelsNoIncludes(t *testing.T) { assert.Equal(t, map[string]string{}, filteredLabels) } +func TestGetPortsExcludesSidecars(t *testing.T) { + cd := &flaggerv1.Canary{ + Spec: flaggerv1.CanarySpec{ + Service: flaggerv1.CanaryService{ + Port: 8080, + }, + }, + } + + containers := []corev1.Container{ + { + Name: "app", + Ports: []corev1.ContainerPort{ + {Name: "http", ContainerPort: 8080}, + {Name: "metrics", ContainerPort: 9090}, + }, + }, + { + Name: "linkerd-proxy", + Ports: []corev1.ContainerPort{ + {Name: "linkerd-proxy", ContainerPort: 4143}, + {Name: "linkerd-admin", ContainerPort: 4191}, + }, + }, + { + Name: "istio-proxy", + Ports: []corev1.ContainerPort{ + {Name: "istio-proxy", ContainerPort: 15090}, + }, + }, + } + + ports := getPorts(cd, containers) + + assert.Equal(t, map[string]int32{"metrics": 9090}, ports) +} + func TestMakePrimaryLabels(t *testing.T) { labels := map[string]string{ "lorem": "ipsum",