Skip to content

Commit

Permalink
temp: cluster apply network
Browse files Browse the repository at this point in the history
  • Loading branch information
kidneyweakx committed Jan 16, 2024
1 parent 82a74f9 commit 34b4255
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/quorum/instance/infra/InfraRunner.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface InfraRunner<T> {
export interface KubernetesInfraRunner<T> {
createDeploymentAndService(payload: K8SRunCommandType): Promise<T>
createTemplate(payload: K8SRunCommandType): Promise<T>
wait(job: string, namespace: string): Promise<T>
deleteDeploymentAndService(payload: K8SRunCommandType): Promise<T>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ node:
image:
goquorum:
repository: quorumengineering/quorum
tag: 22.7.1
tag: 23.4.0
tessera:
repository: quorumengineering/tessera
tag: 22.1.7
Expand Down
17 changes: 6 additions & 11 deletions src/quorum/instance/infra/kubernetes/runner.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import YAML from 'js-yaml'
import { logger } from '../../../../util/logger'
import { spawn } from 'child_process'
import config from '../../../config'
import fs from 'fs-extra'
import { DockerResultType, KubernetesInfraRunner } from '../InfraRunner.interface'
import { K8SRunCommandType } from '../../../model/type/kubernetes.type'

Expand Down Expand Up @@ -30,6 +28,12 @@ export class Runner implements KubernetesInfraRunner<DockerResultType> {
return { stdout: '' }
}

public wait = async (job: string, namespace: string): Promise<DockerResultType> => {
await console.log('wait')
await this.runKubectl(['wait', '--for=condition=complete', job, '-n', namespace, '--timeout=600s'])
return { stdout: '' }
}

public deleteDeploymentAndService = async (payload: K8SRunCommandType): Promise<DockerResultType> => {
await console.log('deleteDeploymentAndService')
await this.runHelm(
Expand Down Expand Up @@ -57,15 +61,6 @@ export class Runner implements KubernetesInfraRunner<DockerResultType> {
return { stdout: '' }
}

private getYaml (path: string): Promise<any> {
return new Promise((resolve, reject) => {
fs.readFile(path, 'utf8', (err, data) => {
if (err) reject(err)
resolve(YAML.load(data))
})
})
}

private async checkAndCreateNamespace (namespace: string): Promise<void> {
try {
console.log(`kubectl get namespaces ${namespace}`)
Expand Down
7 changes: 7 additions & 0 deletions src/quorum/instance/kubernetesCluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ export default class KubernetesInstance extends AbstractInstance {
return await this.kubernetesInfra.createTemplate(payload)
}
}

public async wait (job: string, namespace: string) {
logger.debug('Kubernetes instance wait')
if (this.kubernetesInfra !== undefined) {
return await this.kubernetesInfra.wait(job, namespace)
}
}
}
5 changes: 3 additions & 2 deletions src/quorum/service/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default class Cluster extends AbstractService {
values: this.bdkFile.getGenesisChartPath(),
})

await k8s.wait('job.batch/goquorum-genesis-init', 'quorum')
// create network
const validatorYaml = new ValidatorConfigYaml()
validatorYaml.setCluster()
Expand All @@ -44,15 +45,15 @@ export default class Cluster extends AbstractService {
for (let i = 0; i < validatorNumber; i += 1) {
await k8s.install({
helmChart: this.bdkFile.getGoQuorumNodeChartPath(),
name: `validator${i}`,
name: `validator-${i + 1}`,
namespace: 'quorum',
values: this.bdkFile.getValidatorChartPath(i),
})
}
for (let i = 0; i < memberNumber; i += 1) {
await k8s.install({
helmChart: this.bdkFile.getGoQuorumNodeChartPath(),
name: `member${i}`,
name: `member-${i + 1}`,
namespace: 'quorum',
values: this.bdkFile.getMemberChartPath(i),
})
Expand Down

0 comments on commit 34b4255

Please sign in to comment.