Ingress认证

Basic Authentication

This example shows how to add authentication in a Ingress rule using a secret that contains a file generated with htpasswd. It's important the file generated is named auth (actually - that the secret has a key data.auth), otherwise the ingress-controller returns a 503.

Create htpasswd file

$ htpasswd -c auth foo
New password: <bar>
New password:
Re-type new password:
Adding password for user foo

Convert htpasswd into a secret

$ kubectl create secret -n generic basic-auth --from-file=auth
secret "basic-auth" created

Examine secret

$ kubectl get secret basic-auth -o yaml
apiVersion: v1
data:
  auth: Zm9vOiRhcHIxJE9GRzNYeWJwJGNrTDBGSERBa29YWUlsSDkuY3lzVDAK
kind: Secret
metadata:
  name: basic-auth
  namespace: default
type: Opaque
tag(s): none
show comments · back · home
Edit with markdown

已有 3 条评论

  1. vfopydoyhy

    ?内容类评语?

    vfopydoyhy March 2nd, 2025 at 01:19 pm回复
  2. rkazryskrn

    每一个段落都紧密相连,逻辑清晰,展现了作者高超的写作技巧。

    rkazryskrn March 2nd, 2025 at 08:35 pm回复
  3. jvopufdhzf

    作者的观点新颖且实用,让人在阅读中获得了新的思考和灵感。

    jvopufdhzf March 4th, 2025 at 06:53 pm回复