ingress密码验证

1.安装

1
yum -y install httpd

2.过程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@apiserver local]# mkdir basic-auth
[root@apiserver local]# cd basic-auth/
[root@apiserver basic-auth]# ls
[root@apiserver basic-auth]# htpasswd -c auth foo
New password:
Re-type new password:
Adding password for user foo
[root@apiserver basic-auth]# kubectl create secret generic basic-auth --from-file=auth
secret/basic-auth created

[root@apiserver basic-auth]# vim ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-with-auth
annotations:

nginx.ingress.kubernetes.io/auth-type: basic
nginx.ingress.kubernetes.io/auth-secret: basic-auth
nginx.ingress.kubecnetes.io/auth-realm: ‘Authentication Required - foo’ # foo对应用户名
spec:
rules: