k8s traefik ingress web ui 利用中间件添加密码认证
1.首先生成需要为添加认证的服务生成密码yum -y install httpdhtpasswd -nb admin admin | openssl base64复制密码2.创建加密中间件web-ui-basic-auth.yaml# Declaring the user listapiVersion: traefik.containo.us/v1alpha1kind: M...
·
1.首先生成需要为添加认证的服务生成密码
yum -y install httpd
htpasswd -nb admin admin | openssl base64
复制密码
2.创建加密中间件
web-ui-basic-auth.yaml
# Declaring the user list
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: test-auth
spec:
basicAuth:
secret: authsecret
---
# Note: in a kubernetes secret the string (e.g. generated by htpasswd) must be base64-encoded first.
# To create an encoded user:password pair, the following command can be used:
# htpasswd -nb user password | openssl base64
apiVersion: v1
kind: Secret
metadata:
name: authsecret
data:
users: |2
YWRtaW46JGFwcjEkWUpSclBWOWYkU0FpeDEwVkFSa2UzL2I5VFhadDBjMAoK
将生成的密码填充到最后一行
kubectl apply -f ./web-ui-basic-auth.yaml
3.为目标服务添加认证中间件
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: traefik-dashboard-route
spec:
entryPoints:
- web
routes:
- match: Host(`traefik.test.com`)
kind: Rule
services:
- name: traefik
port: 8080
middlewares:
- name: test-auth
4.kubectl apply -f ./traefik-dashboard-route.yaml 重启ui
添加成功
更多推荐
所有评论(0)