kubernetes/practical

Kubernetes Vault Deployment: A Hands-on Guide with Minikube

blogger903 2024. 8. 20. 14:43
728x90

Kubernetes Vault Deployment: A Hands-on Guide with Minikube

"k8s 클러스터에 springboot application 배포 시리즈"의 시작 포스팅입니다

이번 포스트에서는 k8s에 vault를 배포하여 vault-ui로 접근하여 파드에서 사용할 환경변수를 생성하겠습니다

 

다루는 내용

  • k8s에 vault 배포
  • vault-ui로 secret 생성

 

k8s에 vault 배포

Create a Kubernetes namespace.

kubectl create namespace vault

View all resources in a namespace.

kubectl get all --namespace vault

To access the Vault Helm chart, add the Hashicorp Helm repository.

helm repo add hashicorp https://helm.releases.hashicorp.com

Check that you have access to the chart.

helm search repo hashicorp/vault

List available releases.

helm search repo hashicorp/vault --versions

Install version specific version

helm install vault hashicorp/vault --namespace vault --version 0.28.0

lens로 vault pod을 보시면 event에 다음과 같이 나옵니다
Readiness probe failed: Key Value --- ----- Seal Type shamir Initialized false Sealed true Total Shares 0 Threshold 0 Unseal Progress 0/0 Unseal Nonce n/a Version 1.16.1 Build Date 2024-04-03T12:35:53Z Storage Type file HA Enabled false

vault pod에 shell로 접근하여 초기화 해줍니다

kubectl exec -it value-0

root token과 unsealkey를 확보합니다

vault operator init -n 1 -t 1
vault operator unseal <unseal key>

이제 lens로 network > vault 포트포워드를 해줍니다

 

vault-ui로 secret 생성

token에 root token 입력합니다

 

secrets engines

 

 

Enable new engine

KV를 선택해줍니다

 

Path에 프로젝트 단위로 이름을 적어주시면 될것 같습니다

 

다시 side navigation에서 Secrets Engines를 선택하시면 생성된 Secrets engine를 확인할 수 있습니다

 

Create secret 선택해줍니다

 

Create Secret

secret engine내 path로 secret를 관리할 수 있고

secret data에 환경변수를 넣어줍니다

생성된 KV를 확인할수 있습니다

 

 

참고: