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

Categories

0 votes
940 views
in Technique[技术] by (71.8m points)

kubernetes - Apply nginx-ingress annotations at path level

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

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

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...