Junior — Middle
What key parameters and settings must be configured in the Ingress object when working with Kubernetes?
sobes.tech AI
Answer from AI
In the Kubernetes Ingress object, the following key parameters must be configured:
- metadata.name — the name of the Ingress resource.
- spec.rules — routing rules specifying hosts and paths for request routing.
- spec.rules.host — the domain name that the Ingress will respond to.
- spec.rules.http.paths — a list of paths and their corresponding backend services.
- spec.rules.http.paths.backend.service.name — the name of the service to which traffic will be directed.
- spec.rules.http.paths.backend.service.port.number — the service port.
Additionally, the following are often configured:
- spec.tls — to enable TLS (HTTPS) with specified secret certificates.
- annotations — to configure specific parameters of the Ingress controller (e.g., timeouts, path rewriting, rate limiting).
Example of a minimal Ingress configuration:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: example.com
http:
paths:
- path: /app
pathType: Prefix
backend:
service:
name: example-service
port:
number: 80
tls:
- hosts:
- example.com
secretName: example-tls-secret
Without proper configuration of these parameters, the Ingress will not be able to route requests correctly to the required services within the cluster.