在路径级别应用nginx-ingress注释 [英] Apply nginx-ingress annotations at path level
问题描述
我们正在从传统的nginx部署迁移到kubernetes的nginx-ingress控制器.我正在尝试在location
级别应用设置,但是看不到如何使用注释.
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.
例如,我们有:
server {
listen 80;
server_name example.com;
location /allow-big-uploads {
client_max_body_size 100M;
...
}
}
然后我们将其翻译为:
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
在path
部分下添加该注释似乎无效.我想念什么吗?
Adding that annotation under the path
section doesn't seem to work. Am I missing something?
推荐答案
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.
如果您正在寻找更复杂的设置,则 traefik 已构建了服务.缺点是定义与其他入口控制器不兼容.
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.
这篇关于在路径级别应用nginx-ingress注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!