根据namespace使用多个ingress controller

默认情况下,我们一个k8s环境所有的namespace使用的是同一个ingress-control,为了满足每个namespace使用不同的ingress-control,我们怎么做呢?

参考1

参考2

参考3

参考4

修改和注意的点有:

  • 创建ingress-control的时期启动参数args里面加上配置ingress.class配置,名字自取:
spec:
  template:
     spec:
       containers:
         - name: nginx-ingress-internal-controller
           args:
             - /nginx-ingress-controller
             - '--election-id=ingress-controller-leader-internal'
             - '--ingress-class=nginx-internal'
             - '--configmap=ingress/nginx-ingress-internal-controller'
  • 创建ingress时候加上注解指定:
metadata:
  name: foo
  annotations:
    kubernetes.io/ingress.class: "nginx"
  
  • 创建单独的namespace
  • 修改role中的配置:
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
  name: nginx-ingress-role
  namespace: ingress
rules:
  - apiGroups:
      - ""
    resources:
      - configmaps
      - pods
      - secrets
      - namespaces
    verbs:
      - get
  - apiGroups:
      - ""
    resources:
      - configmaps
    resourceNames:
      # Defaults to "-"
      # Here: "-"
      # This has to be adapted if you change either parameter
      # when launching the nginx-ingress-controller.
      - "ingress-controller-leader-abcdefg"  #此处跟着改
    verbs:
      - get
      - update
  - apiGroups:
      - ""
    resources:
      - configmaps
    verbs:
      - create
  - apiGroups:
      - ""
    resources:
      - endpoints
    verbs:
      - get

你可能感兴趣的:(根据namespace使用多个ingress controller)