ingress-nginx配置basic认证

警告
本文最后更新于 2020-08-28 11:08,文中内容可能已过时。

1.创建认证文件(注意文件名必须叫auth)

1
htpasswd -bc auth admin 123456

2.生成secret

1
kubectl create secret generic --from-file=auth --namespace=kube-ops prome-basic-auth

3.配置ingress

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: prometheus
  namespace: kube-ops
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/auth-type: basic
    nginx.ingress.kubernetes.io/auth-secret: prome-basic-auth
    nginx.ingress.kubernetes.io/auth-realm: '提示信息'
spec:
  rules:
  - host: prom.soulchild.cn
    http:
      paths:
      - path: /
        backend:
          serviceName: prometheus
          servicePort: http
请我喝杯水
SoulChild 微信号 微信号
SoulChild 微信打赏 微信打赏
0%