Skip to content

Commit 9fee4db

Browse files
committed
add the logic to write the gossip key secrets
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent e3ade3e commit 9fee4db

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/commands/node.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ export class NodeCommand extends BaseCommand {
16691669
valuesArg += this.prepareValuesFiles(this.profileValuesFile)
16701670
}
16711671

1672-
// TODO: update the secrets with the new/updated key(s)
1672+
// TODO: update the secrets with the new/updated key(s), platform installer: copyGossipKeys & copyTLSKeys
16731673
await self.chartManager.upgrade(
16741674
config.namespace,
16751675
constants.FULLSTACK_DEPLOYMENT_CHART,

src/core/platform_installer.mjs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { FullstackTestingError, IllegalArgumentError, MissingArgumentError } fro
2222
import { constants } from './index.mjs'
2323
import { Templates } from './templates.mjs'
2424
import { flags } from '../commands/index.mjs'
25+
import * as Base64 from 'js-base64'
2526

2627
/**
2728
* PlatformInstaller install platform code in the root-container of a network pod
@@ -171,13 +172,27 @@ export class PlatformInstaller {
171172
throw new FullstackTestingError(`Unsupported key file format ${keyFormat}`)
172173
}
173174

175+
const data = {}
176+
for (const srcFile of srcFiles) {
177+
const fileContents = fs.readFileSync(srcFile)
178+
const fileName = path.basename(srcFile)
179+
data[fileName] = Base64.encode(fileContents)
180+
}
181+
182+
if (!await this.k8.createSecret(
183+
Templates.renderGossipKeySecretName(nodeId),
184+
this._getNamespace(), 'Opaque', data,
185+
Templates.renderGossipKeySecretLabelObject(nodeId), true)) {
186+
this.logger.error(`failed to create secret for gossip keys for node '${nodeId}'`)
187+
throw new FullstackTestingError(`failed to create secret for gossip keys for node '${nodeId}'`)
188+
}
189+
174190
return await self.copyFiles(podName, srcFiles, keysDir)
175191
} catch (e) {
176192
throw new FullstackTestingError(`failed to copy gossip keys to pod '${podName}': ${e.message}`, e)
177193
}
178194
}
179195

180-
// TODO: update to copy the keys to the k8s secrets
181196
async copyTLSKeys (podName, stagingDir) {
182197
if (!podName) throw new MissingArgumentError('podName is required')
183198
if (!stagingDir) throw new MissingArgumentError('stagingDir is required')
@@ -196,6 +211,8 @@ export class PlatformInstaller {
196211
srcFiles.push(path.join(tmpDir, 'hedera.key'))
197212
srcFiles.push(path.join(tmpDir, 'hedera.crt'))
198213

214+
// TODO: create secret and store in network-node-hapi-app-secrets, hedera-{{ $node.name }}.crt, hedera-{{ $node.name }}.key
215+
199216
return this.copyFiles(podName, srcFiles, constants.HEDERA_HAPI_PATH)
200217
} catch (e) {
201218
throw new FullstackTestingError(`failed to copy TLS keys to pod '${podName}': ${e.message}`, e)

src/core/templates.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,14 @@ export class Templates {
185185
}
186186
}
187187
}
188+
189+
static renderGossipKeySecretName (nodeId) {
190+
return `network-${nodeId}-keys-secrets`
191+
}
192+
193+
static renderGossipKeySecretLabelObject (nodeId) {
194+
return {
195+
'fullstack.hedera.com/node-name': nodeId
196+
}
197+
}
188198
}

0 commit comments

Comments
 (0)