Create a Gateway and RoutesΒΆ

After the Calico Ingress Gateway is enabled, you create a Gateway resource to define the entry point for external traffic, and an HTTPRoute to route that traffic to a backend service.

Prerequisites

  • The Calico Ingress Gateway is enabled and the gatewayapi entry reported by kubectl get tigerastatus shows Available=True. See Enable the Calico Ingress Gateway.

  • The backend Kubernetes service (for example, my-service) exists.

Procedure

  1. Create a Gateway resource.

    apiVersion: gateway.networking.k8s.io/v1
    kind: Gateway
    metadata:
      name: my-gateway
    spec:
      gatewayClassName: tigera-gateway-class
      listeners:
        - name: http
          protocol: HTTP
          port: 80
    

    Apply and verify:

    $ kubectl apply -f gateway.yaml
    $ kubectl get gateway my-gateway
    NAME         CLASS                  ADDRESS   PROGRAMMED   AGE
    my-gateway   tigera-gateway-class             False        ...
    

    Note

    PROGRAMMED shows False because no LoadBalancer provider is available to assign an address. This is expected. The gateway is accepted and functional through NodePort.

  2. Create an HTTPRoute that routes traffic from the gateway to the backend service.

    apiVersion: gateway.networking.k8s.io/v1
    kind: HTTPRoute
    metadata:
      name: my-route
    spec:
      parentRefs:
        - name: my-gateway
      hostnames:
        - "app.example.com"
      rules:
        - matches:
            - path:
                type: PathPrefix
                value: /
          backendRefs:
            - name: my-service
              port: 80
    

    Apply and verify the route is attached:

    $ kubectl apply -f httproute.yaml
    $ kubectl get httproute my-route
    NAME       HOSTNAMES              AGE
    my-route   ["app.example.com"]    ...
    
  3. Test connectivity through NodePort.

    $ kubectl get svc -n tigera-gateway
    NAME                                TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)         AGE
    envoy-default-my-gateway-<hash>     LoadBalancer   10.x.x.x       <pending>     80:3xxxx/TCP    ...
    
    $ curl -H "Host: app.example.com" http://<node-ip>:<nodeport>/
    

Traffic sent to the gateway NodePort with the configured host header is routed to the backend service.

For TLS termination, traffic splitting, TCP routing, and TLS passthrough, see Calico Ingress Gateway Advanced Configurations.