Set up Envoy Gateway
Use Envoy Gateway to route external requests to a stage by hostname. You install Envoy Gateway, one edge Gateway, and one konfidence-router Gateway per landscape. You also register the activation task that lets Konfidence attach its routes. Gateway routing explains what each part does.
Prerequisites
Before you begin, make sure you have:
- Konfidence and the Kubernetes deployer installed.
- At least one landscape with a stage.
kubectl get stages -Alists them. - Helm 3.8 or later and
kubectlwith cluster-admin permissions. - No other Gateway API implementation that manages the Gateway API CRDs.
kubectl get crd gateways.gateway.networking.k8s.ioshows whether they exist.
The commands use these values. Replace them with your own:
export ENVOY_GATEWAY_VERSION=v1.9.2
export LANDSCAPE_NAMESPACE=kden-l-dev
export STAGE=dev-eu12
export STAGE_HOSTNAME=dev-eu12.example.kden.local
export SERVICE=my-serviceSERVICE is the name of a deployment result of the stage.
Install Envoy Gateway
Install the Gateway API and Envoy Gateway CRDs. The CRDs exceed the 1 MiB limit of a Helm release, so render them and apply them server-side:
bashhelm template eg oci://docker.io/envoyproxy/gateway-crds-helm \ --version "$ENVOY_GATEWAY_VERSION" \ --set crds.gatewayAPI.enabled=true \ --set crds.gatewayAPI.channel=standard \ --set crds.envoyGateway.enabled=true \ | kubectl apply --server-side -f -Install the controller in
GatewayNamespacemode. In this mode, each Gateway's proxy runs in the Gateway's own namespace. Thekonfidence-routerservice then lands in the landscape namespace, where your edge routes can reference it.bashhelm upgrade --install eg oci://docker.io/envoyproxy/gateway-helm \ --version "$ENVOY_GATEWAY_VERSION" \ --namespace envoy-gateway-system \ --create-namespace \ --set crds.enabled=false \ --set config.envoyGateway.provider.kubernetes.deploy.type=GatewayNamespace \ --wait
The helm upgrade command reports STATUS: deployed.
Create the edge Gateway
The edge Gateway receives external traffic. Envoy Gateway gives it a LoadBalancer service by default.
Create the namespace of the edge Gateway:
kubectl create namespace edge-gatewayLocal kind cluster
A kind cluster has no load balancer. On the Quickstart cluster, follow Use in a local kind cluster first. Then create the edge Gateway with the infrastructure block from that section.
Create the GatewayClass and the edge Gateway:
kubectl apply -f - <<EOF
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: envoy-gateway
spec:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: edge
namespace: edge-gateway
spec:
gatewayClassName: envoy-gateway
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: Same
EOF
kubectl wait gateway/edge -n edge-gateway --for=condition=Programmed --timeout=180sThe kubectl wait command prints condition met.
Create the konfidence-router Gateway for each landscape
Repeat this step for every landscape namespace. The EnvoyProxy resource pins the service to ClusterIP and gives it the stable name konfidence-router. The ReferenceGrant lets edge routes in edge-gateway use that service.
kubectl apply -f - <<EOF
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
name: konfidence-router
namespace: $LANDSCAPE_NAMESPACE
spec:
provider:
type: Kubernetes
kubernetes:
envoyService:
name: konfidence-router
type: ClusterIP
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: konfidence-router
namespace: $LANDSCAPE_NAMESPACE
spec:
gatewayClassName: envoy-gateway
infrastructure:
parametersRef:
group: gateway.envoyproxy.io
kind: EnvoyProxy
name: konfidence-router
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: Same
---
apiVersion: gateway.networking.k8s.io/v1
kind: ReferenceGrant
metadata:
name: edge-gateway
namespace: $LANDSCAPE_NAMESPACE
spec:
from:
- group: gateway.networking.k8s.io
kind: HTTPRoute
namespace: edge-gateway
to:
- group: ""
kind: Service
name: konfidence-router
EOF
kubectl wait gateway/konfidence-router -n "$LANDSCAPE_NAMESPACE" --for=condition=Programmed --timeout=180skubectl get service konfidence-router -n "$LANDSCAPE_NAMESPACE" shows the type ClusterIP.
Register the activation task for each landscape
Repeat this step for every landscape namespace. Konfidence creates the stage routes on konfidence-router only if this registration exists. Without it, activations succeed but no route exists.
kubectl apply -f - <<EOF
apiVersion: konfidence.cloud/v1alpha1
kind: ActivationTaskRegistration
metadata:
name: gateway-route
namespace: $LANDSCAPE_NAMESPACE
spec:
type: gateway-route.konfidence.cloud
# Optional: gatewayName and gatewayNamespace override the Gateway that the
# routes attach to. They default to konfidence-router in this namespace.
spec: {}
EOFAfter the next activation of a stage in this landscape, kubectl get httproute -n "$LANDSCAPE_NAMESPACE" lists konfidence-stage-<stage>.
Route a hostname to each stage
Repeat this step for every stage that you want to expose outside the cluster. The route matches the stage's hostname. Each rule matches a path and sets the headers that select the stage and the deployment result. It then forwards the request to the landscape's konfidence-router. Add one rule per deployment result that you want to expose.
kubectl get httproute "konfidence-stage-$STAGE" -n "$LANDSCAPE_NAMESPACE" -o yaml shows the x-konfidence-service values that Konfidence matches once the stage is active.
kubectl apply -f - <<EOF
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: $STAGE
namespace: edge-gateway
spec:
parentRefs:
- name: edge
hostnames:
- $STAGE_HOSTNAME
rules:
- matches:
- path:
type: PathPrefix
value: /$SERVICE
filters:
- type: RequestHeaderModifier
requestHeaderModifier:
# set overwrites client-supplied values, so clients cannot
# pick another stage or service.
set:
# Selects the stage.
- name: x-konfidence-stage
value: $STAGE
# Selects the deployment result within the stage.
- name: x-konfidence-service
value: $SERVICE
backendRefs:
- name: konfidence-router
namespace: $LANDSCAPE_NAMESPACE
port: 80
EOFVerify the result
Check that the route is accepted and its backend resolves:
bashkubectl get httproute "$STAGE" -n edge-gateway \ -o jsonpath='{range .status.parents[0].conditions[*]}{.type}={.status}{"\n"}{end}'The output shows
Accepted=TrueandResolvedRefs=True.Send a request through the edge.
<EDGE_ADDRESS>is the address thatkubectl get gateway edge -n edge-gatewayshows. On a local kind cluster, uselocalhost:9090instead, as described in Use in a local kind cluster:bashcurl -i -H "Host: $STAGE_HOSTNAME" "http://<EDGE_ADDRESS>/$SERVICE"The
Hostheader selects the route, so you need no DNS entry or/etc/hostschange. Until Konfidence has created the stage's route, the response is404. The edge also answers404when no route matches, so the status does not show where the request ended.Check that the request reached
konfidence-router:bashkubectl logs -n "$LANDSCAPE_NAMESPACE" -c envoy --tail=5 \ -l gateway.envoyproxy.io/owning-gateway-name=konfidence-routerThe output contains an access log entry with the path
/$SERVICE. If no entry appears, the edge did not forward the request. Repeat the first step.
Use in a local kind cluster
The Quickstart cluster has no load balancer. Its script maps localhost:9090 to NodePort 30080 on the kind node. Give the edge Gateway a NodePort service on that port.
A kind cluster that you created yourself has no such mapping. Add an extraPortMappings entry from containerPort: 30080 to hostPort: 9090 to its configuration, then recreate the cluster.
Before you create the edge Gateway, create this
EnvoyProxy:bashkubectl apply -f - <<EOF apiVersion: gateway.envoyproxy.io/v1alpha1 kind: EnvoyProxy metadata: name: edge namespace: edge-gateway spec: provider: type: Kubernetes kubernetes: envoyService: name: edge type: NodePort patch: type: StrategicMerge value: spec: ports: - port: 80 nodePort: 30080 EOFAdd this block to the
specof the edge Gateway:yamlinfrastructure: parametersRef: group: gateway.envoyproxy.io kind: EnvoyProxy name: edgeSend requests to
localhost:9090:bashcurl -i -H "Host: $STAGE_HOSTNAME" "http://localhost:9090/$SERVICE"
Troubleshooting
| Symptom | Likely cause | Resolution |
|---|---|---|
helm install fails with Too long: may not be more than 1048576 bytes | You installed the CRD chart with helm install | Render it with helm template and apply it server-side, as in the first step. |
Edge route shows ResolvedRefs=False with reason RefNotPermitted | The ReferenceGrant is missing in the landscape namespace | Create the ReferenceGrant from the konfidence-router step. |
Edge route shows ResolvedRefs=False with reason BackendNotFound | The konfidence-router service is in envoy-gateway-system | Install the controller with deploy.type=GatewayNamespace. Then recreate the Gateway. |
kubectl get httproute -n "$LANDSCAPE_NAMESPACE" lists no konfidence-stage-<stage> route after an activation | The activation task is not registered in the landscape namespace | Create the ActivationTaskRegistration from the registration step. Konfidence creates the route on the next activation of the stage. |
curl returns 404 although konfidence-stage-<stage> exists | The edge route does not set x-konfidence-service, or its value is not a deployment result name | Compare the edge route's x-konfidence-service value with the values in konfidence-stage-<stage>. |
curl returns 503 with upstream connect error | The backend Pod of the stage does not accept connections | Check the Pod with kubectl get pods -n "$LANDSCAPE_NAMESPACE". |
Next steps
- Gateway routing describes the contract for other gateway implementations.
- Create a stage, then route a hostname to it.