Lesson 11 Gateway API
Theme:
Lesson 11 · Slide 1

Gateway API

The next generation of Kubernetes traffic management — more expressive, role-oriented, and portable than Ingress.

Lesson 11 · Slide 2

Gateway API vs Ingress

FeatureIngressGateway API
API maturityv1 (frozen)v1 (actively evolving)
Protocol supportHTTP/HTTPS onlyHTTP, TLS, TCP, gRPC, UDP
Role separationNoneInfrastructure / Cluster / App developer
Header manipulationAnnotation hacksNative filters
Traffic splittingNot standardBuilt-in backendRefs weights
Cross-namespaceNot supportedReferenceGrant
PortabilityAnnotation-dependentPortable core spec
Notes: Ingress is not deprecated but is frozen at v1. The Gateway API is the recommended path forward for all new projects.
Lesson 11 · Slide 3

Role Separation Model

Infrastructure Provider

Manages GatewayClass — defines which controller handles Gateways (e.g. Envoy, Istio).

Cluster Operator

Manages Gateway — configures listeners, ports, TLS certificates, and which namespaces can attach routes.

Application Developer

Manages HTTPRoute / TLSRoute / GRPCRoute — defines how traffic reaches their services.

# Infrastructure Provider
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
  name: envoy
spec:
  controllerName: gateway.envoyproxy.io/gatewayclass-controller
  parametersRef:
    group: gateway.envoyproxy.io
    kind: EnvoyProxy
    name: custom-proxy
Lesson 11 · Slide 4

Gateway Resource

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: {{ include "mychart.fullname" . }}
  namespace: {{ .Release.Namespace }}
spec:
  gatewayClassName: {{ .Values.gateway.className }}
  listeners:
    - name: http
      port: 80
      protocol: HTTP
      hostname: "*.{{ .Values.gateway.domain }}"
      allowedRoutes:
        namespaces:
          from: Selector
          selector:
            matchLabels:
              gateway-access: "true"
    - name: https
      port: 443
      protocol: HTTPS
      hostname: "*.{{ .Values.gateway.domain }}"
      tls:
        mode: Terminate
        certificateRefs:
          - name: {{ .Values.gateway.tlsSecretName }}
      allowedRoutes:
        namespaces:
          from: All
Notes: allowedRoutes.namespaces.from can be All, Same, or Selector — controlling which namespaces may attach routes to this listener.
Lesson 11 · Slide 5

HTTPRoute

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: {{ include "mychart.fullname" . }}
spec:
  parentRefs:
    - name: {{ .Values.gateway.name }}
      namespace: {{ .Values.gateway.namespace }}
      sectionName: https
  hostnames:
    - {{ .Values.httpRoute.hostname }}
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /api
          headers:
            - name: x-api-version
              value: v2
      filters:
        - type: RequestHeaderModifier
          requestHeaderModifier:
            add:
              - name: x-routed-by
                value: gateway-api
      backendRefs:
        - name: {{ include "mychart.fullname" . }}-api
          port: {{ .Values.service.port }}
          weight: 90
        - name: {{ include "mychart.fullname" . }}-api-canary
          port: {{ .Values.service.port }}
          weight: 10
Notes: Weighted backendRefs enable canary deployments natively — no annotation gymnastics required.
Lesson 11 · Slide 6

ReferenceGrant & Filters

ReferenceGrant

apiVersion: gateway.networking.k8s.io/v1beta1
kind: ReferenceGrant
metadata:
  name: allow-from-web
  namespace: backend
spec:
  from:
    - group: gateway.networking.k8s.io
      kind: HTTPRoute
      namespace: web
  to:
    - group: ""
      kind: Service

Allows HTTPRoutes in the web namespace to reference Services in the backend namespace.

Common Filters

  • RequestHeaderModifier — add, set, or remove request headers
  • ResponseHeaderModifier — modify response headers
  • URLRewrite — rewrite hostname or path
  • RequestRedirect — HTTP redirects (301/302)
  • RequestMirror — duplicate traffic to a second backend
  • ExtensionRef — implementation-specific filters
Lesson 11 · Slide 7

Installing CRDs & Implementations

# Install Gateway API CRDs (standard channel)
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.0/standard-install.yaml

# Or experimental channel (includes TCPRoute, TLSRoute, GRPCRoute)
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.0/experimental-install.yaml

Popular Implementations

ImplementationController NameNotes
Envoy Gatewaygateway.envoyproxy.io/gatewayclass-controllerReference implementation, Envoy-based
Istioistio.io/gateway-controllerService mesh integration
Ciliumio.cilium/gateway-controllereBPF-powered, high performance
NGINX Gateway Fabricgateway.nginx.org/nginx-gateway-controllerNGINX-based, F5 supported
Lesson 11 · Slide 8

Summary

Next: Lesson 12 — NetworkPolicies

1 / ?