Skip to content

Commit fffe65a

Browse files
committed
Revert "envoy per gateway (#404)"
This reverts commit 231e4fb. Signed-off-by: danehans <[email protected]>
1 parent d48a104 commit fffe65a

File tree

69 files changed

+1460
-1543
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1460
-1543
lines changed

internal/cmd/xdstest.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,19 +187,19 @@ func xDSTest() error {
187187
for {
188188
time.Sleep(10 * time.Second)
189189
logger.Info("Updating the cache for first-listener with first-route")
190-
err := snapCache.GenerateNewSnapshot("", cacheVersion1.GetXdsResources())
190+
err := snapCache.GenerateNewSnapshot(cacheVersion1.GetXdsResources())
191191
if err != nil {
192192
logger.Error(err, "Something went wrong with generating a snapshot")
193193
}
194194
time.Sleep(10 * time.Second)
195195
logger.Info("Updating the cache for first-listener with second-route")
196-
err = snapCache.GenerateNewSnapshot("", cacheVersion2.GetXdsResources())
196+
err = snapCache.GenerateNewSnapshot(cacheVersion2.GetXdsResources())
197197
if err != nil {
198198
logger.Error(err, "Something went wrong with generating a snapshot")
199199
}
200200
time.Sleep(10 * time.Second)
201201
logger.Info("Updating the cache for second-listener with second-route")
202-
err = snapCache.GenerateNewSnapshot("", cacheVersion3.GetXdsResources())
202+
err = snapCache.GenerateNewSnapshot(cacheVersion3.GetXdsResources())
203203
if err != nil {
204204
logger.Error(err, "Something went wrong with generating a snapshot")
205205
}

internal/crypto/certgen.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const (
2121
DefaultEnvoyGatewayDNSPrefix = config.EnvoyGatewayServiceName
2222

2323
// DefaultEnvoyDNSPrefix defines the default Envoy DNS prefix.
24-
DefaultEnvoyDNSPrefix = "*"
24+
DefaultEnvoyDNSPrefix = config.EnvoyServiceName
2525

2626
// DefaultNamespace is the default Namespace name where Envoy Gateway is running.
2727
DefaultNamespace = config.EnvoyGatewayNamespace
@@ -112,7 +112,7 @@ func GenerateCerts(egCfg *v1alpha1.EnvoyGateway) (*Certificates, error) {
112112
switch egProvider {
113113
case v1alpha1.ProviderTypeKubernetes:
114114
egDNSNames = kubeServiceNames(DefaultEnvoyGatewayDNSPrefix, DefaultNamespace, DefaultDNSSuffix)
115-
envoyDNSNames = append(envoyDNSNames, fmt.Sprintf("*.%s", DefaultNamespace))
115+
envoyDNSNames = kubeServiceNames(DefaultEnvoyDNSPrefix, DefaultNamespace, DefaultDNSSuffix)
116116
default:
117117
// Kubernetes is the only supported Envoy Gateway provider.
118118
return nil, fmt.Errorf("unsupported provider type %v", egProvider)

internal/crypto/certgen_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestGenerateCerts(t *testing.T) {
4747
run(t, "no configuration - use defaults", testcase{
4848
certConfig: &Configuration{},
4949
wantEnvoyGatewayDNSName: "envoy-gateway",
50-
wantEnvoyDNSName: "*.envoy-gateway-system",
50+
wantEnvoyDNSName: "envoy",
5151
})
5252
}
5353

internal/envoygateway/config/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ const (
1212
EnvoyGatewayNamespace = "envoy-gateway-system"
1313
// EnvoyGatewayServiceName is the name of the Envoy Gateway service.
1414
EnvoyGatewayServiceName = "envoy-gateway"
15+
// EnvoyServiceName is the name of the Envoy Service.
16+
EnvoyServiceName = "envoy"
17+
// EnvoyDeploymentName is the name of the Envoy Deployment.
18+
EnvoyDeploymentName = "envoy"
1519
// EnvoyConfigMapName is the name of the Envoy ConfigMap.
1620
EnvoyConfigMapName = "envoy"
17-
// EnvoyServicePrefix is the prefix applied to the Envoy Service.
18-
EnvoyServicePrefix = "envoy"
19-
// EnvoyDeploymentPrefix is the prefix applied to the Envoy Deployment.
20-
EnvoyDeploymentPrefix = "envoy"
2121
)
2222

2323
// Server wraps the EnvoyGateway configuration and additional parameters

internal/gatewayapi/runner/runner.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,22 @@ func (r *Runner) subscribeAndTranslate(ctx context.Context) {
9595
yamlInfraIR, _ := yaml.Marshal(&result.InfraIR)
9696
r.Logger.WithValues("output", "infra-ir").Info(string(yamlInfraIR))
9797

98-
// Publish the IRs.
98+
// Publish the IRs. Use the service name as the key
99+
// to ensure there is always one element in the map.
99100
// Also validate the ir before sending it.
100-
for key, val := range result.InfraIR {
101-
if err := val.Validate(); err != nil {
102-
r.Logger.Error(err, "unable to validate infra ir, skipped sending it")
103-
} else {
104-
r.InfraIR.Store(key, val)
105-
}
101+
if err := result.InfraIR.Validate(); err != nil {
102+
r.Logger.Error(err, "unable to validate infra ir, skipped sending it")
103+
} else {
104+
r.InfraIR.Store(r.Name(), result.InfraIR)
106105
}
106+
107107
// Wait until all HTTPRoutes have been reconciled , else the translation
108108
// result will be incomplete, and might cause churn in the data plane.
109109
if r.xdsIRReady {
110-
for key, val := range result.XdsIR {
111-
if err := val.Validate(); err != nil {
112-
r.Logger.Error(err, "unable to validate xds ir, skipped sending it")
113-
} else {
114-
r.XdsIR.Store(key, val)
115-
}
110+
if err := result.XdsIR.Validate(); err != nil {
111+
r.Logger.Error(err, "unable to validate xds ir, skipped sending it")
112+
} else {
113+
r.XdsIR.Store(r.Name(), result.XdsIR)
116114
}
117115
}
118116

internal/gatewayapi/runner/runner_test.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"time"
88

99
"github.com/stretchr/testify/require"
10-
"k8s.io/apimachinery/pkg/types"
1110

1211
"github.com/envoyproxy/gateway/internal/envoygateway/config"
1312
"github.com/envoyproxy/gateway/internal/ir"
@@ -33,22 +32,21 @@ func TestRunner(t *testing.T) {
3332
require.NoError(t, err)
3433

3534
// IR is nil at start
36-
require.Equal(t, map[string]*ir.Xds{}, xdsIR.LoadAll())
37-
require.Equal(t, map[string]*ir.Infra{}, infraIR.LoadAll())
35+
require.Equal(t, (*ir.Xds)(nil), xdsIR.Get())
36+
require.Equal(t, (*ir.Infra)(nil), infraIR.Get())
3837

3938
// TODO: pass valid provider resources
4039

41-
// Reset gateway slice and update with a nil gateway to trigger a delete.
42-
pResources.DeleteGateways()
43-
key := types.NamespacedName{Namespace: "test", Name: "test"}
44-
pResources.Gateways.Store(key, nil)
40+
// Reset gatewayclass slice and update with a nil gatewayclass to trigger a delete
41+
pResources.DeleteGatewayClasses()
42+
pResources.GatewayClasses.Store("test", nil)
4543
require.Eventually(t, func() bool {
46-
out := xdsIR.LoadAll()
44+
out := xdsIR.Get()
4745
if out == nil {
4846
return false
4947
}
5048
// Ensure ir is empty
51-
return (reflect.DeepEqual(xdsIR.LoadAll(), map[string]*ir.Xds{})) && (reflect.DeepEqual(infraIR.LoadAll(), map[string]*ir.Infra{}))
49+
return (reflect.DeepEqual(*xdsIR.Get(), ir.Xds{})) && (reflect.DeepEqual(*infraIR.Get(), ir.Infra{Proxy: nil}))
5250
}, time.Second*1, time.Millisecond*20)
5351

5452
}

internal/gatewayapi/testdata/gateway-allows-same-namespace-with-allowed-httproute.out.yaml

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,31 @@ httpRoutes:
5454
reason: Accepted
5555
message: Route is accepted
5656
xdsIR:
57-
envoy-gateway-gateway-1:
58-
http:
59-
- name: envoy-gateway-gateway-1-http
60-
address: 0.0.0.0
61-
port: 10080
62-
hostnames:
63-
- "*"
64-
routes:
65-
- name: envoy-gateway-httproute-1-rule-0-match-0-*
66-
pathMatch:
67-
prefix: "/"
68-
destinations:
69-
- host: 7.7.7.7
70-
port: 8080
71-
weight: 1
57+
http:
58+
- name: envoy-gateway-gateway-1-http
59+
address: 0.0.0.0
60+
port: 10080
61+
hostnames:
62+
- "*"
63+
routes:
64+
- name: envoy-gateway-httproute-1-rule-0-match-0-*
65+
pathMatch:
66+
prefix: "/"
67+
destinations:
68+
- host: 7.7.7.7
69+
port: 8080
70+
weight: 1
7271
infraIR:
73-
envoy-gateway-gateway-1:
74-
proxy:
75-
metadata:
76-
labels:
77-
gateway.envoyproxy.io/owning-gateway: gateway-1
78-
name: envoy-gateway-gateway-1
79-
image: envoyproxy/envoy:v1.23-latest
80-
listeners:
81-
- address: ""
82-
ports:
83-
- name: envoy-gateway-gateway-1
84-
protocol: "HTTP"
85-
servicePort: 80
86-
containerPort: 10080
72+
proxy:
73+
metadata:
74+
labels:
75+
gateway.envoyproxy.io/owning-gatewayclass: envoy-gateway-class
76+
name: envoy-gateway-class
77+
image: envoyproxy/envoy:v1.23-latest
78+
listeners:
79+
- address: ""
80+
ports:
81+
- name: envoy-gateway-gateway-1
82+
protocol: "HTTP"
83+
servicePort: 80
84+
containerPort: 10080

internal/gatewayapi/testdata/gateway-allows-same-namespace-with-disallowed-httproute.out.yaml

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,23 @@ httpRoutes:
5454
reason: NotAllowedByListeners
5555
message: No listeners included by this parent ref allowed this attachment.
5656
xdsIR:
57-
envoy-gateway-gateway-1:
58-
http:
59-
- name: envoy-gateway-gateway-1-http
60-
address: 0.0.0.0
61-
hostnames:
62-
- "*"
63-
port: 10080
57+
http:
58+
- name: envoy-gateway-gateway-1-http
59+
address: 0.0.0.0
60+
hostnames:
61+
- "*"
62+
port: 10080
6463
infraIR:
65-
envoy-gateway-gateway-1:
66-
proxy:
67-
metadata:
68-
labels:
69-
gateway.envoyproxy.io/owning-gateway: gateway-1
70-
name: envoy-gateway-gateway-1
71-
image: envoyproxy/envoy:v1.23-latest
72-
listeners:
73-
- address: ""
74-
ports:
75-
- name: envoy-gateway-gateway-1
76-
protocol: "HTTP"
77-
servicePort: 80
78-
containerPort: 10080
64+
proxy:
65+
metadata:
66+
labels:
67+
gateway.envoyproxy.io/owning-gatewayclass: envoy-gateway-class
68+
name: envoy-gateway-class
69+
image: envoyproxy/envoy:v1.23-latest
70+
listeners:
71+
- address: ""
72+
ports:
73+
- name: envoy-gateway-gateway-1
74+
protocol: "HTTP"
75+
servicePort: 80
76+
containerPort: 10080

internal/gatewayapi/testdata/gateway-with-listener-with-invalid-allowed-namespaces-selector.out.yaml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,13 @@ httpRoutes:
5959
status: "False"
6060
reason: NoReadyListeners
6161
message: There are no ready listeners for this parent ref
62-
xdsIR:
63-
envoy-gateway-gateway-1: {}
62+
xdsIR: {}
6463
infraIR:
65-
envoy-gateway-gateway-1:
66-
proxy:
67-
metadata:
68-
labels:
69-
gateway.envoyproxy.io/owning-gateway: gateway-1
70-
name: envoy-gateway-gateway-1
71-
image: envoyproxy/envoy:v1.23-latest
72-
listeners:
73-
- address: ""
64+
proxy:
65+
metadata:
66+
labels:
67+
gateway.envoyproxy.io/owning-gatewayclass: envoy-gateway-class
68+
name: envoy-gateway-class
69+
image: envoyproxy/envoy:v1.23-latest
70+
listeners:
71+
- address: ""

internal/gatewayapi/testdata/gateway-with-listener-with-invalid-allowed-routes-group.out.yaml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,13 @@ httpRoutes:
5757
status: "False"
5858
reason: NoReadyListeners
5959
message: There are no ready listeners for this parent ref
60-
xdsIR:
61-
envoy-gateway-gateway-1: {}
60+
xdsIR: {}
6261
infraIR:
63-
envoy-gateway-gateway-1:
64-
proxy:
65-
metadata:
66-
labels:
67-
gateway.envoyproxy.io/owning-gateway: gateway-1
68-
name: envoy-gateway-gateway-1
69-
image: envoyproxy/envoy:v1.23-latest
70-
listeners:
71-
- address: ""
62+
proxy:
63+
metadata:
64+
labels:
65+
gateway.envoyproxy.io/owning-gatewayclass: envoy-gateway-class
66+
name: envoy-gateway-class
67+
image: envoyproxy/envoy:v1.23-latest
68+
listeners:
69+
- address: ""

0 commit comments

Comments
 (0)