OpenMCF logoOpenMCF

Loading...

Kubernetes HTTP Route

Provision a Kubernetes Gateway API HTTPRoute -- namespaced HTTP routing rules that attach to a Gateway and forward matching requests to backend Services. Match by hostname, path, header, query parameter, or method; transform with filters; and split traffic across weighted backends.

What Gets Created

  • A namespaced gateway.networking.k8s.io/v1 HTTPRoute custom resource.
  • One or more rules, each with matches, optional filters, and backend refs.
  • Optional per-rule and per-backend filters (header modification, redirect, URL rewrite, request mirror, CORS, or an implementation-specific extension).

Prerequisites

  • Gateway API CRDs installed on the cluster (KubernetesGatewayApiCrds).
  • A Gateway to attach to via parentRefs (KubernetesGateway).
  • The target namespace (KubernetesNamespace).
  • The backend Services the route forwards to.

Quick Start

apiVersion: kubernetes.openmcf.org/v1
kind: KubernetesHttpRoute
metadata:
  name: web-route
spec:
  namespace:
    value: app-ns
  parentRefs:
    - name: my-gateway
  hostnames:
    - app.example.com
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: web
          port: 8080
openmcf apply -f httproute.yaml

Configuration Reference

Required Fields

FieldTypeDescription
namespacereferenceNamespace to create the route in.
ruleslistAt least one routing rule.

Optional Fields

FieldTypeDescription
parentRefslistGateways (and optional listener sectionName) the route attaches to.
hostnameslistHost header values that select this route.
rules[].matcheslistPath, header, query-param, and method matchers.
rules[].filterslistHeader modify, redirect, URL rewrite, request mirror, CORS, extension ref.
rules[].backendRefslistWeighted backends to forward to.
rules[].timeoutsobjectRequest and backend-request timeouts.

Examples

Host + path routing

spec:
  namespace:
    value: app-ns
  parentRefs:
    - name: my-gateway
  hostnames:
    - app.example.com
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /api
      backendRefs:
        - name: api
          port: 8080

Weighted canary split

spec:
  namespace:
    value: app-ns
  parentRefs:
    - name: my-gateway
  hostnames:
    - app.example.com
  rules:
    - backendRefs:
        - name: web-stable
          port: 8080
          weight: 90
        - name: web-canary
          port: 8080
          weight: 10

Stack Outputs

OutputDescription
routeNameName of the created HTTPRoute (equals metadata.name).
namespaceNamespace the HTTPRoute was created in.

Related Components

  • Kubernetes Gateway
  • Kubernetes Gateway Class
  • Kubernetes Gateway API CRDs
  • Kubernetes Namespace

Next article

Kubernetes Ingress Nginx

Kubernetes Ingress Nginx Deploys the ingress-nginx controller on Kubernetes using the upstream Helm chart (default version 4.11.1), with provider-specific load balancer configuration for GKE, EKS, and AKS, optional internal load balancer mode, configurable chart version, and optional namespace creation. What Gets Created When you deploy a KubernetesIngressNginx resource, OpenMCF provisions: Namespace — created only when createNamespace is true Helm Release (ingress-nginx) — deploys the...
Read next article
Presets
2 ready-to-deploy configurationsView presets →