Skip to content

Commit 036d8f5

Browse files
authored
fix: add cluster domain with final dot to no proxy list (#821)
1 parent b1e434e commit 036d8f5

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

api/v1alpha1/http_proxy.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ func (p *HTTPProxy) GenerateNoProxy(cluster *clusterv1.Cluster) []string {
6666
".svc",
6767
// append .svc.<SERVICE_DOMAIN>
6868
fmt.Sprintf(".svc.%s", strings.TrimLeft(serviceDomain, ".")),
69+
// append .svc.<SERVICE_DOMAIN>.
70+
fmt.Sprintf(".svc.%s.", strings.TrimLeft(serviceDomain, ".")),
6971
)
7072

7173
if cluster.Spec.InfrastructureRef == nil {

api/v1alpha1/http_proxy_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ func TestGenerateNoProxy(t *testing.T) {
2626
cluster: &clusterv1.Cluster{},
2727
expectedNoProxy: []string{
2828
"localhost", "127.0.0.1", "kubernetes", "kubernetes.default",
29-
".svc", ".svc.cluster.local",
29+
".svc", ".svc.cluster.local", ".svc.cluster.local.",
3030
},
3131
}, {
3232
name: "no networking config with additional no proxy",
3333
cluster: &clusterv1.Cluster{},
3434
additonalNo: []string{"example.com"},
3535
expectedNoProxy: []string{
3636
"localhost", "127.0.0.1", "kubernetes", "kubernetes.default",
37-
".svc", ".svc.cluster.local", "example.com",
37+
".svc", ".svc.cluster.local", ".svc.cluster.local.", "example.com",
3838
},
3939
}, {
4040
name: "custom pod network",
@@ -49,7 +49,7 @@ func TestGenerateNoProxy(t *testing.T) {
4949
},
5050
expectedNoProxy: []string{
5151
"localhost", "127.0.0.1", "10.0.0.0/24", "10.0.1.0/24", "kubernetes",
52-
"kubernetes.default", ".svc", ".svc.cluster.local",
52+
"kubernetes.default", ".svc", ".svc.cluster.local", ".svc.cluster.local.",
5353
},
5454
}, {
5555
name: "Unknown infrastructure cluster",
@@ -62,7 +62,7 @@ func TestGenerateNoProxy(t *testing.T) {
6262
},
6363
expectedNoProxy: []string{
6464
"localhost", "127.0.0.1", "kubernetes", "kubernetes.default",
65-
".svc", ".svc.cluster.local",
65+
".svc", ".svc.cluster.local", ".svc.cluster.local.",
6666
},
6767
}, {
6868
name: "AWS cluster",
@@ -75,7 +75,7 @@ func TestGenerateNoProxy(t *testing.T) {
7575
},
7676
expectedNoProxy: []string{
7777
"localhost", "127.0.0.1", "kubernetes", "kubernetes.default",
78-
".svc", ".svc.cluster.local", "169.254.169.254", ".elb.amazonaws.com",
78+
".svc", ".svc.cluster.local", ".svc.cluster.local.", "169.254.169.254", ".elb.amazonaws.com",
7979
},
8080
}, {
8181
name: "AWS managed (EKS) cluster",
@@ -88,7 +88,7 @@ func TestGenerateNoProxy(t *testing.T) {
8888
},
8989
expectedNoProxy: []string{
9090
"localhost", "127.0.0.1", "kubernetes", "kubernetes.default",
91-
".svc", ".svc.cluster.local", "169.254.169.254", ".elb.amazonaws.com",
91+
".svc", ".svc.cluster.local", ".svc.cluster.local.", "169.254.169.254", ".elb.amazonaws.com",
9292
},
9393
}, {
9494
name: "Azure cluster",
@@ -101,7 +101,7 @@ func TestGenerateNoProxy(t *testing.T) {
101101
},
102102
expectedNoProxy: []string{
103103
"localhost", "127.0.0.1", "kubernetes", "kubernetes.default",
104-
".svc", ".svc.cluster.local", "169.254.169.254",
104+
".svc", ".svc.cluster.local", ".svc.cluster.local.", "169.254.169.254",
105105
},
106106
}, {
107107
name: "Azure managed (AKS) cluster",
@@ -114,7 +114,7 @@ func TestGenerateNoProxy(t *testing.T) {
114114
},
115115
expectedNoProxy: []string{
116116
"localhost", "127.0.0.1", "kubernetes", "kubernetes.default",
117-
".svc", ".svc.cluster.local", "169.254.169.254",
117+
".svc", ".svc.cluster.local", ".svc.cluster.local.", "169.254.169.254",
118118
},
119119
}, {
120120
name: "GCP cluster",
@@ -127,7 +127,8 @@ func TestGenerateNoProxy(t *testing.T) {
127127
},
128128
expectedNoProxy: []string{
129129
"localhost", "127.0.0.1", "kubernetes", "kubernetes.default",
130-
".svc", ".svc.cluster.local", "169.254.169.254", "metadata", "metadata.google.internal",
130+
".svc", ".svc.cluster.local", ".svc.cluster.local.",
131+
"169.254.169.254", "metadata", "metadata.google.internal",
131132
},
132133
}, {
133134
name: "custom service network",
@@ -142,7 +143,7 @@ func TestGenerateNoProxy(t *testing.T) {
142143
},
143144
expectedNoProxy: []string{
144145
"localhost", "127.0.0.1", "172.16.0.0/24", "172.16.1.0/24", "kubernetes",
145-
"kubernetes.default", ".svc", ".svc.cluster.local",
146+
"kubernetes.default", ".svc", ".svc.cluster.local", ".svc.cluster.local.",
146147
},
147148
}, {
148149
name: "custom servicedomain",
@@ -155,7 +156,7 @@ func TestGenerateNoProxy(t *testing.T) {
155156
},
156157
expectedNoProxy: []string{
157158
"localhost", "127.0.0.1", "kubernetes", "kubernetes.default",
158-
".svc", ".svc.foo.bar",
159+
".svc", ".svc.foo.bar", ".svc.foo.bar.",
159160
},
160161
}, {
161162
name: "all options",
@@ -175,7 +176,7 @@ func TestGenerateNoProxy(t *testing.T) {
175176
additonalNo: []string{"example.com"},
176177
expectedNoProxy: []string{
177178
"localhost", "127.0.0.1", "10.10.0.0/16", "172.16.0.0/16", "kubernetes",
178-
"kubernetes.default", ".svc", ".svc.foo.bar", "example.com",
179+
"kubernetes.default", ".svc", ".svc.foo.bar", ".svc.foo.bar.", "example.com",
179180
},
180181
}}
181182

0 commit comments

Comments
 (0)