哪个入口文档应该遵循?以及如何应用 nginx.conf?

huangapple go评论84阅读模式
英文:

Which ingress documentation to follow? and how to apply nginx.conf?

问题

https://kubernetes.github.io/ingress-nginx/

or

https://docs.nginx.com/nginx-ingress-controller/

我可以直接使用已经工作的 nginx.conf 吗?可以为 nginx.conf 创建一个 configMap。如何将 configMap 应用于以下的 Ingress?

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-ingress

spec:
  tls:
    - hosts:
        - "*.mydomin.com"
      secretName: mydomain-ssl

  rules:
    - host: "*.mydomain.com"
      http:
        paths:
          - pathType: Prefix
            path: "/"
            backend:
              service:
                name: my-webapp
                port:
                  number: 8080
英文:

https://kubernetes.github.io/ingress-nginx/

or

https://docs.nginx.com/nginx-ingress-controller/

Can I just use nginx.conf that is already working? A configMap can be created for the nginx.conf. How to apply the configMap to the following ingress?

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-ingress
      
spec:

  tls:
    - hosts:
        - "*.mydomin.com"
      secretName:mydomain-ssl

  rules:
    - host: "*.mydomain.com"
      http:
        paths:
          - pathType: Prefix
            path: "/"
            backend:
              service:
                name: my-webapp
                port:
                  number: 8080

答案1

得分: 1

要使用 nginx.conf 创建一个配置映射,请参考这份官方的 Google 文档

创建配置映射后,您可以使用 annotation “snippets” 将其应用到 Ingress 上,您可以在下面找到示例的 YAML,以获取更多信息,您可以查看这份 NGINX 文档

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
 name: cafe-ingress-with-annotations
 annotations:
   nginx.org/proxy-connect-timeout: "30s"
   nginx.org/proxy-read-timeout: "20s"
   nginx.org/client-max-body-size: "4m"
   nginx.org/server-snippets: |
     location / {
       return 302 /coffee;
     }           
spec:
英文:

To create a config map using the nginx.conf refer to this official Google document.

After creating a config map you can use annotation “snippets” to apply it to the ingress, you can find the sample yaml below and For more information you can follow this NGINX documentation.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
 name: cafe-ingress-with-annotations
 annotations:
   nginx.org/proxy-connect-timeout: "30s"
   nginx.org/proxy-read-timeout: "20s"
   nginx.org/client-max-body-size: "4m"
   nginx.org/server-snippets: |
     location / {
       return 302 /coffee;
     }      
spec:

huangapple
  • 本文由 发表于 2023年8月9日 14:33:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76865146-2.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定