|
| 1 | +local externalSecrets = import 'external-secrets-libsonnet/0.19/main.libsonnet'; |
| 2 | +local k = import 'k.libsonnet'; |
| 3 | +local labsonnet = import 'labsonnet/main.libsonnet'; |
| 4 | +local externalSecret = externalSecrets.nogroup.v1.externalSecret; |
| 5 | + |
| 6 | +{ |
| 7 | + affine: |
| 8 | + labsonnet.new('affine', 'ghcr.io/dzervas/affine') |
| 9 | + + labsonnet.withCreateNamespace() |
| 10 | + + labsonnet.withType('StatefulSet') |
| 11 | + + labsonnet.withPort({ port: 3010 }) |
| 12 | + + labsonnet.withPV('/root/.affine/storage', { name: 'affine-storage', size: '10Gi' }) |
| 13 | + + labsonnet.withPV('/root/.affine/config', { name: 'affine-config', size: '1Gi' }) |
| 14 | + // + labsonnet.withEnv('AFFINE_INDEXER_ENABLED', 'false') |
| 15 | + + labsonnet.withEnv({ REDIS_SERVER_HOST: 'redis' }) |
| 16 | + + labsonnet.withInitContainer({ |
| 17 | + name: 'migrations', |
| 18 | + image: 'ghcr.io/toeverything/affine:stable', |
| 19 | + command: ['sh', '-c', 'node ./scripts/self-host-predeploy.js'], |
| 20 | + }) |
| 21 | + + labsonnet.withSecretEnv({ |
| 22 | + DATABASE_SERVER_URL: { name: 'affine-secrets-op', key: 'postgres_url' }, |
| 23 | + }) |
| 24 | + , |
| 25 | + |
| 26 | + redis: |
| 27 | + labsonnet.new('redis', 'redis') |
| 28 | + + labsonnet.withNamespace('affine') |
| 29 | + + labsonnet.withPort({ port: 6379 }), |
| 30 | + |
| 31 | + postgres: |
| 32 | + labsonnet.new('postgres', 'pgvector/pgvector:pg16') |
| 33 | + + labsonnet.withNamespace('affine') |
| 34 | + + labsonnet.withType('StatefulSet') |
| 35 | + + labsonnet.withPort({ port: 5432 }) |
| 36 | + + labsonnet.withPV('/var/lib/postgresql/data', { size: '2Gi' }) |
| 37 | + + labsonnet.withEnv({ |
| 38 | + POSTGRES_USER: 'affine', |
| 39 | + POSTGRES_DB: 'affine', |
| 40 | + POSTGRES_INITDB_ARGS: '--data-checksums', |
| 41 | + // + labsonnet.withEnv('POSTGRES_HOST_AUTH_METHOD', 'trust') |
| 42 | + }) |
| 43 | + + labsonnet.withSecretEnv({ |
| 44 | + POSTGRES_PASSWORD: { name: 'affine-secrets-op', key: 'password' }, |
| 45 | + }) |
| 46 | + , |
| 47 | + |
| 48 | + passwords: |
| 49 | + externalSecret.new('affine-secrets-op') |
| 50 | + + externalSecret.spec.secretStoreRef.withKind('ClusterSecretStore') |
| 51 | + + externalSecret.spec.secretStoreRef.withName('1password') |
| 52 | + + externalSecret.spec.withDataFrom([{ extract: { key: 'affine' } }]) |
| 53 | + + externalSecret.spec.target.template.withData({ |
| 54 | + password: '{{ .password }}', |
| 55 | + postgres_url: 'postgres://affine@{{ .password }}:5432/affine', |
| 56 | + }), |
| 57 | +} |
0 commit comments