Skip to main content

Kubernetes Ingress

tip
  • 如果设置了多个 默认 ingressclass 则必须为 ingress 指定 class

Ingress

default-ingress-backend.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: default-ingress-backend
spec:
defaultBackend:
service:
name: test
port:
number: 80
  • pathType
    • ImplementationSpecific - 大多实现默认为 Prefix
    • Exact - 完整匹配
    • Prefix - 前缀匹配
      • 路径 Prefix 而不是 字符串 Prefix
      • 例如 /a 匹配 /a/ 和 /a/b 但是不匹配 /aa
    • Mixed - Prefix+Exact

IngressClass

apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: external-lb
annotations:
# 标记为默认 ingress
ingressclass.kubernetes.io/is-default-class: true
spec:
controller: example.com/ingress-controller
parameters:
apiGroup: k8s.example.com
kind: IngressParameters
name: external-lb
namespace: external-configuration
# v1.22 beta
scope: Namespace