What is the primary purpose of using annotations in a Kubernetes Ingress resource?
Think about how you can change settings like SSL or timeouts without modifying the main rules.
Annotations allow you to add extra configuration to the Ingress controller, such as SSL settings, timeouts, or rewrite rules, without altering the core Ingress specification.
Given this Ingress snippet with annotation nginx.ingress.kubernetes.io/ssl-redirect: "true", what effect does this have on HTTP requests?
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
rules:
- host: example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: example-service
port:
number: 80Consider what 'ssl-redirect: true' means for incoming traffic.
The annotation nginx.ingress.kubernetes.io/ssl-redirect: "true" tells the NGINX Ingress controller to redirect all HTTP requests to HTTPS automatically.
You want to set a custom proxy read timeout of 120 seconds on an NGINX Ingress. Which annotation correctly sets this timeout?
Look for the exact annotation name used by NGINX Ingress for read timeout.
The correct annotation to set the proxy read timeout in seconds is nginx.ingress.kubernetes.io/proxy-read-timeout. The value is in seconds as a string.
You added the annotation nginx.ingress.kubernetes.io/rewrite-target: / to your Ingress, but the URL paths are not rewritten as expected. What is a common cause?
Check the pathType used in the Ingress rule when using rewrite-target.
The rewrite-target annotation requires the Ingress path to be defined as a regex pathType to match and rewrite the URL path correctly.
Which annotation combination is best practice to enhance security by enabling HTTP Strict Transport Security (HSTS) with a max age of 6 months and including subdomains on an NGINX Ingress?
NGINX Ingress does not have built-in hsts annotations; custom headers are added via configuration-snippet.
NGINX Ingress does not support dedicated HSTS annotations. The best practice is to add the HSTS header using the configuration-snippet annotation with the correct header syntax.