Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

We are migrating from a traditional nginx deployment to a kubernetes nginx-ingress controller. I'm trying to apply settings at a location level, but can't see how to do so with annotations.

For example, we had:

server {
  listen 80;
  server_name example.com;

  location /allow-big-uploads {
    client_max_body_size 100M;
    ...
  }
}

And we translate to something like this:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: web-ingress
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: 100m <-- this now applies globally
spec:
  rules:
    - host: example.com
      http:
        paths:
          - path: /allow-big-uploads
            backend:
              serviceName: example-svc
              servicePort: 5009

Adding that annotation under the path section doesn't seem to work. Am I missing something?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
888 views
Welcome To Ask or Share your Answers For Others

1 Answer

Annotations can only be set on the whole kubernetes resource, as they are part of the resource metadata. The ingress spec doesn't include that functionality at a lower level.

If you are looking for more complex setups, traefik have built a custom resource definition for their ingress controller that allows more configuration per service. The downside is the definition is not compatible with other ingress controllers.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...