helm을 이용한 harbor 인증서 업데이트

김건호·2023년 1월 19일
0

목표

selfsigned로 인증된 harbor 파드에 사설 인증서 적용하기 / 공인 인증서도 가능

작업내용

인증서를 사용하여 tls secret 생성

kubectl create secret tls [secret name] -n harbor \
--cert=tls.crt \
--key=tls.key

bundle가 있는 경우 tls.crtbundle 파일을 사용합니다.

tls secret 조회 시, ca.crt가 없는 경우

harbor는 ca.crt를 참조하기 때문에 tls secret에 ca.crt가 반드시 있어야 합니다.

yaml 파일 생성

cat <<EOF > [file].yaml
apiVersion: v1
kind: Secret
metadata:
  name: [secret name]
  namespace: harbor
type: kubernetes.io/tls
data:
  ca.crt: $(cat tls.crt | base64 -w 0 )
  tls.crt: $(cat tls.crt | base64 -w 0 )
  tls.key: $(cat tls.key | base64 -w 0 )
EOF

EOF 안 쓰고 vi로 하면 $ 가 안먹습니다..
crt key 값 복사보다는 EOF 한 줄 씩 복사 붙여넣기 하는게 정신건강에 이롭습니다.🙃

tls secret 생성

kubectl apply -f [file].yaml

helm values 수정

  1. expose.tls.enabletrue로 설정합니다.
  2. expose.tls.secret.secretName 을 생성한 시크릿 이름으로 설정합니다.
  3. expose.tls.secret.notarySecretName 을 생성한 시크릿 이름으로 설정합니다.
  4. caSecretName 를 생성한 시크릿 이름으로 설정합니다.

helm upgrade

  1. helm chart 디렉토리로 이동합니다.
  2. helm upgrade 를 실행합니다.
helm upgrade -f values.yaml -n harbor harbor ./

작업확인

pod에 secret가 적용 되었는지 확인

kubectl describe pod -n harbor [pod name] | grep [secret name] 

ingress에 tls 적용 되었는지 확인

kubectl edit ingress -n harbor [ingress name]

을 실행하여 ingress 설정 값을 확인합니다.
tls.secretName에 생성한 secret 이름이 적용되었는지 확인합니다.

profile
Ken, 🔽🔽 거노밥 유튜브(house icon) 🔽🔽

0개의 댓글