traefik基本用户认证Basic Authentication

  sre

C6A6DB43D20AB61AB56B0F9E71CA0EDF.jpg
apt install apache2-utils
创建验证文件:

root@nginx:~# htpasswd -c ./auth test
New password: 
Re-type new password: 
Adding password for user test
root@nginx:~# cat auth
test:apr1CVb1BkuF$9lrKDaf1mBtjOu/7N/SDK1

用auth文件创建secret:

[root@node01 ~]# kubectl create secret generic dashbaord-basic-auth --from-file auth --namespace=kube-system
secret/dashbaord-basic-auth created

调用:

kind: Ingress
apiVersion: extensions/v1beta1
metadata: 
    name: test-com
    namespace: kube-system
    annotations:
        kubernetes.io/ingress.class: traefik
        ingress.kubernetes.io/auth-type: "basic"
        ingress.kubernetes.io/auth-secret: "dashbaord-basic-auth"
spec:
    rules:
    -   host: test.com
        http:
            paths:
            -   backend:
                    serviceName: kubernetes-dashboard
                    servicePort: 443
                path: /

LEAVE A COMMENT

Captcha Code