Ingress configurations in helm values files.
The following setup assumes that you have a helm chart which provides the configuration to deploy a service and an ingress for it
Now, lets look at few of the sample helm values file configurations for ingress configurations with ingress-nginx.
Enable Cors¶
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-methods: "DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT"
nginx.ingress.kubernetes.io/cors-allow-headers: "*"
nginx.ingress.kubernetes.io/cors-allow-origin: "*"
nginx.ingress.kubernetes.io/cors-max-age: "100"
nginx.ingress.kubernetes.io/cors-allow-credentials: "true"
hosts:
- host: ravikrs.com
paths:
- path: /test/path1
pathType: Prefix
- path: /path2
pathType: Prefix
|
External Authentication¶
External Authentication configuration based from doc
1
2
3
4
5
6
7
8
9
10
11
12
13
| ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
# authentication/authorization service url
nginx.ingress.kubernetes.io/auth-url: http://auth-service.namespace.svc.cluster.local:8080/auth/urls
# response urls to be returned from auth service and passed to services
nginx.ingress.kubernetes.io/auth-response-headers: "X-Header1, X-Header2, X-Header3"
hosts:
- host: ravikrs.com
paths:
- path: /test/path
pathType: Prefix
|
Setup additional headers returned to the caller/client based from doc
1
2
3
4
5
6
7
8
9
10
11
12
| ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/configuration-snippet: |
more_set_headers "X-Header1: value1";
more_set_headers "Deprecation: true";
hosts:
- host: ravikrs.com
paths:
- path: /test
pathType: Prefix
|
Path Rewrite¶
Rewrite path /service1/swagger
url to /swagger/
path for kubernetes service exposing deployment. See docs
1
2
3
4
5
6
7
8
9
10
| ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /swagger/$1
hosts:
- host: ravikrs.com
paths:
- path: /service1/swagger/(.*)
pathType: Prefix
|
Use Regex in Path¶
We may also use regular expression to handle ingress path configurations. See docs
1
2
3
4
5
6
7
8
9
10
| ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: "true"
hosts:
- host: ravikrs.com
paths:
- path: /path/[A-Za-z0-9]+
pathType: Prefix
|
Links¶