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:$apr1$CVb1BkuF$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: /

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code