-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for using gateway.spec.addresses as service external ips (#…
- Loading branch information
Showing
11 changed files
with
188 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Gateway Address | ||
|
||
The Gateway API provides an optional [Addresses][] field through which Envoy Gateway can set addresses for Envoy Proxy Service. The currently supported addresses are: | ||
|
||
- [External IPs](#External-IPs) | ||
|
||
## Installation | ||
|
||
Install Envoy Gateway: | ||
|
||
```shell | ||
helm install eg oci://docker.io/envoyproxy/gateway-helm --version v0.0.0-latest -n envoy-gateway-system --create-namespace | ||
``` | ||
|
||
Wait for Envoy Gateway to become available: | ||
|
||
```shell | ||
kubectl wait --timeout=5m -n envoy-gateway-system deployment/envoy-gateway --for=condition=Available | ||
``` | ||
|
||
## External IPs | ||
|
||
Using the addresses in `Gateway.Spec.Addresses` as the [External IPs][] of Envoy Proxy Service, this will __require__ the address to be of type `IPAddress`. | ||
|
||
Install the GatewayClass, Gateway from quickstart: | ||
|
||
```shell | ||
kubectl apply -f https://github.com/envoyproxy/gateway/releases/download/latest/quickstart.yaml -n default | ||
``` | ||
|
||
Set the address of the Gateway, the address settings here are for reference only: | ||
|
||
```shell | ||
kubectl patch gateway eg --type=json --patch '[{ | ||
"op": "add", | ||
"path": "/spec/addresses", | ||
"value": [{ | ||
"type": "IPAddress", | ||
"value": "1.2.3.4" | ||
}] | ||
}]' | ||
``` | ||
|
||
Verify the Gateway status: | ||
|
||
```shell | ||
kubectl get gateway | ||
|
||
NAME CLASS ADDRESS PROGRAMMED AGE | ||
eg eg 1.2.3.4 True 14m | ||
``` | ||
|
||
Verify the Envoy Proxy Service status: | ||
|
||
```shell | ||
kubectl get service -n envoy-gateway-system | ||
|
||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE | ||
envoy-default-eg-64656661 LoadBalancer 10.96.236.219 1.2.3.4 80:31017/TCP 15m | ||
envoy-gateway ClusterIP 10.96.192.76 <none> 18000/TCP 15m | ||
envoy-gateway-metrics-service ClusterIP 10.96.124.73 <none> 8443/TCP 15m | ||
``` | ||
|
||
[Addresses]: https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1beta1.GatewayAddress | ||
[External IPs]: https://kubernetes.io/docs/concepts/services-networking/service/#external-ips |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright Envoy Gateway Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// The full text of the Apache license is available in the LICENSE file at | ||
// the root of the repo. | ||
|
||
package gatewayapi | ||
|
||
import ( | ||
"sigs.k8s.io/gateway-api/apis/v1beta1" | ||
) | ||
|
||
var _ AddressesTranslator = (*Translator)(nil) | ||
|
||
type AddressesTranslator interface { | ||
ProcessAddresses(gateways []*GatewayContext, xdsIR XdsIRMap, infraIR InfraIRMap, resources *Resources) | ||
} | ||
|
||
func (t *Translator) ProcessAddresses(gateways []*GatewayContext, xdsIR XdsIRMap, infraIR InfraIRMap, resources *Resources) { | ||
for _, gateway := range gateways { | ||
// Infra IR already exist | ||
irKey := irStringKey(gateway.Gateway) | ||
gwInfraIR := infraIR[irKey] | ||
|
||
var ipAddr []string | ||
for _, addr := range gateway.Spec.Addresses { | ||
if *addr.Type == v1beta1.IPAddressType { | ||
ipAddr = append(ipAddr, addr.Value) | ||
} | ||
} | ||
gwInfraIR.Proxy.Addresses = ipAddr | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
internal/gatewayapi/testdata/gateway-with-addresses-with-ipaddress.in.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
gateways: | ||
- apiVersion: gateway.networking.k8s.io/v1beta1 | ||
kind: Gateway | ||
metadata: | ||
namespace: envoy-gateway | ||
name: gateway-1 | ||
spec: | ||
gatewayClassName: envoy-gateway-class | ||
listeners: | ||
- name: tcp | ||
protocol: TCP | ||
port: 80 | ||
addresses: | ||
- type: IPAddress | ||
value: 1.2.3.4 | ||
- type: IPAddress | ||
value: 5.6.7.8 | ||
- type: Hostname | ||
value: foo.bar |
54 changes: 54 additions & 0 deletions
54
internal/gatewayapi/testdata/gateway-with-addresses-with-ipaddress.out.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
gateways: | ||
- apiVersion: gateway.networking.k8s.io/v1beta1 | ||
kind: Gateway | ||
metadata: | ||
namespace: envoy-gateway | ||
name: gateway-1 | ||
spec: | ||
gatewayClassName: envoy-gateway-class | ||
listeners: | ||
- name: tcp | ||
protocol: TCP | ||
port: 80 | ||
addresses: | ||
- type: IPAddress | ||
value: 1.2.3.4 | ||
- type: IPAddress | ||
value: 5.6.7.8 | ||
- type: Hostname | ||
value: foo.bar | ||
status: | ||
listeners: | ||
- name: tcp | ||
supportedKinds: | ||
- group: gateway.networking.k8s.io | ||
kind: TCPRoute | ||
conditions: | ||
- type: Programmed | ||
status: "True" | ||
reason: Programmed | ||
message: Sending translated listener configuration to the data plane | ||
- type: Accepted | ||
status: "True" | ||
reason: Accepted | ||
message: Listener has been successfully translated | ||
xdsIR: | ||
envoy-gateway-gateway-1: {} | ||
infraIR: | ||
envoy-gateway-gateway-1: | ||
proxy: | ||
metadata: | ||
labels: | ||
gateway.envoyproxy.io/owning-gateway-name: gateway-1 | ||
gateway.envoyproxy.io/owning-gateway-namespace: envoy-gateway | ||
name: envoy-gateway-gateway-1 | ||
listeners: | ||
- address: "" | ||
ports: | ||
- name: tcp | ||
protocol: TCP | ||
servicePort: 80 | ||
containerPort: 10080 | ||
addresses: | ||
- 1.2.3.4 | ||
- 5.6.7.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters