basic文件创建
htpasswd -c auth test
第一次创建的时候需要加-c
后面追加不需要
在K8S创建key文件
kubectl -n kube-system create secret generic basic-auth --from-file=auth
ingress 文件覆盖
1.nginx ingress 模板
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: prometheus-ingress
namespace: kube-system
annotations:
nginx.ingress.kubernetes.io/auth-type: basic
nginx.ingress.kubernetes.io/auth-secret: basic-auth
spec:
rules:
- host: prometheus.devops-test.com
http:
paths:- path: /
backend:
serviceName: prometheus
servicePort: 9090
- path: /
2.traefik ingress 模板
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: prometheus-ingress
namespace: kube-system
annotations:
kubernetes.io/ingress.class: traefik
ingress.kubernetes.io/auth-type: basic
ingress.kubernetes.io/auth-secret: basic-auth
spec:
rules:
- host: prometheus.devops-test.com
http:
paths:- path: /
backend:
serviceName: prometheus
servicePort: 9090
- path: /
网友评论