Skip to content

Commit e4ac40c

Browse files
committed
K13
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent dc6e820 commit e4ac40c

14 files changed

+91
-55
lines changed

src/commands/account.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class AccountCommand extends BaseCommand {
170170
const namespace = await resolveNamespaceFromDeployment(this.localConfig, this.configManager, task);
171171
const config = {namespace};
172172

173-
if (!(await this.K0013.namespaces().has(namespace))) {
173+
if (!(await this.k8Factory.default().namespaces().has(namespace))) {
174174
throw new SoloError(`namespace ${namespace.name} does not exist`);
175175
}
176176

@@ -334,7 +334,7 @@ export class AccountCommand extends BaseCommand {
334334
config.amount = flags.amount.definition.defaultValue as number;
335335
}
336336

337-
if (!(await this.K0013.namespaces().has(config.namespace))) {
337+
if (!(await this.k8Factory.default().namespaces().has(config.namespace))) {
338338
throw new SoloError(`namespace ${config.namespace} does not exist`);
339339
}
340340

@@ -412,7 +412,7 @@ export class AccountCommand extends BaseCommand {
412412
ed25519PrivateKey: self.configManager.getFlag<string>(flags.ed25519PrivateKey) as string,
413413
};
414414

415-
if (!(await this.K0013.namespaces().has(config.namespace))) {
415+
if (!(await this.k8Factory.default().namespaces().has(config.namespace))) {
416416
throw new SoloError(`namespace ${config.namespace} does not exist`);
417417
}
418418

@@ -494,7 +494,7 @@ export class AccountCommand extends BaseCommand {
494494
privateKey: self.configManager.getFlag<boolean>(flags.privateKey) as boolean,
495495
};
496496

497-
if (!(await this.K0013.namespaces().has(config.namespace))) {
497+
if (!(await this.k8Factory.default().namespaces().has(config.namespace))) {
498498
throw new SoloError(`namespace ${config.namespace} does not exist`);
499499
}
500500

src/commands/explorer.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,14 @@ export class ExplorerCommand extends BaseCommand {
249249

250250
if (config.enableIngress) {
251251
// patch ingressClassName of mirror ingress so it can be recognized by haproxy ingress controller
252-
await this.K0013.ingresses().update(config.namespace, constants.MIRROR_NODE_RELEASE_NAME, {
253-
spec: {
254-
ingressClassName: `${config.namespace}-hedera-explorer-ingress-class`,
255-
},
256-
});
252+
await this.k8Factory
253+
.default()
254+
.ingresses()
255+
.update(config.namespace, constants.MIRROR_NODE_RELEASE_NAME, {
256+
spec: {
257+
ingressClassName: `${config.namespace}-hedera-explorer-ingress-class`,
258+
},
259+
});
257260

258261
// to support GRPC over HTTP/2
259262
await this.K0015.configMaps().update(
@@ -286,13 +289,16 @@ export class ExplorerCommand extends BaseCommand {
286289

287290
// patch explorer ingress to use h1 protocol, haproxy ingress controller default backend protocol is h2
288291
// to support grpc over http/2
289-
await this.K0013.ingresses().update(config.namespace, constants.HEDERA_EXPLORER_RELEASE_NAME, {
290-
metadata: {
291-
annotations: {
292-
'haproxy-ingress.github.io/backend-protocol': 'h1',
292+
await this.k8Factory
293+
.default()
294+
.ingresses()
295+
.update(config.namespace, constants.HEDERA_EXPLORER_RELEASE_NAME, {
296+
metadata: {
297+
annotations: {
298+
'haproxy-ingress.github.io/backend-protocol': 'h1',
299+
},
293300
},
294-
},
295-
});
301+
});
296302
},
297303
},
298304
{

src/commands/mirror_node.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ export class MirrorNodeCommand extends BaseCommand {
233233

234234
if (ctx.config.pinger) {
235235
const startAccId = constants.HEDERA_NODE_ACCOUNT_ID_START;
236-
const networkPods = await this.K0013.pods().list(namespace, ['solo.hedera.com/type=network-node']);
236+
const networkPods = await this.k8Factory
237+
.default()
238+
.pods()
239+
.list(namespace, ['solo.hedera.com/type=network-node']);
237240

238241
if (networkPods.length) {
239242
const pod = networkPods[0];
@@ -453,7 +456,10 @@ export class MirrorNodeCommand extends BaseCommand {
453456
return; //! stop the execution
454457
}
455458

456-
const pods = await this.K0013.pods().list(namespace, ['app.kubernetes.io/name=postgres']);
459+
const pods = await this.k8Factory
460+
.default()
461+
.pods()
462+
.list(namespace, ['app.kubernetes.io/name=postgres']);
457463
if (pods.length === 0) {
458464
throw new SoloError('postgres pod not found');
459465
}

src/commands/network.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,8 @@ export class NetworkCommand extends BaseCommand {
431431
config.valuesArg = await this.prepareValuesArg(config);
432432
config.namespace = namespace;
433433

434-
if (!(await this.K0013.namespaces().has(namespace))) {
435-
await this.K0013.namespaces().create(namespace);
434+
if (!(await this.k8Factory.default().namespaces().has(namespace))) {
435+
await this.k8Factory.default().namespaces().create(namespace);
436436
}
437437

438438
// prepare staging keys directory

src/commands/node/configs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ export const stopConfigBuilder = async function (argv, ctx, task) {
323323
deployment: this.configManager.getFlag(flags.deployment),
324324
};
325325

326-
if (!(await this.K0013.namespaces().has(ctx.config.namespace))) {
326+
if (!(await this.k8Factory.default().namespaces().has(ctx.config.namespace))) {
327327
throw new SoloError(`namespace ${ctx.config.namespace} does not exist`);
328328
}
329329

@@ -334,7 +334,7 @@ export const startConfigBuilder = async function (argv, ctx, task) {
334334
const config = this.getConfig(START_CONFIGS_NAME, argv.flags, ['nodeAliases', 'namespace']) as NodeStartConfigClass;
335335
config.namespace = await resolveNamespaceFromDeployment(this.parent.localConfig, this.configManager, task);
336336

337-
if (!(await this.K0013.namespaces().has(config.namespace))) {
337+
if (!(await this.k8Factory.default().namespaces().has(config.namespace))) {
338338
throw new SoloError(`namespace ${config.namespace} does not exist`);
339339
}
340340

src/commands/node/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class NodeCommand extends BaseCommand {
7575
await this.accountManager.close();
7676
if (this._portForwards) {
7777
for (const srv of this._portForwards) {
78-
await this.K0013.pods().readByRef(null).stopPortForward(srv);
78+
await this.k8Factory.default().pods().readByRef(null).stopPortForward(srv);
7979
}
8080
}
8181

src/commands/node/tasks.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,9 @@ export class NodeCommandTasks {
10211021
subTasks.push({
10221022
title: `Start node: ${chalk.yellow(nodeAlias)}`,
10231023
task: async () => {
1024-
await this.K0013.containers()
1024+
await this.k8Factory
1025+
.default()
1026+
.containers()
10251027
.readByRef(containerRef)
10261028
.execContainer(['systemctl', 'restart', 'network-node']);
10271029
},
@@ -1045,7 +1047,11 @@ export class NodeCommandTasks {
10451047
async (ctx: any, task: ListrTaskWrapper<any, any, any>) => {
10461048
const podRef = PodRef.of(ctx.config.namespace, PodName.of(`network-${ctx.config.debugNodeAlias}-0`));
10471049
this.logger.debug(`Enable port forwarding for JVM debugger on pod ${podRef.name}`);
1048-
await this.K0013.pods().readByRef(podRef).portForward(constants.JVM_DEBUG_PORT, constants.JVM_DEBUG_PORT);
1050+
await this.k8Factory
1051+
.default()
1052+
.pods()
1053+
.readByRef(podRef)
1054+
.portForward(constants.JVM_DEBUG_PORT, constants.JVM_DEBUG_PORT);
10491055
},
10501056
(ctx: any) => !ctx.config.debugNodeAlias,
10511057
);
@@ -1173,7 +1179,11 @@ export class NodeCommandTasks {
11731179
subTasks.push({
11741180
title: `Stop node: ${chalk.yellow(nodeAlias)}`,
11751181
task: async () =>
1176-
await this.K0013.containers().readByRef(containerRef).execContainer('systemctl stop network-node'),
1182+
await this.k8Factory
1183+
.default()
1184+
.containers()
1185+
.readByRef(containerRef)
1186+
.execContainer('systemctl stop network-node'),
11771187
});
11781188
}
11791189
}
@@ -1572,7 +1582,7 @@ export class NodeCommandTasks {
15721582
return new Task('Kill nodes', async (ctx: any, task: ListrTaskWrapper<any, any, any>) => {
15731583
const config = ctx.config;
15741584
for (const service of config.serviceMap.values()) {
1575-
await this.K0013.pods().readByRef(PodRef.of(config.namespace, service.nodePodName)).killPod();
1585+
await this.k8Factory.default().pods().readByRef(PodRef.of(config.namespace, service.nodePodName)).killPod();
15761586
}
15771587
});
15781588
}
@@ -1586,7 +1596,7 @@ export class NodeCommandTasks {
15861596
config.serviceMap = await this.accountManager.getNodeServiceMap(config.namespace);
15871597

15881598
for (const service of config.serviceMap.values()) {
1589-
await this.K0013.pods().readByRef(PodRef.of(config.namespace, service.nodePodName)).killPod();
1599+
await this.k8Factory.default().pods().readByRef(PodRef.of(config.namespace, service.nodePodName)).killPod();
15901600
}
15911601

15921602
// again, the pod names will change after the pods are killed
@@ -1669,7 +1679,11 @@ export class NodeCommandTasks {
16691679
await this.K0015.containers()
16701680
.readByRef(containerRef)
16711681
.execContainer(['bash', '-c', `mkdir -p ${savedStatePath}`]);
1672-
await this.K0013.containers().readByRef(containerRef).copyTo(config.lastStateZipPath, savedStatePath);
1682+
await this.k8Factory
1683+
.default()
1684+
.containers()
1685+
.readByRef(containerRef)
1686+
.copyTo(config.lastStateZipPath, savedStatePath);
16731687
await this.platformInstaller.setPathPermission(podRef, constants.HEDERA_HAPI_PATH);
16741688
await this.K0015.containers()
16751689
.readByRef(containerRef)

src/commands/relay.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ export class RelayCommand extends BaseCommand {
105105
try {
106106
const deploymentName = this.configManager.getFlag<DeploymentName>(flags.deployment);
107107
const namespace = NamespaceName.of(this.localConfig.deployments[deploymentName].namespace);
108-
const secrets = await this.K0013.secrets().list(namespace, [`solo.hedera.com/account-id=${operatorIdUsing}`]);
108+
const secrets = await this.k8Factory
109+
.default()
110+
.secrets()
111+
.list(namespace, [`solo.hedera.com/account-id=${operatorIdUsing}`]);
109112
if (secrets.length === 0) {
110113
this.logger.info(`No k8s secret found for operator account id ${operatorIdUsing}, use default one`);
111114
valuesArg += ` --set config.OPERATOR_KEY_MAIN=${constants.OPERATOR_KEY}`;

src/core/certificate_manager.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,10 @@ export class CertificateManager {
8080
const namespace = this.getNamespace();
8181
const labels = Templates.renderGrpcTlsCertificatesSecretLabelObject(nodeAlias, type);
8282

83-
const isSecretCreated = await this.K0013.secrets().createOrReplace(
84-
namespace,
85-
name,
86-
SecretType.OPAQUE,
87-
data,
88-
labels,
89-
);
83+
const isSecretCreated = await this.k8Factory
84+
.default()
85+
.secrets()
86+
.createOrReplace(namespace, name, SecretType.OPAQUE, data, labels);
9087
if (!isSecretCreated) {
9188
throw new SoloError(`failed to create secret for TLS certificates for node '${nodeAlias}'`);
9289
}

src/core/cluster_checks.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class ClusterChecks {
3131
*/
3232
public async isCertManagerInstalled(): Promise<boolean> {
3333
try {
34-
const pods: Pod[] = await this.K0013.pods().listForAllNamespaces(['app=cert-manager']);
34+
const pods: Pod[] = await this.k8Factory.default().pods().listForAllNamespaces(['app=cert-manager']);
3535

3636
return pods.length > 0;
3737
} catch (e) {
@@ -48,7 +48,7 @@ export class ClusterChecks {
4848
public async isMinioInstalled(namespace: NamespaceName): Promise<boolean> {
4949
try {
5050
// TODO DETECT THE OPERATOR
51-
const pods: V1Pod[] = await this.K0013.pods().list(namespace, ['app=minio']);
51+
const pods: V1Pod[] = await this.k8Factory.default().pods().list(namespace, ['app=minio']);
5252

5353
return pods.length > 0;
5454
} catch (e) {
@@ -64,7 +64,7 @@ export class ClusterChecks {
6464
*/
6565
public async isIngressControllerInstalled(): Promise<boolean> {
6666
try {
67-
const ingressClassList: IngressClass[] = await this.K0013.ingressClasses().list();
67+
const ingressClassList: IngressClass[] = await this.k8Factory.default().ingressClasses().list();
6868

6969
return ingressClassList.length > 0;
7070
} catch (e) {
@@ -99,7 +99,10 @@ export class ClusterChecks {
9999
*/
100100
public async isPrometheusInstalled(namespace: NamespaceName) {
101101
try {
102-
const pods: V1Pod[] = await this.K0013.pods().list(namespace, ['app.kubernetes.io/name=prometheus']);
102+
const pods: V1Pod[] = await this.k8Factory
103+
.default()
104+
.pods()
105+
.list(namespace, ['app.kubernetes.io/name=prometheus']);
103106

104107
return pods.length > 0;
105108
} catch (e) {

0 commit comments

Comments
 (0)