Kubernetes

kubernetes-Ingress nginx

本文主要是介绍kubernetes-Ingress nginx,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

内部pod是Https

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  namespace: xxx
  name: xxx-web
  annotations:
    # 文件上传限制
    nginx.ingress.kubernetes.io/proxy-body-size: "200M"
    nginx.ingress.kubernetes.io/backend-protocol: HTTPS
spec:
  ingressClassName: nginx
  rules:
    - host: www.xxx.net
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: xxx-web
                port:
                  number: 443

Ingress配置Https

https://kubernetes.io/zh-cn/docs/concepts/services-networking/ingress/

  • 创建secret
kubectl create secret tls xxx-secret --cert=xxx.crt --key=xxx.key
  • 配置
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  namespace: xxx
  name: xxx-web
  annotations:
    # 文件上传限制
    nginx.ingress.kubernetes.io/proxy-body-size: "200M"
    nginx.ingress.kubernetes.io/backend-protocol: HTTPS
spec:
  ingressClassName: nginx
  tls:
  - hosts:
    - www.xxx.net
    secretName: xxx-secret
  rules:
    - host: www.xxx.net
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: xxx-web
                port:
                  number: 443

Websocket配置

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  namespace: xxx
  name: xxx-web
  annotations:
    # 代理发送超时
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
    # 代理读取超时
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    # 代理连接超时
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "3600"
    # 基于客户端出口ip哈希
    nginx.ingress.kubernetes.io/upstream-hash-by: "$http_x_forwarded_for"
spec:
  ingressClassName: nginx
  rules:
    - host: www.xxx.net
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: xxx-web
                port:
                  number: 443
这篇关于kubernetes-Ingress nginx的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!