Ver Fonte

Add env variables to indexer, change initial migration to processor db

Anuj Bansal há 3 anos atrás
pai
commit
770cb84cb2

+ 2 - 22
devops/infrastructure/query-node/index.ts

@@ -9,18 +9,6 @@ import * as fs from 'fs'
 
 require('dotenv').config()
 
-interface EnvironmentType {
-  name: string
-  value: string
-}
-
-let envCopy: EnvironmentType[] = []
-let e: string = ''
-for (e in process.env) {
-  let envObject: EnvironmentType = { 'name': e, 'value': process.env[e]! }
-  envCopy.push(envObject)
-}
-
 // const awsConfig = new pulumi.Config('aws')
 
 // // Create a VPC for our cluster.
@@ -55,17 +43,8 @@ export const joystreamAppsImage = new docker.Image('joystream/apps', {
   },
   imageName: 'joystream/apps:latest',
   skipPush: true,
-  localImageName: 'joystream/apps:latest',
 }).baseImageName
 
-function getUniqueListByName(arr: EnvironmentType[]) {
-  return [...new Map(arr.map((item: EnvironmentType) => [item['name'], item])).values()]
-}
-
-// export let imageName: pulumi.Output<string>
-// imageName = joystreamAppsImage
-// console.log(imageName)
-
 // export const joystreamAppsImage = 'joystream/apps'
 
 const name = 'query-node'
@@ -153,7 +132,7 @@ const exampleJob = new k8s.batch.v1.Job(
                   name: 'DB_HOST',
                   value: 'postgres-db',
                 },
-                { name: 'DB_NAME', value: process.env.INDEXER_DB_NAME! },
+                { name: 'DB_NAME', value: process.env.DB_NAME! },
                 { name: 'DB_PASS', value: process.env.DB_PASS! },
               ],
               command: ['/bin/sh', '-c'],
@@ -204,6 +183,7 @@ const deployment = new k8s.apps.v1.Deployment(
                 { 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: [
                 {

+ 0 - 86
devops/infrastructure/query-node/k8sjs.ts

@@ -1,86 +0,0 @@
-import * as k8s from '@pulumi/kubernetes'
-import * as k8stypes from '@pulumi/kubernetes/types/input'
-import * as pulumi from '@pulumi/pulumi'
-
-/**
- * ServiceDeployment is an example abstraction that uses a class to fold together the common pattern of a
- * Kubernetes Deployment and its associated Service object.
- */
-export class ServiceDeployment extends pulumi.ComponentResource {
-  public readonly deployment: k8s.apps.v1.Deployment
-  public readonly service: k8s.core.v1.Service
-  public readonly ipAddress?: pulumi.Output<string>
-
-  constructor(name: string, args: ServiceDeploymentArgs, opts?: pulumi.ComponentResourceOptions) {
-    super('k8sjs:service:ServiceDeployment', name, {}, opts)
-
-    const labels = { app: name }
-    const currentEnv = args.env || []
-    currentEnv.push({ name: 'GET_HOSTS_FROM', value: 'dns' })
-
-    const container: k8stypes.core.v1.Container = {
-      name,
-      image: args.image,
-      resources: args.resources || { requests: { cpu: '100m', memory: '100Mi' } },
-      env: currentEnv,
-      command: args.command,
-      ports: args.ports && args.ports.map((p) => ({ containerPort: p })),
-      volumeMounts: args.volumeMounts,
-    }
-    this.deployment = new k8s.apps.v1.Deployment(
-      name,
-      {
-        spec: {
-          selector: { matchLabels: labels },
-          replicas: args.replicas || 1,
-          template: {
-            metadata: { labels: labels },
-            spec: { containers: [container], volumes: args.volumes },
-          },
-        },
-      },
-      { provider: args.provider, parent: this }
-    )
-
-    this.service = new k8s.core.v1.Service(
-      name,
-      {
-        metadata: {
-          name: name,
-          labels: this.deployment.metadata.labels,
-        },
-        spec: {
-          ports: args.ports && args.ports.map((p) => ({ port: p, targetPort: p })),
-          selector: this.deployment.spec.template.metadata.labels,
-          // Minikube does not implement services of type `LoadBalancer`; require the user to specify if we're
-          // running on minikube, and if so, create only services of type ClusterIP.
-          type: args.allocateIpAddress ? (args.isMinikube ? 'ClusterIP' : 'LoadBalancer') : undefined,
-        },
-      },
-      { provider: args.provider, parent: this }
-    )
-
-    if (args.allocateIpAddress) {
-      this.ipAddress = args.isMinikube ? this.service.spec.clusterIP : this.service.status.loadBalancer.ingress[0].ip
-    }
-  }
-}
-
-interface EnvironmentType {
-  name: string
-  value: string
-}
-
-export interface ServiceDeploymentArgs {
-  image: string | pulumi.Output<string>
-  provider: k8s.Provider
-  resources?: k8stypes.core.v1.ResourceRequirements
-  replicas?: number
-  ports?: number[]
-  env?: EnvironmentType[]
-  command?: string[]
-  volumeMounts?: any[]
-  volumes?: any[]
-  allocateIpAddress?: boolean
-  isMinikube?: boolean
-}