Forráskód Böngészése

Add args to container, add password keyfile support

Anuj Bansal 3 éve
szülő
commit
eaf388fdab

+ 2 - 6
devops/kubernetes/storage-node/Pulumi.yaml

@@ -1,6 +1,6 @@
-name: eks-cluster
+name: storage-node
 runtime: nodejs
-description: A Pulumi program to deploy storage node to cloud environment
+description: A Pulumi program to deploy storage node to Kubernetes
 template:
   config:
     aws:profile:
@@ -12,7 +12,6 @@ template:
       default: false
     wsProviderEndpointURI:
       description: Chain RPC endpoint
-      default: 'wss://rome-rpc-endpoint.joystream.org:9944/'
     isLoadBalancerReady:
       description: Whether the load balancer service is ready and has been assigned an IP
       default: false
@@ -32,10 +31,7 @@ template:
       default: joystream/colossus:latest
     queryNodeHost:
       description: Query node GraphQL endpoint
-      default: 'https://hydra.joystream.org/graphql'
     workerId:
       description: ID of the node operator (distribution working group worker)
-      default: 0
     accountURI:
       description: Account URI
-      default: '//Alice'

+ 6 - 6
devops/kubernetes/storage-node/README.md

@@ -1,6 +1,6 @@
 # Amazon EKS Cluster: Hello World!
 
-This example deploys an EKS Kubernetes cluster with custom ipfs image
+Deploy storage-node to a Kubernetes cluster
 
 ## Deploying the App
 
@@ -37,12 +37,12 @@ After cloning this repo, from this working directory, run these commands:
 1. Set the required configuration variables in `Pulumi.<stack>.yaml`
 
    ```bash
-   $ pulumi config set-all --plaintext aws:region=us-east-1 --plaintext aws:profile=joystream-user \
-    --plaintext wsProviderEndpointURI='wss://rome-rpc-endpoint.joystream.org:9944/' \
+   $ pulumi config set-all --plaintext wsProviderEndpointURI='wss://rome-rpc-endpoint.joystream.org:9944/' \
     --plaintext queryNodeHost='http://graphql-server.query-node-yszsbs2i:8081' \
-    --plaintext keyFile='../../../keyfile.json' --plaintext passphrase='' \
-    --plaintext accountURI='//Alice' \
-    --plaintext isMinikube=true
+    --plaintext keyFile='../../../keyfile.json' --secret passphrase='' \
+    --plaintext accountURI='//Alice' workerId=0 \
+    --plaintext isMinikube=true --plaintext colossusImage='joystream/colossus:latest' \
+    --plaintext aws:region=us-east-1 --plaintext aws:profile=joystream-user
    ```
 
    If you want to build the stack on AWS set the `isMinikube` config to `false`

+ 21 - 3
devops/kubernetes/storage-node/index.ts

@@ -14,7 +14,7 @@ const name = 'storage-node'
 
 const wsProviderEndpointURI = config.require('wsProviderEndpointURI')
 const queryNodeHost = config.require('queryNodeHost')
-const workerId = config.get('workerId') || '0'
+const workerId = config.require('workerId')
 const accountURI = config.get('accountURI')
 const keyFile = config.get('keyFile')
 const lbReady = config.get('isLoadBalancerReady') === 'true'
@@ -108,11 +108,11 @@ if (keyFile) {
   ).configName
 
   const remoteKeyFilePath = '/joystream/key-file.json'
-  additionalParams = ['--keyFile', remoteKeyFilePath]
+  additionalParams.push(`--keyFile=${remoteKeyFilePath}`)
 
   const passphrase = config.get('passphrase')
   if (passphrase) {
-    additionalParams.push('--password', passphrase)
+    additionalParams.push(`--password=${passphrase}`)
   }
 
   additionalVolumes.push({
@@ -150,6 +150,7 @@ const deployment = new k8s.apps.v1.Deployment(
               name: 'colossus',
               image: colossusImage,
               imagePullPolicy: 'IfNotPresent',
+              workingDir: '/joystream/storage-node-v2',
               env: [
                 {
                   name: 'WS_PROVIDER_ENDPOINT_URI',
@@ -172,6 +173,7 @@ const deployment = new k8s.apps.v1.Deployment(
                   name: 'WORKER_ID',
                   value: workerId,
                 },
+                // ACCOUNT_URI takes precedence over keyFile
                 {
                   name: 'ACCOUNT_URI',
                   value: accountURI,
@@ -190,6 +192,22 @@ const deployment = new k8s.apps.v1.Deployment(
                 },
                 ...additionalVolumeMounts,
               ],
+              command: ['yarn'],
+              args: [
+                'storage-node',
+                'server',
+                '--worker',
+                workerId,
+                '--port=3333',
+                '--uploads=/data',
+                '--sync',
+                '--syncInterval=1',
+                '--queryNodeEndpoint',
+                queryNodeHost,
+                '--apiUrl',
+                wsProviderEndpointURI,
+                ...additionalParams,
+              ],
               ports: [{ containerPort: colossusPort }],
             },
           ],