REFACTOR(k8s): move secrets to Vault

- Migrate secrets to HashiCorp Vault
- Use ExternalSecrets operator
This commit is contained in:
2025-12-23 22:42:05 +09:00
parent 346b0c79ef
commit e54811c09b
7 changed files with 82 additions and 11 deletions

View File

@@ -0,0 +1,37 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: mas
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
source:
repoURL: https://gitea0213.kro.kr/bluemayne/mas.git
targetRevision: main
path: deploy/argocd
destination:
server: https://kubernetes.default.svc
namespace: argocd
syncPolicy:
automated:
prune: true
selfHeal: true
allowEmpty: false
syncOptions:
- CreateNamespace=true
retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m
revisionHistoryLimit: 10

View File

@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# App of Apps Application
- application.yaml
# MAS Application
- mas.yaml

View File

@@ -3,11 +3,13 @@ kind: Application
metadata: metadata:
name: mas name: mas
namespace: argocd namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec: spec:
project: default project: default
source: source:
repoURL: https://gitea0213.kro.kr/bluemayne/mas.git repoURL: https://gitea0213.kro.kr/bluemayne/mas.git
targetRevision: HEAD targetRevision: main
path: deploy/k8s path: deploy/k8s
destination: destination:
server: https://kubernetes.default.svc server: https://kubernetes.default.svc
@@ -16,6 +18,14 @@ spec:
automated: automated:
prune: true prune: true
selfHeal: true selfHeal: true
allowEmpty: false
syncOptions: syncOptions:
- CreateNamespace=true - CreateNamespace=true
retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m
revisionHistoryLimit: 10

View File

@@ -45,10 +45,12 @@ spec:
- name: GROQ_API_BASE - name: GROQ_API_BASE
value: "https://api.groq.com/openai/v1" value: "https://api.groq.com/openai/v1"
- name: DATABASE_URL - name: DATABASE_URL
value: "postgresql+asyncpg://mas_user:$(POSTGRES_PASSWORD)@postgresql.postgresql.svc.cluster.local:5432/mas"
- name: POSTGRES_PASSWORD
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
name: mas-postgres name: mas-postgres
key: database-url key: password
- name: REDIS_URL - name: REDIS_URL
value: "redis://redis:6379/0" value: "redis://redis:6379/0"
resources: resources:

View File

@@ -7,6 +7,7 @@ resources:
- namespace.yaml - namespace.yaml
- ../vault/mas-api-keys.yaml - ../vault/mas-api-keys.yaml
- ../vault/mas-postgres.yaml - ../vault/mas-postgres.yaml
- ../vault/postgresql-root-password.yaml
- deployment.yaml - deployment.yaml
- service.yaml - service.yaml
- ingress.yaml - ingress.yaml

View File

@@ -12,14 +12,6 @@ spec:
name: mas-postgres name: mas-postgres
creationPolicy: Owner creationPolicy: Owner
data: data:
- secretKey: database-url
remoteRef:
key: mas/postgres
property: DATABASE_URL
- secretKey: username
remoteRef:
key: mas/postgres
property: USERNAME
- secretKey: password - secretKey: password
remoteRef: remoteRef:
key: mas/postgres key: mas/postgres

View File

@@ -0,0 +1,19 @@
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: postgresql-root-password
namespace: mas
spec:
refreshInterval: 1h
secretStoreRef:
kind: ClusterSecretStore
name: vault-backend
target:
name: postgresql-root-password
creationPolicy: Owner
data:
- secretKey: password
remoteRef:
key: databases/postgresql
property: PASSWORD