traefik ingress

上面的方式需要引入haprox或者nginx,多引入了一个代理转发层,其实ingress本身就提供了basic auth的支持,在ingress规则中添加额外的认证annotations即可。

  • 首先,我们需要创建用于存储用户名和密码的htpasswd文件
  $ htpasswd -bc auth admin admin
  • 然后,然后创建一个基于auth文件的secret
  $ kubectl create secret generic system-basic-auth --from-file=auth -n kube-system
  • 现在我们需要将auth-type:basicauth-secret:system-basic-auth注释添加到ingress定义中。这告诉traefik ingress controller为hosts 配置basic auth,以及从哪里读取htpasswd文件。
  apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: traefik-system
    namespace: kube-system
    annotations:
      ingress.kubernetes.io/auth-type: basic
      ingress.kubernetes.io/auth-secret: system-basic-auth
  spec:
    rules:
    - host: k8s.local
      http:
        paths:
        - path: /
          backend:
            serviceName: haproxy
            servicePort: k8s-ui

相关文章:

  • 2021-09-18
  • 2021-12-17
  • 2021-11-01
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2021-12-31
相关资源
相似解决方案