ingress-auth


1.安装

1
yum -y install httpd

2.过程
[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’
spec:
rules:

  • host: auth.kk.com
    http:
    paths:

    • path: /
      backend:
      serviceName: svc-3
      servicePort: 80
      ingress对应相应的svc
      3.结果(http://auth.kk.com:30325) 用户密码登录
      在这里插入图片描述