traefik基本用户认证Basic Authentication
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: /