Skip to content

Commit

Permalink
Merge pull request #900 from jcmoraisjr/jm-gateway-v1alpha2
Browse files Browse the repository at this point in the history
Add starting implementation of Gateway API v1alpha2
  • Loading branch information
jcmoraisjr authored Feb 13, 2022
2 parents 98b8a99 + 38e5924 commit 0dde900
Show file tree
Hide file tree
Showing 16 changed files with 2,991 additions and 1,212 deletions.
46 changes: 23 additions & 23 deletions docs/content/en/docs/configuration/gateway-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,50 @@ description: >
Configure HAProxy using Gateway API resources.
---

[Gateway API](https://gateway-api.sigs.k8s.io/) is a collection of Kubernetes resources that can be installed as [Custom Resource Definitions](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/). Just like Ingress resources, Gateway API resources are used to configure incoming HTTP/s and TCP requests to the in cluster applications. HAProxy Ingress v0.13 partially supports the Gateway API spec.
[Gateway API](https://gateway-api.sigs.k8s.io/) is a collection of Kubernetes resources that can be installed as [Custom Resource Definitions](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/). Just like Ingress resources, Gateway API resources are used to configure incoming HTTP/s and TCP requests to the in cluster applications. HAProxy Ingress v0.14 partially supports the Gateway API spec, v1alpha1 and v1alpha2 versions.

## Installation

The following steps configure the Kubernetes cluster and HAProxy Ingress to read and parse Gateway API resources:

* Manually install the Gateway API CRDs, see the Gateway API [documentation](https://gateway-api.sigs.k8s.io/v1alpha1/guides/getting-started/#installing-gateway-api-crds-manually)
* ... or simply `kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd?ref=v0.3.0" | kubectl apply -f -`
* Manually install the Gateway API CRDs, see the Gateway API [documentation](https://gateway-api.sigs.k8s.io/v1alpha2/guides/getting-started/#installing-gateway-api-crds-manually)
* ... or simply `kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd?ref=v0.4.1" | kubectl apply -f -`
* Start (or restart) the controller

See below the [getting started steps](#getting-started).

## Conformance

Gateway API v1alpha1 spec is partially implemented in the v0.13 release. The following list describes what is (or is not) supported:
Gateway API v1alpha2 spec is partially implemented in the v0.14 release. The following list describes what is (or is not) supported:

* Target Services can be annotated with [Backend or Path scoped]({{% relref "keys#scope" %}}) configuration keys, this will continue to be supported.
* Gateway API resources doesn't support annotations, this will continue to be unsupported, extensions to the Gateway API spec will be added in the extension points of the API.
* Gateway API resources doesn't support annotations, this is planned to continue to be unsupported. Extensions to the Gateway API spec will be added in the extension points of the API.
* Only the `GatewayClass`, `Gateway` and `HTTPRoute` resource definitions were implemented.
* The controller doesn't implement partial parsing yet for Gateway API resources, changes should be a bit slow on clusters with thousands of Ingress, Gateway API resources or Services.
* Gateway's Listener Port and Protocol wasn't implemented - Port uses the global [bind-port]({{% relref "keys#bind-port" %}}) configuration and Protocol is based on the presence or absence of the TLS attribute.
* Gateway's Route Namespace selector only supports `Same` or `All` namespaces.
* Gateway's Addresses wasn't implemented - binding addresses use the global [bind-ip-addr]({{% relref "keys#bind-ip-addr" %}}) configuration.
* Gateway's Hostname only supports empty/absence of Hostname or a single `*`, any other string will override the HTTPRoute Hostnames configuration without any merging.
* HTTPRoute's Matches doesn't support Headers.
* HTTPRoute's Rules and ForwardTo doesn't support Filters.
* HTTPRoute's Rules and BackendRefs don't support Filters.
* Resources status aren't updated.

Version v1alpha2 should be partially implemented in v0.14 (beta version starting jan/22) and fully implemented in v0.15 (Q2'22).
Version v1alpha2 should be fully implemented in v0.15 (Q2'22).

Version v1alpha1 support should be dropped in v0.16.

## Ingress

A single HAProxy Ingress deployment can manage Ingress and Gateway API resources in the same Kubernetes cluster. If the same hostname and path is declared in the Gateway API and Ingress, the Gateway API wins and a warning is logged. Ingress resources will continue to be supported in future controller versions, without side effects, and without the need to install the Gateway API CRDs.
A single HAProxy Ingress deployment can manage Ingress, and both v1alpha1 and v1alpha2 Gateway API resources in the same Kubernetes cluster. If the same hostname and path with the same path type is declared in the Gateway API and Ingress, the Gateway API wins and a warning is logged. Ingress resources will continue to be supported in future controller versions, without side effects, and without the need to install the Gateway API CRDs.

## Getting started

Add the following steps to the [Getting Started guide]({{% relref "/docs/getting-started" %}}) in order to expose the echoserver service along with the Gateway API:

[Manually install](https://gateway-api.sigs.k8s.io/guides/getting-started/#installing-gateway-api-crds-manually) the Gateway API CRDs:
[Manually install](https://gateway-api.sigs.k8s.io/v1alpha2/guides/getting-started/#installing-gateway-api-crds-manually) the Gateway API CRDs:

```
kubectl kustomize\
"github.com/kubernetes-sigs/gateway-api/config/crd?ref=v0.3.0" |\
"github.com/kubernetes-sigs/gateway-api/config/crd?ref=v0.4.1" |\
kubectl apply -f -
```

Expand All @@ -61,52 +63,50 @@ kubectl --namespace default expose deployment echoserver --port=8080
A GatewayClass enables Gateways to be read and parsed by HAProxy Ingress. Create a GatewayClass with the following content:

```yaml
apiVersion: networking.x-k8s.io/v1alpha1
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: GatewayClass
metadata:
name: haproxy
spec:
controller: haproxy-ingress.github.io/controller
controllerName: haproxy-ingress.github.io/controller
```
Gateways create listeners and allow to configure hostnames. Create a Gateway with the following content:
Note: port and protocol attributes [have some limitations](#conformance).
```yaml
apiVersion: networking.x-k8s.io/v1alpha1
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: Gateway
metadata:
name: echoserver
namespace: default
spec:
gatewayClassName: haproxy
listeners:
- protocol: HTTP
- name: echoserver-gw
port: 80
routes:
kind: HTTPRoute
selector:
matchLabels:
gateway: echo
protocol: HTTP
```
HTTPRoutes configure the hostnames and target services. Create a HTTPRoute with the following content, changing `echoserver-from-gateway.local` to a hostname that resolves to a HAProxy Ingress node:

```yaml
apiVersion: networking.x-k8s.io/v1alpha1
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: HTTPRoute
metadata:
labels:
gateway: echo
name: echoserver
namespace: default
spec:
parentRefs:
- name: echoserver
hostnames:
- echoserver-from-gateway.local
rules:
- forwardTo:
- serviceName: echoserver
- backendRefs:
- name: echoserver
port: 8080
```

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
k8s.io/apimachinery v0.23.3
k8s.io/apiserver v0.23.3
k8s.io/client-go v0.23.3
sigs.k8s.io/gateway-api v0.3.0
sigs.k8s.io/gateway-api v0.4.1
)

require (
Expand All @@ -35,7 +35,7 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
Expand Down
Loading

0 comments on commit 0dde900

Please sign in to comment.