Ingress
An ingress controller consists of:
- Ingress Controller: A deployment that implements the Ingress rules (e.g., NGINX, HAProxy)
- Managed via
kubectl edit deployment <ingress-controller-name>
- Managed via
- Ingress Resource: The configuration object that defines routing rules
- Managed via
kubectl edit ingress <ingress-name>
- Managed via
- IngressClass: Specifies which controller should implement the Ingress resource
- Links Ingress resources to their respective controllers
- Controller Pods: The actual running instances of the controller (e.g., NGINX pods)
- ConfigMap: Stores controller configuration settings
- Service: Exposes the Ingress controller to external traffic
- ServiceAccount: Provides necessary permissions for the controller to access K8s API
Multiple Ingresses (resources/configs)
An Ingress deployment can watch multiple Ingress resources for the path matchings.
$ k get ingress # Ingress resource object (rules)
$ k get ingressclass # The Ingress controller type
kubectl create ingress my-ingress \
--class=nginx \ # If not specified, uses the default one, may not work!!
--rule="wear.my-online-store.com/wear*=wear-service:80"
# Ingress is a deployment itself with it's own pods running in a namespace
$ k get deployments.apps -A | grep ingress
ingress-nginx ingress-nginx-controller 1/1 1 1 16m
-> Ingress Deployment has the default backend service defined.
ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-wear-watch
annotations:
nginx.ingress.kubernetes.io/rewrite-target: / #rewrites to / from /wear
nginx.ingress.kubernetes.io/ssl-redirect: false #rewrites to / from /wear
spec:
ingressClassName: nginx # If not specified, uses the default one, may not work!!
rules:
- host: incoming-host.com # If you omit, it is *
http:
paths:
- path: /wear
backend:
service:
name: wear-service
port:
number: 80
- path: ...
Ingress defines path forwardings to services, should be in the services namespace Service is the hostname with round-robin to pods. Service can use kube expose to be created with selectors An external service can be in another namespace Ingress Controller is the