stand: deploy persistent SpiceDB using Terraform-managed Vault credentials

This commit is contained in:
ivan 2026-11-23 15:28:31 +05:00
parent c3bc4a3c1a
commit 98dbc31121
3 changed files with 152 additions and 0 deletions

View File

@ -3,3 +3,4 @@ kind: Kustomization
resources: resources:
- ../../../infrastructure/zitadel/contour-template - ../../../infrastructure/zitadel/contour-template
- ../../../infrastructure/camunda/contour-template - ../../../infrastructure/camunda/contour-template
- ../../../infrastructure/spicedb/stand

View File

@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- spicedb.yaml

View File

@ -0,0 +1,147 @@
apiVersion: v1
kind: Namespace
metadata:
name: spicedb
labels:
istio-injection: disabled
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: spicedb-vault
namespace: spicedb
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: spicedb
namespace: spicedb
spec:
replicas: 1
selector:
matchLabels:
app: spicedb
template:
metadata:
labels:
app: spicedb
annotations:
vault.hashicorp.com/agent-inject: 'true'
vault.hashicorp.com/agent-init-first: 'true'
vault.hashicorp.com/agent-pre-populate-only: 'true'
vault.hashicorp.com/agent-requests-cpu: 25m
vault.hashicorp.com/auth-path: auth/kubernetes
vault.hashicorp.com/role: spicedb
vault.hashicorp.com/agent-inject-secret-spicedb-db: secrets/data/apps/spicedb/postgres
vault.hashicorp.com/agent-inject-template-spicedb-db: '{{- with secret "secrets/data/apps/spicedb/postgres"
-}}
SPICEDB_DATASTORE_CONN_URI=''postgres://{{ index .Data.data "username" }}:{{
index .Data.data "password" }}@{{ index .Data.data "host" }}:{{ index .Data.data
"port" }}/{{ index .Data.data "database" }}?sslmode=disable''
{{- end -}}'
vault.hashicorp.com/agent-inject-secret-spicedb-auth: secrets/data/apps/spicedb/auth
vault.hashicorp.com/agent-inject-template-spicedb-auth: '{{- with secret "secrets/data/apps/spicedb/auth"
-}}
SPICEDB_GRPC_PRESHARED_KEY=''{{ index .Data.data "preshared_key" }}''
{{- end -}}'
spec:
serviceAccountName: spicedb-vault
initContainers:
- name: vault-runtime
image: hashicorp/vault:1.21.2
command:
- /bin/sh
- -ec
args:
- cp /bin/busybox /lib/ld-musl-x86_64.so.1 /vault-runtime/
resources:
requests:
cpu: 25m
memory: 16Mi
volumeMounts:
- name: vault-runtime
mountPath: /vault-runtime
- name: spicedb-migrate
image: authzed/spicedb:v1.54.0
command: &id001
- /vault-runtime/ld-musl-x86_64.so.1
- /vault-runtime/busybox
- sh
- -ec
args:
- 'set -a
. /vault/secrets/spicedb-db
. /vault/secrets/spicedb-auth
set +a
exec spicedb datastore migrate head --datastore-engine postgres
'
volumeMounts: &id003
- name: vault-runtime
mountPath: /vault-runtime
readOnly: true
resources: &id002
requests:
cpu: 100m
memory: 256Mi
containers:
- name: spicedb
image: authzed/spicedb:v1.54.0
command: *id001
args:
- 'set -a
. /vault/secrets/spicedb-db
. /vault/secrets/spicedb-auth
set +a
exec spicedb serve --datastore-engine postgres --http-enabled --datastore-conn-pool-read-max-open
10 --datastore-conn-pool-read-min-open 1 --datastore-conn-pool-write-max-open
5 --datastore-conn-pool-write-min-open 1
'
ports:
- name: grpc
containerPort: 50051
- name: http
containerPort: 8443
resources: *id002
volumeMounts: *id003
startupProbe:
grpc:
port: 50051
periodSeconds: 5
failureThreshold: 60
readinessProbe:
grpc:
port: 50051
periodSeconds: 5
volumes:
- name: vault-runtime
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: spicedb
namespace: spicedb
spec:
selector:
app: spicedb
ports:
- name: grpc
port: 50051
targetPort: grpc
- name: http
port: 8443
targetPort: http