common-secret
데이터 형태는 아래와 같은 구조
"app": {
"DB": {
"HOST": "xxx.xxxx.xxxx",
"PASSWORD" : "****"
},
"KAFKA_BROKERS": "kkk.xxxx.xxxxx"
},
...
$ helm repo add external-secrets https://charts.external-secrets.io
$ helm install external-secrets \
external-secrets/external-secrets \
-n external-secrets \
--create-namespace \
--set installCRDs=true \
--set webhook.port=9443
dev-secretstore.yaml
apiVersion: external-secrets.io/v1beta1
kind: SecretStore
metadata:
name: dev-secretstore
namespace: kube-system
spec:
provider:
aws:
service: SecretsManager
region: ap-northeast-2
auth:
jwt:
serviceAccountRef:
name: eks-sa-role # Secret Manager 접근 권한을 들고 있는 Service Account Role 이름 명시
dev-externalsecret.yaml
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: dev-externalsecret
namespace: kube-system
spec:
refreshInterval: 1m
secretStoreRef:
name: dev-secretstore # 위에서 생성한 Secret Store 이름 명시
kind: SecretStore
target:
name: app-secret # 클러스터 내 생성할 secret 이름
creationPolicy: Owner
data:
- secretKey: DB_HOST
remoteRef:
key: "common-secret" # 값 가져올 AWS Secret Manager Name 명시
property: app.DB.HOST # 3중첩 # xxx.xxxx.xxxx
- secretKey: KAFKA_BROKERS
remoteRef:
key: "common-secret"
property: app.KAFKA_BROKERS # 2중첩 # kkk.xxxx.xxxxx
app-admin-deployment.yaml
파일
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-deployment
namespace: kube-system
spec:
replicas: 1
selector:
matchLabels:
app: app-deployment
template:
metadata:
labels:
app: app-deployment
spec:
containers:
- name: app-deployment
image: [AccountID].dkr.ecr.ap-northeast-2.amazonaws.com/develop/[ImageName]:latest
# envFrom:
# - configMapRef:
# name: env-configmap
## 여기부터
env:
- name: DB_HOST # 컨테이너 내에 등록될 환경변수의 이름
valueFrom:
secretKeyRef:
name: app-secret # 참조할 클러스터 내 Secret Name
key: DB_HOST # Secret 내에 명시된 참조할 키 Name
optional: false # 환경변수가 제대로 주입이 안될 경우 컨테이너 생성이 안되게 함
- name: KAFKA_BROKERS
valueFrom:
secretKeyRef:
name: app-secret
key: KAFKA_BROKERS
optional: false
########################################################################
ports:
- containerPort: 3000
https://external-secrets.io/latest/provider/aws-secrets-manager/