ingress password authentication

traefik ingress

The above method needs to introduce haproxor nginxintroduce an additional proxy forwarding layer, which in fact ingressprovides basic authsupport itself, just ingressadd additional authentication annotationsto the rules.

  • htpasswdFirst, we need to create files for storing usernames and passwords
  $ htpasswd -bc auth admin admin
  • Then, then create a authfile-basedsecret
  $ kubectl create secret generic system-basic-auth --from-file=auth -n kube-system
  • Now we need to add the auth-type:basicand auth-secret:system-basic-authannotations to the ingressdefinition. This tells what traefik ingress controllerto configure for hosts basic auth, and where to read htpasswdfiles from.
  apiVersion: extensions/v1beta1
  kind: Ingress
  metadata: name: traefik-system namespace: kube-system annotations: ingress.kubernetes.io/auth-type: basic ingress.kubernetes.io/auth-secret: system-basic-auth spec: rules: - host: k8s.local http: paths: - path: / backend: serviceName: haproxy servicePort: k8s-ui 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325379790&siteId=291194637