Merge pull request #1955 from pujitha24/auto/issue-1345

Exclude linkerd-proxy sidecar ports from port discovery
This commit is contained in:
Sanskar Jaiswal
2026-08-02 18:20:23 +05:30
committed by GitHub
2 changed files with 43 additions and 2 deletions
+3 -2
View File
@@ -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 {
+40
View File
@@ -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",