How do users access the containerized services?
Containers are not accessible by default
XXX
Responsible for routing requests to containers
Maintains rules for matching hosts and paths
Host port is directly forwarded to container
One port per host per port
Typical for self-hosted clusters without load balancer
kube-proxy
opens port >30.000 on all nodes…
…and forwards requests to a service
Typical for hosted clusters with hosted load balancer
Ingress defines rule to match requests and how to route them
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
spec:
rules:
- host: inmylab.de
http:
paths:
- pathType: Prefix
path: "/foo"
backend:
service:
name: foo-service
port:
number: 5678
Wildcard host names are allowed
Match paths using Exact
or Prefix
Can be backed by multiple pods
Service takes care of load balancing
Using nginx-based ingress controller
Two pods foo
and bar
and…
…accompanying services
Match host inmylab.de
Match path prefix /foo
and forward to service foo-service
Match path prefix /bar
and forward to service bar-service
Manage user access automatically
Define as code
DNS records route requests to hosts running the ingress controller (managed by external-dns
)
Connections are secured using TLS (certificates managed by cert-manager
)
Use more flexible ingress controller, e.g. traefik and many others
Shortcomings of Ingress
resource: focused on HTTP(S), annotations for advanced features
Solved by custom resources in some ingress controllers, e.g. IngressRoute
in traefik