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
gatewayapientry reported bykubectl get tigerastatusshowsAvailable=True. See Enable the Calico Ingress Gateway.The backend Kubernetes service (for example,
my-service) exists.
Procedure
Create a
Gatewayresource.apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: my-gateway spec: gatewayClassName: tigera-gateway-class listeners: - name: http protocol: HTTP port: 80Apply and verify:
$ kubectl apply -f gateway.yaml $ kubectl get gateway my-gateway NAME CLASS ADDRESS PROGRAMMED AGE my-gateway tigera-gateway-class False ...
Note
PROGRAMMEDshowsFalsebecause no LoadBalancer provider is available to assign an address. This is expected. The gateway is accepted and functional through NodePort.Create an
HTTPRoutethat 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: 80Apply and verify the route is attached:
$ kubectl apply -f httproute.yaml $ kubectl get httproute my-route NAME HOSTNAMES AGE my-route ["app.example.com"] ...
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.