k8s | ingress Basic Auth 설정

icurfer·2024년 5월 5일

kubernetes

목록 보기
3/5

Basic-Auth

BasicAuth는 Promehteus같이 인증수단이 없는 경우에 사용하도록 한다.

QuicStart

htpasswd 설치

apt-get install apache2-utils

auth 파일 생성

admin라는 사용자를 test라는 비밀번호로 auth 파일에 생성

htpasswd -cb auth admin test

secret생성

kubectl create -n monitoring secret generic basic-auth --from-file=auth

확인명령

kubectl get -n monitoring secret basic-auth -o yaml

인그레스 annotation추가

annotations:
  # 인증 방법 설정: basic auth
  nginx.ingress.kubernetes.io/auth-type: basic
  # basic auth 사용자가 들어있는 secret 설정
  nginx.ingress.kubernetes.io/auth-secret: basic-auth
  # 인증 요청시 나오는 메세지 설정
  nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - admin'
profile
낮에는 클라우드엔지니어, 밤에는 나홀로 개발자...

0개의 댓글