Skip to content

Envoy Gateway ​

Envoy Gateway is an open-source project that provides a Kubernetes-native implementation of the Gateway API spec using Envoy Proxy as the data plane. It automatically translates Gateway API resources (GatewayClass, Gateway, HTTPRoute, etc.) into Envoy configuration, simplifying the management of HTTPS and TCP ingress traffic. It is an extremely capable load balancer and traffic gateway that can replace many otherwise dedicated solutions in this space (such as F5, Nginx, HAProxy, etc.) for Kubernetes-native workloads.

Gateway API is the successor and replacement of the Ingress resource in Kubernetes.

Installation ​

To install Envoy Gateway, select it from the list of installable applications for your Kubernetes cluster. Follow this guide on how to get there.

Envoy Gateway application installation

Continue to proceed with the application installation steps. Do not change the provided default values.yaml unless necessary.

💡 Note

The shown values will also contain a list of out-of-the-box supported container images for envoyproxy. Take note as these will be needed in later steps if your Kubernetes Service environment is air-gapped.

The result should look like this: Applications installed

You can also see the new envoy-gateway namespace where the application has been installed in your cluster:

bash
kubectl get namespaces
NAME                   STATUS   AGE
cert-manager           Active   3d
cilium-secrets         Active   4d
cloud-init-settings    Active   4d
default                Active   4d
envoy-gateway          Active   5m
kube-node-lease        Active   4d
kube-public            Active   4d
kube-system            Active   4d
kubernetes-dashboard   Active   4d
kubevirt-csi-driver    Active   4d

Usage ​

Custom EnvoyProxy ​

As most Kubernetes Service environments are usually air-gapped, the Envoy Gateway operator will need to told where to pull the container images from for deploying gateway controllers, envoy proxies, etc. This can be any container registry available to the users, but for convenience the environment also hosts all necessary images internally.

The internal container registry path can be seen during installation of the envoy-gateway application, as was mentioned in the previous steps.

To successfully deploy an entire Envoy Gateway setup in an air-gapped environment, we will need to add additional parameters on GatewayClass, to use a custom EnvoyProxy configuration that specifies the container image explicitely. This is also explained in the upstream documentation for air-gapped deployments.


Use this yaml manifest as a basis to create the customized GatewayClass and EnvoyProxy, along with a Gateway:

yaml
---
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
  name: example-gateway-class
  namespace: envoy-gateway
spec:
  controllerName: gateway.envoyproxy.io/gatewayclass-controller
  parametersRef:
    group: gateway.envoyproxy.io
    kind: EnvoyProxy
    name: custom-proxy-config
    namespace: envoy-gateway

---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
  name: custom-proxy-config
  namespace: envoy-gateway
spec:
  provider:
    type: Kubernetes
    kubernetes:
      envoyDeployment:
        replicas: 3
        container:
          # replace "ENV_ID" with your environment ID:
          # https://docs.cloud.swisscom.ch/guide/cloud-services/kubernetes-service/manage/environment/#environment-id
          image: registry.ENV_ID.ks.private.cloud.swisscom.ch/envoyproxy/envoy:distroless-v1.36.5
          resources:
            requests:
              cpu: "100m"
              memory: "128Mi"
        pod:
          topologySpreadConstraints:
          - maxSkew: 1
            topologyKey: topology.kubernetes.io/zone
            whenUnsatisfiable: DoNotSchedule
            labelSelector:
              matchLabels:
                app.kubernetes.io/managed-by: envoy-gateway
                gateway.envoyproxy.io/owning-gateway-name: example-gateway # must match "Gateway" name, see below
            matchLabelKeys:
            - gateway.envoyproxy.io/owning-gateway-namespace
            - pod-template-hash
            nodeAffinityPolicy: Honor

---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: example-gateway
  namespace: envoy-gateway
spec:
  gatewayClassName: example-gateway-class
  listeners:
  - name: http
    protocol: HTTP
    port: 8080
    allowedRoutes:
      namespaces:
        from: All
  ## uncomment the line below if you want to explicitely specify the LB IP
  # infrastructure:
  #   annotations:
  #     metallb.io/loadBalancerIPs: 1.2.3.4

The result on Kubernetes should look like this:

bash
kubectl -n envoy-gateway get all,gatewayclass,gateway,envoyproxy
NAME                                                                READY   STATUS    RESTARTS   AGE
pod/envoy-envoy-gateway-example-gateway-7b4cb313-57cfb6d657-29ftw   2/2     Running   0          46s
pod/envoy-envoy-gateway-example-gateway-7b4cb313-57cfb6d657-9ntfj   2/2     Running   0          46s
pod/envoy-envoy-gateway-example-gateway-7b4cb313-57cfb6d657-knx74   2/2     Running   0          46s
pod/envoy-gateway-79fffd7778-2nxkj                                  1/1     Running   0          16m
pod/envoy-gateway-79fffd7778-7w87f                                  1/1     Running   0          16m

NAME                                                   TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)                                            AGE
service/envoy-envoy-gateway-example-gateway-7b4cb313   LoadBalancer   10.241.15.111   144.11.32.19   8080:30649/TCP                                     47s
service/envoy-gateway                                  ClusterIP      10.241.9.56     <none>           18000/TCP,18001/TCP,18002/TCP,19001/TCP,9443/TCP   16m

NAME                                                           READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/envoy-envoy-gateway-example-gateway-7b4cb313   3/3     3            3           47s
deployment.apps/envoy-gateway                                  2/2     2            2           16m

NAME                                                                      DESIRED   CURRENT   READY   AGE
replicaset.apps/envoy-envoy-gateway-example-gateway-7b4cb313-57cfb6d657   3         3         3       47s
replicaset.apps/envoy-gateway-79fffd7778                                  2         2         2       16m

NAME                                                           CONTROLLER                                      ACCEPTED   AGE
gatewayclass.gateway.networking.k8s.io/example-gateway-class   gateway.envoyproxy.io/gatewayclass-controller   True       48s

NAME                                                CLASS                   ADDRESS          PROGRAMMED   AGE
gateway.gateway.networking.k8s.io/example-gateway   example-gateway-class   144.11.32.19   True         47s

NAME                                                   AGE
envoyproxy.gateway.envoyproxy.io/custom-proxy-config   48s

We can see that the example-gateway and its envoy proxy replicas are up and running and was assigned an external LoadBalancer IP address.

HTTPRoute example ​

Once the Envoy Gateway controller and Envoy Proxy replicas are up and running, we can deploy an application that can be accessed by an HTTPRoute:

yaml
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: example-httproute
  namespace: example
spec:
  parentRefs:
  - name: example-gateway
    namespace: envoy-gateway
  hostnames:
  - www.example-domain.com
  rules:
  - backendRefs:
    - name: example-service
      kind: Service
      port: 8080

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-app
  namespace: example
spec:
  replicas: 1
  selector:
    matchLabels:
      app: example-app
  template:
    metadata:
      labels:
        app: example-app
    spec:
      containers:
      - name: app
        # replace "ENV_ID" with your environment ID:
        # https://docs.cloud.swisscom.ch/guide/cloud-services/kubernetes-service/manage/environment/#environment-id
        image: registry.ENV_ID.ks.private.cloud.swisscom.ch/nginx:1.29.8-alpine
        ports:
        - containerPort: 80

---
apiVersion: v1
kind: Service
metadata:
  name: example-service
  namespace: example
spec:
  type: ClusterIP
  selector:
    app: example-app
  ports:
  - name: http
    protocol: TCP
    port: 8080
    targetPort: 80

The result on Kubernetes should look like this:

bash
kubectl -n example get all,httproute
NAME                               READY   STATUS    RESTARTS   AGE
pod/example-app-745cfb9c8d-kt4c8   1/1     Running   0          27s

NAME                      TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)    AGE
service/example-service   ClusterIP   10.241.9.207   <none>        8080/TCP   27s

NAME                          READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/example-app   1/1     1            1           27s

NAME                                     DESIRED   CURRENT   READY   AGE
replicaset.apps/example-app-745cfb9c8d   1         1         1       27s

NAME                                                    HOSTNAMES                    AGE
httproute.gateway.networking.k8s.io/example-httproute   ["www.example-domain.com"]   27s

We can verify the HTTPRoute is working by testing it with curl:

bash
curl http://144.11.32.19:8080/ -H 'Host: www.example-domain.com'

Documentation ​

Please consult the excellent Envoy Gateway documentation for more details and examples, such as HTTPS configuration, basic auth, OIDC authentication, TLS passthrough, TCP and UDP routing, header rules, circuit breakers, traffic filtering, etc..