|
@@ -5,17 +5,24 @@ import * as pulumi from '@pulumi/pulumi'
|
|
|
import { configMapFromFile } from './configMap'
|
|
|
import * as k8s from '@pulumi/kubernetes'
|
|
|
import * as s3Helpers from './s3Helpers'
|
|
|
-import { CaddyServiceDeployment } from 'pulumi-common'
|
|
|
+import { CaddyServiceDeployment, PostgresServiceDeployment } from 'pulumi-common'
|
|
|
|
|
|
require('dotenv').config()
|
|
|
|
|
|
const config = new pulumi.Config()
|
|
|
const awsConfig = new pulumi.Config('aws')
|
|
|
const isMinikube = config.getBoolean('isMinikube')
|
|
|
+const externalIndexerUrl = config.get('externalIndexerUrl')
|
|
|
+const skipProcessor = config.getBoolean('skipProcessor')
|
|
|
export let kubeconfig: pulumi.Output<any>
|
|
|
export let joystreamAppsImage: pulumi.Output<string>
|
|
|
let provider: k8s.Provider
|
|
|
|
|
|
+if (skipProcessor && externalIndexerUrl) {
|
|
|
+ pulumi.log.error('Need to deploy atleast one component, Indexer or Processor')
|
|
|
+ throw new Error(`Please check the config settings for skipProcessor and externalIndexerUrl`)
|
|
|
+}
|
|
|
+
|
|
|
if (isMinikube) {
|
|
|
provider = new k8s.Provider('local', {})
|
|
|
|
|
@@ -28,6 +35,8 @@ if (isMinikube) {
|
|
|
imageName: 'joystream/apps:latest',
|
|
|
skipPush: true,
|
|
|
}).baseImageName
|
|
|
+
|
|
|
+ // Uncomment the below line if you want to use a pre built image
|
|
|
// joystreamAppsImage = pulumi.interpolate`joystream/apps`
|
|
|
} else {
|
|
|
// Create a VPC for our cluster.
|
|
@@ -56,6 +65,8 @@ if (isMinikube) {
|
|
|
dockerfile: '../../../apps.Dockerfile',
|
|
|
context: '../../../',
|
|
|
})
|
|
|
+
|
|
|
+ // Uncomment the below line if you want to use a pre built image
|
|
|
// joystreamAppsImage = pulumi.interpolate`joystream/apps`
|
|
|
}
|
|
|
|
|
@@ -69,341 +80,359 @@ const ns = new k8s.core.v1.Namespace(name, {}, resourceOptions)
|
|
|
// Export the Namespace name
|
|
|
export const namespaceName = ns.metadata.name
|
|
|
|
|
|
-const appLabels = { appClass: name }
|
|
|
-
|
|
|
-// Create a Deployment
|
|
|
-const databaseLabels = { app: 'postgres-db' }
|
|
|
+let appLabels = { appClass: name }
|
|
|
|
|
|
-const pvc = new k8s.core.v1.PersistentVolumeClaim(
|
|
|
- `db-pvc`,
|
|
|
+const defsConfig = new configMapFromFile(
|
|
|
+ 'defs-config',
|
|
|
{
|
|
|
- metadata: {
|
|
|
- labels: databaseLabels,
|
|
|
- namespace: namespaceName,
|
|
|
- name: `db-pvc`,
|
|
|
- },
|
|
|
- spec: {
|
|
|
- accessModes: ['ReadWriteOnce'],
|
|
|
- resources: {
|
|
|
- requests: {
|
|
|
- storage: `10Gi`,
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
+ filePath: '../../../types/augment/all/defs.json',
|
|
|
+ namespaceName: namespaceName,
|
|
|
},
|
|
|
resourceOptions
|
|
|
-)
|
|
|
+).configName
|
|
|
|
|
|
-const databaseDeployment = new k8s.apps.v1.Deployment(
|
|
|
- 'postgres-db',
|
|
|
- {
|
|
|
- metadata: {
|
|
|
- namespace: namespaceName,
|
|
|
- labels: databaseLabels,
|
|
|
+if (!externalIndexerUrl) {
|
|
|
+ const indexerDbName = 'indexer-db'
|
|
|
+ const indexerDb = new PostgresServiceDeployment(
|
|
|
+ indexerDbName,
|
|
|
+ {
|
|
|
+ namespaceName: namespaceName,
|
|
|
+ env: [
|
|
|
+ { name: 'POSTGRES_USER', value: process.env.DB_USER! },
|
|
|
+ { name: 'POSTGRES_PASSWORD', value: process.env.DB_PASS! },
|
|
|
+ { name: 'POSTGRES_DB', value: process.env.INDEXER_DB_NAME! },
|
|
|
+ ],
|
|
|
+ storage: 10,
|
|
|
},
|
|
|
- spec: {
|
|
|
- selector: { matchLabels: databaseLabels },
|
|
|
- template: {
|
|
|
- metadata: { labels: databaseLabels },
|
|
|
- spec: {
|
|
|
- containers: [
|
|
|
- {
|
|
|
- name: 'postgres-db',
|
|
|
- image: 'postgres:12',
|
|
|
- env: [
|
|
|
- { name: 'POSTGRES_USER', value: process.env.DB_USER! },
|
|
|
- { name: 'POSTGRES_PASSWORD', value: process.env.DB_PASS! },
|
|
|
- { name: 'POSTGRES_DB', value: process.env.INDEXER_DB_NAME! },
|
|
|
- ],
|
|
|
- ports: [{ containerPort: 5432 }],
|
|
|
- volumeMounts: [
|
|
|
- {
|
|
|
- name: 'postgres-data',
|
|
|
- mountPath: '/var/lib/postgresql/data',
|
|
|
- subPath: 'postgres',
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
- volumes: [
|
|
|
- {
|
|
|
- name: 'postgres-data',
|
|
|
- persistentVolumeClaim: {
|
|
|
- claimName: `db-pvc`,
|
|
|
+ resourceOptions
|
|
|
+ )
|
|
|
+
|
|
|
+ const indexerMigrationJob = new k8s.batch.v1.Job(
|
|
|
+ 'db-migration',
|
|
|
+ {
|
|
|
+ metadata: {
|
|
|
+ namespace: namespaceName,
|
|
|
+ },
|
|
|
+ spec: {
|
|
|
+ backoffLimit: 0,
|
|
|
+ template: {
|
|
|
+ spec: {
|
|
|
+ containers: [
|
|
|
+ {
|
|
|
+ name: 'db-migration',
|
|
|
+ image: joystreamAppsImage,
|
|
|
+ imagePullPolicy: 'IfNotPresent',
|
|
|
+ resources: { requests: { cpu: '100m', memory: '100Mi' } },
|
|
|
+ env: [
|
|
|
+ {
|
|
|
+ name: 'WARTHOG_DB_HOST',
|
|
|
+ value: indexerDbName,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'DB_HOST',
|
|
|
+ value: indexerDbName,
|
|
|
+ },
|
|
|
+ { name: 'WARTHOG_DB_DATABASE', value: process.env.INDEXER_DB_NAME! },
|
|
|
+ { name: 'DB_NAME', value: process.env.INDEXER_DB_NAME! },
|
|
|
+ { name: 'DB_PASS', value: process.env.DB_PASS! },
|
|
|
+ ],
|
|
|
+ command: ['/bin/sh', '-c'],
|
|
|
+ args: ['yarn workspace query-node-root db:prepare; yarn workspace query-node-root db:migrate'],
|
|
|
},
|
|
|
- },
|
|
|
- ],
|
|
|
+ ],
|
|
|
+ restartPolicy: 'Never',
|
|
|
+ },
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- },
|
|
|
- resourceOptions
|
|
|
-)
|
|
|
+ { ...resourceOptions, dependsOn: indexerDb.service }
|
|
|
+ )
|
|
|
|
|
|
-const databaseService = new k8s.core.v1.Service(
|
|
|
- 'postgres-db',
|
|
|
- {
|
|
|
- metadata: {
|
|
|
- namespace: namespaceName,
|
|
|
- labels: databaseDeployment.metadata.labels,
|
|
|
- name: 'postgres-db',
|
|
|
- },
|
|
|
- spec: {
|
|
|
- ports: [{ port: 5432 }],
|
|
|
- selector: databaseDeployment.spec.template.metadata.labels,
|
|
|
- },
|
|
|
- },
|
|
|
- resourceOptions
|
|
|
-)
|
|
|
+ appLabels = { appClass: 'indexer' }
|
|
|
|
|
|
-const migrationJob = new k8s.batch.v1.Job(
|
|
|
- 'db-migration',
|
|
|
- {
|
|
|
- metadata: {
|
|
|
- namespace: namespaceName,
|
|
|
- },
|
|
|
- spec: {
|
|
|
- backoffLimit: 0,
|
|
|
- template: {
|
|
|
- spec: {
|
|
|
- containers: [
|
|
|
- {
|
|
|
- name: 'db-migration',
|
|
|
- image: joystreamAppsImage,
|
|
|
- imagePullPolicy: 'IfNotPresent',
|
|
|
- resources: { requests: { cpu: '100m', memory: '100Mi' } },
|
|
|
- env: [
|
|
|
- {
|
|
|
- name: 'WARTHOG_DB_HOST',
|
|
|
- value: 'postgres-db',
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'DB_HOST',
|
|
|
- value: 'postgres-db',
|
|
|
+ const indexerDeployment = new k8s.apps.v1.Deployment(
|
|
|
+ 'indexer',
|
|
|
+ {
|
|
|
+ metadata: {
|
|
|
+ namespace: namespaceName,
|
|
|
+ labels: appLabels,
|
|
|
+ },
|
|
|
+ spec: {
|
|
|
+ replicas: 1,
|
|
|
+ selector: { matchLabels: appLabels },
|
|
|
+ template: {
|
|
|
+ metadata: {
|
|
|
+ labels: appLabels,
|
|
|
+ },
|
|
|
+ spec: {
|
|
|
+ containers: [
|
|
|
+ {
|
|
|
+ name: 'redis',
|
|
|
+ image: 'redis:6.0-alpine',
|
|
|
+ ports: [{ containerPort: 6379 }],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'indexer',
|
|
|
+ image: 'joystream/hydra-indexer:3.0.0',
|
|
|
+ env: [
|
|
|
+ { name: 'DB_HOST', value: indexerDbName },
|
|
|
+ { name: 'DB_NAME', value: process.env.INDEXER_DB_NAME! },
|
|
|
+ { name: 'DB_PASS', value: process.env.DB_PASS! },
|
|
|
+ { name: 'DB_USER', value: process.env.DB_USER! },
|
|
|
+ { name: 'DB_PORT', value: process.env.DB_PORT! },
|
|
|
+ { name: 'INDEXER_WORKERS', value: '5' },
|
|
|
+ { name: 'REDIS_URI', value: 'redis://localhost:6379/0' },
|
|
|
+ { name: 'DEBUG', value: 'index-builder:*' },
|
|
|
+ { name: 'WS_PROVIDER_ENDPOINT_URI', value: process.env.WS_PROVIDER_ENDPOINT_URI! },
|
|
|
+ { name: 'TYPES_JSON', value: 'types.json' },
|
|
|
+ { name: 'PGUSER', value: process.env.DB_USER! },
|
|
|
+ { name: 'BLOCK_HEIGHT', value: process.env.BLOCK_HEIGHT! },
|
|
|
+ ],
|
|
|
+ volumeMounts: [
|
|
|
+ {
|
|
|
+ mountPath: '/home/hydra/packages/hydra-indexer/types.json',
|
|
|
+ name: 'indexer-volume',
|
|
|
+ subPath: 'fileData',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ command: ['/bin/sh', '-c'],
|
|
|
+ args: ['yarn db:bootstrap && yarn start:prod'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'hydra-indexer-gateway',
|
|
|
+ image: 'joystream/hydra-indexer-gateway:3.0.0',
|
|
|
+ env: [
|
|
|
+ { name: 'WARTHOG_STARTER_DB_DATABASE', value: process.env.INDEXER_DB_NAME! },
|
|
|
+ { name: 'WARTHOG_STARTER_DB_HOST', value: indexerDbName },
|
|
|
+ { name: 'WARTHOG_STARTER_DB_PASSWORD', value: process.env.DB_PASS! },
|
|
|
+ { name: 'WARTHOG_STARTER_DB_PORT', value: process.env.DB_PORT! },
|
|
|
+ { name: 'WARTHOG_STARTER_DB_USERNAME', value: process.env.DB_USER! },
|
|
|
+ { name: 'WARTHOG_STARTER_REDIS_URI', value: 'redis://localhost:6379/0' },
|
|
|
+ { name: 'WARTHOG_APP_PORT', value: process.env.WARTHOG_APP_PORT! },
|
|
|
+ { name: 'PORT', value: process.env.WARTHOG_APP_PORT! },
|
|
|
+ { name: 'DEBUG', value: '*' },
|
|
|
+ ],
|
|
|
+ ports: [{ name: 'hydra-port', containerPort: Number(process.env.WARTHOG_APP_PORT!) }],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ volumes: [
|
|
|
+ {
|
|
|
+ name: 'indexer-volume',
|
|
|
+ configMap: {
|
|
|
+ name: defsConfig,
|
|
|
},
|
|
|
- { name: 'DB_NAME', value: process.env.DB_NAME! },
|
|
|
- { name: 'DB_PASS', value: process.env.DB_PASS! },
|
|
|
- ],
|
|
|
- command: ['/bin/sh', '-c'],
|
|
|
- args: ['yarn workspace query-node-root db:prepare; yarn workspace query-node-root db:migrate'],
|
|
|
- },
|
|
|
- ],
|
|
|
- restartPolicy: 'Never',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- },
|
|
|
- { ...resourceOptions, dependsOn: databaseService }
|
|
|
-)
|
|
|
-
|
|
|
-const dataPath = '/joystream/query-node/mappings/bootstrap/data'
|
|
|
-
|
|
|
-const defsConfig = new configMapFromFile(
|
|
|
- 'defs-config',
|
|
|
- {
|
|
|
- filePath: '../../../types/augment/all/defs.json',
|
|
|
- namespaceName: namespaceName,
|
|
|
- },
|
|
|
- resourceOptions
|
|
|
-).configName
|
|
|
+ { ...resourceOptions, dependsOn: indexerMigrationJob }
|
|
|
+ )
|
|
|
|
|
|
-const indexerContainer = []
|
|
|
-
|
|
|
-const existingIndexer = config.get('indexerURL')
|
|
|
-
|
|
|
-if (!existingIndexer) {
|
|
|
- indexerContainer.push({
|
|
|
- name: 'indexer',
|
|
|
- image: 'joystream/hydra-indexer:3.0.0',
|
|
|
- env: [
|
|
|
- { name: 'DB_HOST', value: 'postgres-db' },
|
|
|
- { name: 'DB_NAME', value: process.env.INDEXER_DB_NAME! },
|
|
|
- { name: 'DB_PASS', value: process.env.DB_PASS! },
|
|
|
- { name: 'DB_USER', value: process.env.DB_USER! },
|
|
|
- { name: 'DB_PORT', value: process.env.DB_PORT! },
|
|
|
- { name: 'INDEXER_WORKERS', value: '5' },
|
|
|
- { name: 'REDIS_URI', value: 'redis://localhost:6379/0' },
|
|
|
- { name: 'DEBUG', value: 'index-builder:*' },
|
|
|
- { name: 'WS_PROVIDER_ENDPOINT_URI', value: process.env.WS_PROVIDER_ENDPOINT_URI! },
|
|
|
- { name: 'TYPES_JSON', value: 'types.json' },
|
|
|
- { name: 'PGUSER', value: process.env.DB_USER! },
|
|
|
- { name: 'BLOCK_HEIGHT', value: process.env.BLOCK_HEIGHT! },
|
|
|
- ],
|
|
|
- volumeMounts: [
|
|
|
- {
|
|
|
- mountPath: '/home/hydra/packages/hydra-indexer/types.json',
|
|
|
- name: 'indexer-volume',
|
|
|
- subPath: 'fileData',
|
|
|
+ // Create a Service for the Indexer
|
|
|
+ const indexerService = new k8s.core.v1.Service(
|
|
|
+ 'indexer',
|
|
|
+ {
|
|
|
+ metadata: {
|
|
|
+ labels: appLabels,
|
|
|
+ namespace: namespaceName,
|
|
|
+ name: 'indexer',
|
|
|
},
|
|
|
- ],
|
|
|
- command: ['/bin/sh', '-c'],
|
|
|
- args: ['yarn db:bootstrap && yarn start:prod'],
|
|
|
- })
|
|
|
+ spec: {
|
|
|
+ ports: [{ name: 'port-1', port: 4000, targetPort: 'hydra-port' }],
|
|
|
+ selector: appLabels,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ resourceOptions
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
-const deployment = new k8s.apps.v1.Deployment(
|
|
|
- name,
|
|
|
- {
|
|
|
- metadata: {
|
|
|
- namespace: namespaceName,
|
|
|
- labels: appLabels,
|
|
|
+if (!skipProcessor) {
|
|
|
+ const processorDbName = 'processor-db'
|
|
|
+ const processorDb = new PostgresServiceDeployment(
|
|
|
+ processorDbName,
|
|
|
+ {
|
|
|
+ namespaceName: namespaceName,
|
|
|
+ env: [
|
|
|
+ { name: 'POSTGRES_USER', value: process.env.DB_USER! },
|
|
|
+ { name: 'POSTGRES_PASSWORD', value: process.env.DB_PASS! },
|
|
|
+ { name: 'POSTGRES_DB', value: process.env.DB_NAME! },
|
|
|
+ ],
|
|
|
+ storage: 10,
|
|
|
},
|
|
|
- spec: {
|
|
|
- replicas: 1,
|
|
|
- selector: { matchLabels: appLabels },
|
|
|
- template: {
|
|
|
- metadata: {
|
|
|
- labels: appLabels,
|
|
|
- },
|
|
|
- spec: {
|
|
|
- containers: [
|
|
|
- {
|
|
|
- name: 'redis',
|
|
|
- image: 'redis:6.0-alpine',
|
|
|
- ports: [{ containerPort: 6379 }],
|
|
|
- },
|
|
|
- ...indexerContainer,
|
|
|
- {
|
|
|
- name: 'hydra-indexer-gateway',
|
|
|
- image: 'joystream/hydra-indexer-gateway:3.0.0',
|
|
|
- env: [
|
|
|
- { name: 'WARTHOG_STARTER_DB_DATABASE', value: process.env.INDEXER_DB_NAME! },
|
|
|
- { name: 'WARTHOG_STARTER_DB_HOST', value: 'postgres-db' },
|
|
|
- { name: 'WARTHOG_STARTER_DB_PASSWORD', value: process.env.DB_PASS! },
|
|
|
- { name: 'WARTHOG_STARTER_DB_PORT', value: process.env.DB_PORT! },
|
|
|
- { name: 'WARTHOG_STARTER_DB_USERNAME', value: process.env.DB_USER! },
|
|
|
- { name: 'WARTHOG_STARTER_REDIS_URI', value: 'redis://localhost:6379/0' },
|
|
|
- { name: 'WARTHOG_APP_PORT', value: process.env.WARTHOG_APP_PORT! },
|
|
|
- { name: 'PORT', value: process.env.WARTHOG_APP_PORT! },
|
|
|
- { name: 'DEBUG', value: '*' },
|
|
|
- ],
|
|
|
- ports: [{ name: 'hydra-port', containerPort: Number(process.env.WARTHOG_APP_PORT!) }],
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'graphql-server',
|
|
|
- image: joystreamAppsImage,
|
|
|
- imagePullPolicy: 'IfNotPresent',
|
|
|
- env: [
|
|
|
- { name: 'DB_HOST', value: 'postgres-db' },
|
|
|
- { name: 'DB_PASS', value: process.env.DB_PASS! },
|
|
|
- { name: 'DB_USER', value: process.env.DB_USER! },
|
|
|
- { name: 'DB_PORT', value: process.env.DB_PORT! },
|
|
|
- { name: 'DB_NAME', value: process.env.DB_NAME! },
|
|
|
- { name: 'GRAPHQL_SERVER_HOST', value: process.env.GRAPHQL_SERVER_HOST! },
|
|
|
- { name: 'GRAPHQL_SERVER_PORT', value: process.env.GRAPHQL_SERVER_PORT! },
|
|
|
- { name: 'WS_PROVIDER_ENDPOINT_URI', value: process.env.WS_PROVIDER_ENDPOINT_URI! },
|
|
|
- ],
|
|
|
- ports: [{ name: 'graph-ql-port', containerPort: Number(process.env.GRAPHQL_SERVER_PORT!) }],
|
|
|
- args: ['workspace', 'query-node-root', 'query-node:start:prod'],
|
|
|
- },
|
|
|
- ],
|
|
|
- volumes: [
|
|
|
- {
|
|
|
- name: 'indexer-volume',
|
|
|
- configMap: {
|
|
|
- name: defsConfig,
|
|
|
+ resourceOptions
|
|
|
+ )
|
|
|
+
|
|
|
+ const processorMigrationJob = new k8s.batch.v1.Job(
|
|
|
+ 'processor-db-migration',
|
|
|
+ {
|
|
|
+ metadata: {
|
|
|
+ namespace: namespaceName,
|
|
|
+ },
|
|
|
+ spec: {
|
|
|
+ backoffLimit: 0,
|
|
|
+ template: {
|
|
|
+ spec: {
|
|
|
+ containers: [
|
|
|
+ {
|
|
|
+ name: 'db-migration',
|
|
|
+ image: joystreamAppsImage,
|
|
|
+ imagePullPolicy: 'IfNotPresent',
|
|
|
+ resources: { requests: { cpu: '100m', memory: '100Mi' } },
|
|
|
+ env: [
|
|
|
+ {
|
|
|
+ name: 'WARTHOG_DB_HOST',
|
|
|
+ value: processorDbName,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'DB_HOST',
|
|
|
+ value: processorDbName,
|
|
|
+ },
|
|
|
+ { name: 'WARTHOG_DB_DATABASE', value: process.env.DB_NAME! },
|
|
|
+ { name: 'DB_NAME', value: process.env.DB_NAME! },
|
|
|
+ { name: 'DB_PASS', value: process.env.DB_PASS! },
|
|
|
+ ],
|
|
|
+ command: ['/bin/sh', '-c'],
|
|
|
+ args: ['yarn workspace query-node-root db:prepare; yarn workspace query-node-root db:migrate'],
|
|
|
},
|
|
|
- },
|
|
|
- ],
|
|
|
+ ],
|
|
|
+ restartPolicy: 'Never',
|
|
|
+ },
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- },
|
|
|
- { ...resourceOptions, dependsOn: migrationJob }
|
|
|
-)
|
|
|
+ { ...resourceOptions, dependsOn: processorDb.service }
|
|
|
+ )
|
|
|
|
|
|
-// Export the Deployment name
|
|
|
-export const deploymentName = deployment.metadata.name
|
|
|
+ appLabels = { appClass: 'graphql-server' }
|
|
|
|
|
|
-// Create a LoadBalancer Service for the NGINX Deployment
|
|
|
-const service = new k8s.core.v1.Service(
|
|
|
- name,
|
|
|
- {
|
|
|
- metadata: {
|
|
|
- labels: appLabels,
|
|
|
- namespace: namespaceName,
|
|
|
- name: 'query-node',
|
|
|
- },
|
|
|
- spec: {
|
|
|
- ports: [
|
|
|
- { name: 'port-1', port: 8081, targetPort: 'graph-ql-port' },
|
|
|
- { name: 'port-2', port: 4000, targetPort: 'hydra-port' },
|
|
|
- ],
|
|
|
- selector: appLabels,
|
|
|
+ const graphqlDeployment = new k8s.apps.v1.Deployment(
|
|
|
+ 'graphql-server',
|
|
|
+ {
|
|
|
+ metadata: {
|
|
|
+ namespace: namespaceName,
|
|
|
+ labels: appLabels,
|
|
|
+ },
|
|
|
+ spec: {
|
|
|
+ replicas: 1,
|
|
|
+ selector: { matchLabels: appLabels },
|
|
|
+ template: {
|
|
|
+ metadata: {
|
|
|
+ labels: appLabels,
|
|
|
+ },
|
|
|
+ spec: {
|
|
|
+ containers: [
|
|
|
+ {
|
|
|
+ name: 'graphql-server',
|
|
|
+ image: joystreamAppsImage,
|
|
|
+ imagePullPolicy: 'IfNotPresent',
|
|
|
+ env: [
|
|
|
+ { name: 'DB_HOST', value: processorDbName },
|
|
|
+ { name: 'DB_PASS', value: process.env.DB_PASS! },
|
|
|
+ { name: 'DB_USER', value: process.env.DB_USER! },
|
|
|
+ { name: 'DB_PORT', value: process.env.DB_PORT! },
|
|
|
+ { name: 'DB_NAME', value: process.env.DB_NAME! },
|
|
|
+ { name: 'GRAPHQL_SERVER_HOST', value: process.env.GRAPHQL_SERVER_HOST! },
|
|
|
+ { name: 'GRAPHQL_SERVER_PORT', value: process.env.GRAPHQL_SERVER_PORT! },
|
|
|
+ { name: 'WS_PROVIDER_ENDPOINT_URI', value: process.env.WS_PROVIDER_ENDPOINT_URI! },
|
|
|
+ ],
|
|
|
+ ports: [{ name: 'graph-ql-port', containerPort: Number(process.env.GRAPHQL_SERVER_PORT!) }],
|
|
|
+ args: ['workspace', 'query-node-root', 'query-node:start:prod'],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
},
|
|
|
- },
|
|
|
- resourceOptions
|
|
|
-)
|
|
|
+ { ...resourceOptions, dependsOn: processorMigrationJob }
|
|
|
+ )
|
|
|
|
|
|
-// Export the Service name
|
|
|
-export const serviceName = service.metadata.name
|
|
|
+ // Create a Service for the GraphQL Server
|
|
|
+ const graphqlService = new k8s.core.v1.Service(
|
|
|
+ 'graphql-server',
|
|
|
+ {
|
|
|
+ metadata: {
|
|
|
+ labels: appLabels,
|
|
|
+ namespace: namespaceName,
|
|
|
+ name: 'graphql-server',
|
|
|
+ },
|
|
|
+ spec: {
|
|
|
+ ports: [{ name: 'port-1', port: 8081, targetPort: 'graph-ql-port' }],
|
|
|
+ selector: appLabels,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ resourceOptions
|
|
|
+ )
|
|
|
|
|
|
-const indexerURL = config.get('indexerURL') || `http://query-node:4000/graphql`
|
|
|
+ const indexerURL = externalIndexerUrl || `http://indexer:4000/graphql`
|
|
|
+ appLabels = { appClass: 'processor' }
|
|
|
|
|
|
-const processorDeployment = new k8s.apps.v1.Deployment(
|
|
|
- `processor`,
|
|
|
- {
|
|
|
- metadata: {
|
|
|
- namespace: namespaceName,
|
|
|
- labels: appLabels,
|
|
|
- },
|
|
|
- spec: {
|
|
|
- replicas: 1,
|
|
|
- selector: { matchLabels: appLabels },
|
|
|
- template: {
|
|
|
- metadata: {
|
|
|
- labels: appLabels,
|
|
|
- },
|
|
|
- spec: {
|
|
|
- containers: [
|
|
|
- {
|
|
|
- name: 'processor',
|
|
|
- image: joystreamAppsImage,
|
|
|
- imagePullPolicy: 'IfNotPresent',
|
|
|
- env: [
|
|
|
- {
|
|
|
- name: 'INDEXER_ENDPOINT_URL',
|
|
|
- value: indexerURL,
|
|
|
- },
|
|
|
- { name: 'TYPEORM_HOST', value: 'postgres-db' },
|
|
|
- { name: 'TYPEORM_DATABASE', value: process.env.DB_NAME! },
|
|
|
- { name: 'DEBUG', value: 'index-builder:*' },
|
|
|
- { name: 'PROCESSOR_POLL_INTERVAL', value: '1000' },
|
|
|
- ],
|
|
|
- volumeMounts: [
|
|
|
- {
|
|
|
- mountPath: '/joystream/query-node/mappings/lib/generated/types/typedefs.json',
|
|
|
- name: 'processor-volume',
|
|
|
- subPath: 'fileData',
|
|
|
+ const processorDeployment = new k8s.apps.v1.Deployment(
|
|
|
+ `processor`,
|
|
|
+ {
|
|
|
+ metadata: {
|
|
|
+ namespace: namespaceName,
|
|
|
+ labels: appLabels,
|
|
|
+ },
|
|
|
+ spec: {
|
|
|
+ replicas: 1,
|
|
|
+ selector: { matchLabels: appLabels },
|
|
|
+ template: {
|
|
|
+ metadata: {
|
|
|
+ labels: appLabels,
|
|
|
+ },
|
|
|
+ spec: {
|
|
|
+ containers: [
|
|
|
+ {
|
|
|
+ name: 'processor',
|
|
|
+ image: joystreamAppsImage,
|
|
|
+ imagePullPolicy: 'IfNotPresent',
|
|
|
+ env: [
|
|
|
+ {
|
|
|
+ name: 'INDEXER_ENDPOINT_URL',
|
|
|
+ value: indexerURL,
|
|
|
+ },
|
|
|
+ { name: 'TYPEORM_HOST', value: processorDbName },
|
|
|
+ { name: 'TYPEORM_DATABASE', value: process.env.DB_NAME! },
|
|
|
+ { name: 'DEBUG', value: 'index-builder:*' },
|
|
|
+ { name: 'PROCESSOR_POLL_INTERVAL', value: '1000' },
|
|
|
+ ],
|
|
|
+ volumeMounts: [
|
|
|
+ {
|
|
|
+ mountPath: '/joystream/query-node/mappings/lib/generated/types/typedefs.json',
|
|
|
+ name: 'processor-volume',
|
|
|
+ subPath: 'fileData',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ command: ['/bin/sh', '-c'],
|
|
|
+ args: ['cd query-node && yarn hydra-processor run -e ../.env'],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ volumes: [
|
|
|
+ {
|
|
|
+ name: 'processor-volume',
|
|
|
+ configMap: {
|
|
|
+ name: defsConfig,
|
|
|
},
|
|
|
- ],
|
|
|
- command: ['/bin/sh', '-c'],
|
|
|
- args: ['cd query-node && yarn hydra-processor run -e ../.env'],
|
|
|
- },
|
|
|
- ],
|
|
|
- volumes: [
|
|
|
- {
|
|
|
- name: 'processor-volume',
|
|
|
- configMap: {
|
|
|
- name: defsConfig,
|
|
|
},
|
|
|
- },
|
|
|
- ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- },
|
|
|
- { ...resourceOptions, dependsOn: service }
|
|
|
-)
|
|
|
+ { ...resourceOptions, dependsOn: graphqlService }
|
|
|
+ )
|
|
|
+}
|
|
|
|
|
|
const caddyEndpoints = [
|
|
|
`/indexer* {
|
|
|
uri strip_prefix /indexer
|
|
|
- reverse_proxy query-node:4000
|
|
|
+ reverse_proxy indexer:4000
|
|
|
}`,
|
|
|
`/server* {
|
|
|
uri strip_prefix /server
|
|
|
- reverse_proxy query-node:8081
|
|
|
+ reverse_proxy graphql-server:8081
|
|
|
}`,
|
|
|
]
|
|
|
|