Exposing an application¶
Through the cluster's Gateway (Gateway API): one Gateway, public in the namespace ethere-gateway, with an HTTPS
listener per name the cluster serves and their certificates (Let's Encrypt, renewed by the cluster). An application
attaches an HTTPRoute to it; there is no ingress controller to install, nor any certificate to declare.
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata: {name: my-app, namespace: my-app}
spec:
parentRefs: [{name: public, namespace: ethere-gateway}]
hostnames: [my-app.cloud.example.com]
rules: [{backendRefs: [{name: my-app, port: 8080}]}]
---
apiVersion: v1
kind: Service
metadata: {name: my-app, namespace: my-app}
spec:
ipFamilies: [IPv6]
selector: {app: my-app}
ports: [{port: 8080}]
---
# The pods are denied by default (Network): let the Gateway in.
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata: {name: my-app-from-gateway, namespace: my-app}
spec:
endpointSelector: {matchLabels: {app: my-app}}
ingress:
- fromEntities: [ingress]
toPorts: [{ports: [{port: "8080", protocol: TCP}]}]
Without the policy, the route answers but the backend doesn't (the Gateway's Envoy reaches pods as Cilium's
ingress identity).
Names¶
- A route's
hostnamesare among its namespace's allowed names, which the cluster's declaration grants (Getting started): the namespace's annotationethe.re/hostnameslists them (kubectl get namespace my-app -o jsonpath='{.metadata.annotations.ethe\.re/hostnames}'), a*.entry allowing every name under it. A route with another name, or withouthostnames(it would take every name of its listener), is refused when it is applied, the message naming the allowed ones. Members can't change the annotation. - Its DNS record is published by the cluster: a name under the cluster's zone (here
cloud.example.com; this cluster's is on its own page) gets its record once the route is accepted, nothing to do. A name under a project's own domain needs that domain delegated to the cluster, which the admins set up once. - Listeners: one per name of the cluster (
*.its zone, and each project domain), namedhttps-and the name with dots as dashes,*aswildcard(https-wildcard-cloud-example-com). WithoutsectionNameinparentRefs, a route attaches to every listener its names match. - HTTP (port 80) is redirected to HTTPS by the Gateway itself.
Redirects¶
A route's RequestRedirect names the public port (port: 443, otherwise it is the listener's internal one) and no
scheme (the Gateway's Envoy treats a redirect naming one as an HTTP-to-HTTPS redirect, never taken on an HTTPS
listener: the route answers 404):
rules:
- filters:
- type: RequestRedirect
requestRedirect: {hostname: my-app.cloud.example.com, port: 443, statusCode: 301}
gRPC and other protocols¶
GRPCRoute works like HTTPRoute, under the same names policy. Other TCP or UDP protocols aren't exposed by the
Gateway yet: ask the admins.