Skip to content

Commit

Permalink
fix(kuma-cp): default value if metadata field is not set
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya Lobkov <[email protected]>
  • Loading branch information
lobkovilya committed Sep 28, 2023
1 parent 1d0e74c commit 21efbfb
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ node:
id: default.dp-1.default
metadata:
accessLogSocketPath: /tmp/kuma-al-dp-1.default-default.sock
dataplane.admin.address: 127.0.0.1
dataplane.admin.port: "1234"
dataplane.proxyType: dataplane
features: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ node:
id: mesh.name.namespace
metadata:
accessLogSocketPath: /tmp/kuma-al-name.namespace-mesh.sock
dataplane.admin.address: 192.168.0.1
dataplane.admin.port: "9902"
dataplane.proxyType: dataplane
features: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ node:
id: mesh.name.namespace
metadata:
accessLogSocketPath: /tmp/kuma-al-name.namespace-mesh.sock
dataplane.admin.address: 192.168.0.1
dataplane.admin.port: "1234"
dataplane.proxyType: dataplane
dataplane.resource: |2-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ node:
id: mesh.name.namespace
metadata:
accessLogSocketPath: /tmp/kuma-al-name.namespace-mesh.sock
dataplane.admin.address: 127.0.0.1
dataplane.admin.port: "1234"
dataplane.dns.empty.port: "53002"
dataplane.dns.port: "53001"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ node:
id: mesh.name.namespace
metadata:
accessLogSocketPath: /tmp/kuma-al-name.namespace-mesh.sock
dataplane.admin.address: 127.0.0.1
dataplane.admin.port: "1234"
dataplane.dns.empty.port: "53002"
dataplane.dns.port: "53001"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ node:
id: mesh.name.namespace
metadata:
accessLogSocketPath: /tmp/kuma-al-name.namespace-mesh.sock
dataplane.admin.address: 127.0.0.1
dataplane.admin.port: "1234"
dataplane.proxyType: dataplane
features: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ node:
id: mesh.name.namespace
metadata:
accessLogSocketPath: /tmp/kuma-al-name.namespace-mesh.sock
dataplane.admin.address: 127.0.0.1
dataplane.admin.port: "1234"
dataplane.proxyType: dataplane
features: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ node:
id: mesh.name.namespace
metadata:
accessLogSocketPath: /tmp/kuma-al-name.namespace-mesh.sock
dataplane.admin.address: 127.0.0.1
dataplane.admin.port: "1234"
dataplane.proxyType: dataplane
features: []
Expand Down
10 changes: 7 additions & 3 deletions pkg/xds/generator/admin_proxy_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ func (g AdminProxyGenerator) Generate(ctx context.Context, xdsCtx xds_context.Co
// since it would allow a malicious user to manipulate that value and use Prometheus endpoint
// as a gateway to another host.
envoyAdminClusterName := envoy_names.GetEnvoyAdminClusterName()
adminAddress := proxy.Metadata.GetAdminAddress()
if adminAddress == "" {
adminAddress = "127.0.0.1"
}
cluster, err := envoy_clusters.NewClusterBuilder(proxy.APIVersion, envoyAdminClusterName).
Configure(envoy_clusters.ProvidedEndpointCluster(
govalidator.IsIPv6(proxy.Metadata.GetAdminAddress()),
core_xds.Endpoint{Target: proxy.Metadata.GetAdminAddress(), Port: adminPort})).
govalidator.IsIPv6(adminAddress),
core_xds.Endpoint{Target: adminAddress, Port: adminPort})).
Configure(envoy_clusters.DefaultTimeout()).
Build()
if err != nil {
Expand All @@ -65,7 +69,7 @@ func (g AdminProxyGenerator) Generate(ctx context.Context, xdsCtx xds_context.Co
}

// We bind admin to 127.0.0.1 by default, creating another listener with same address and port will result in error.
if g.getAddress(proxy) != proxy.Metadata.GetAdminAddress() {
if g.getAddress(proxy) != adminAddress {
filterChains := []envoy_listeners.ListenerBuilderOpt{
envoy_listeners.FilterChain(envoy_listeners.NewFilterChainBuilder(proxy.APIVersion, envoy_common.AnonymousResource).
Configure(envoy_listeners.StaticEndpoints(envoy_names.GetAdminListenerName(), staticEndpointPaths)),
Expand Down

0 comments on commit 21efbfb

Please sign in to comment.