第一步,创建账号密码文件
这里需要使用到密码文件生成工具htpasswd
htpasswd -c auth user1
New password:
第二步,创建kubernets secret
kubectl -n
secret "basic-auth" created
第三步,创建ingress配置文件
kind: Ingress
metadata:
name: ingress-with-auth
annotations:
# type of authentication
ingress.kubernetes.io/auth-type: basic
# name of the secret that contains the user/password definitions
ingress.kubernetes.io/auth-secret: basic-auth
# message to display with an appropiate context why the authentication is required
ingress.kubernetes.io/auth-realm: "Authentication Required - foo"
spec:
rules:
- host: foo.bar.com
http:
paths:
- path: /
backend:
serviceName: echoheaders
servicePort: 80
https://johng.cn/kubernets-ingress-with-http-auth/
https://github.com/kubernetes/ingress-nginx/
https://kubernetes.github.io/ingress-nginx/kubectl-plugin/
https://kubernetes.github.io/ingress-nginx/examples/auth/external-auth/
https://pkg.go.dev/k8s.io/client-go/informers#NewFilteredSharedInformerFactory
https://stackoverflow.com/questions/34784644/what-is-the-difference-between-oauth-based-and-token-based-authentication
https://docs.ansible.com/ansible-tower/latest/html/administration/oauth2_token_auth.html
https://docs.ansible.com/ansible-tower/latest/html/administration/oauth2_token_auth.html#ag-use-oauth-pat