Skip to content

Commit

Permalink
fix: remove kubectl usage
Browse files Browse the repository at this point in the history
Signed-off-by: Lenin Mehedy <lenin.mehedy@swirldslabs.com>
  • Loading branch information
leninmehedy committed Jan 24, 2024
1 parent 7387dff commit 1194025
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 322 deletions.
2 changes: 0 additions & 2 deletions fullstack-network-manager/src/commands/base.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export class BaseCommand extends ShellRunner {
constructor (opts) {
if (!opts || !opts.logger) throw new Error('An instance of core/Logger is required')
if (!opts || !opts.helm) throw new Error('An instance of core/Helm is required')
if (!opts || !opts.kubectl) throw new Error('An instance of core/Kubectl is required')
if (!opts || !opts.kubectl2) throw new Error('An instance of core/Kubectl2 is required')
if (!opts || !opts.chartManager) throw new Error('An instance of core/ChartManager is required')
if (!opts || !opts.configManager) throw new Error('An instance of core/ConfigManager is required')
Expand All @@ -28,7 +27,6 @@ export class BaseCommand extends ShellRunner {
super(opts.logger)

this.helm = opts.helm
this.kubectl = opts.kubectl
this.kubectl2 = opts.kubectl2
this.chartManager = opts.chartManager
this.configManager = opts.configManager
Expand Down
2 changes: 1 addition & 1 deletion fullstack-network-manager/src/commands/cluster.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class ClusterCommand extends BaseCommand {
desc: 'Setup cluster with shared components',
builder: y => flags.setCommandFlags(y,
flags.clusterName,
flags.withDefaultValue(flags.namespace, constants.DEFAULT_NAMESPACE),
flags.namespace,
flags.chartDirectory,
flags.deployPrometheusStack,
flags.deployMinio,
Expand Down
5 changes: 2 additions & 3 deletions fullstack-network-manager/src/commands/init.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,12 @@ export class InitCommand extends BaseCommand {
title: 'Check dependencies',
task: async (_, task) => {
const deps = [
core.constants.HELM,
core.constants.KUBECTL
core.constants.HELM
]

const subTasks = self.depManager.taskCheckDependencies(deps)

// setup the sub-tasks
// set up the sub-tasks
return task.newListr(subTasks, {
concurrent: true,
rendererOptions: {
Expand Down
14 changes: 6 additions & 8 deletions fullstack-network-manager/src/commands/relay.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class RelayCommand extends BaseCommand {
const chartDir = self.configManager.getFlag(flags.chartDirectory)

// prompt if inputs are empty and set it in the context
const namespaces = await self.kubectl.getNamespace('--no-headers', '-o name')
const namespaces = await self.kubectl2.getNamespaces()
ctx.config = {
chartDir: await prompts.promptChartDir(task, chartDir),
namespace: await prompts.promptSelectNamespaceArg(task, namespace, namespaces),
Expand Down Expand Up @@ -132,12 +132,10 @@ export class RelayCommand extends BaseCommand {

await this.chartManager.install(namespace, releaseName, chartPath, '', valuesArg)

await this.kubectl.wait('pod',
'--for=condition=ready',
'-l app=hedera-json-rpc-relay',
`-l app.kubernetes.io/instance=${releaseName}`,
'--timeout=900s'
)
await this.kubectl2.waitForPod(constants.POD_STATUS_READY, [
'app=hedera-json-rpc-relay',
`app.kubernetes.io/instance=${releaseName}`
], 1)

this.logger.showList('Deployed Relays', await self.chartManager.getInstalledCharts(namespace))
}
Expand Down Expand Up @@ -170,7 +168,7 @@ export class RelayCommand extends BaseCommand {
const namespace = self.configManager.getFlag(flags.namespace)

// prompt if inputs are empty and set it in the context
const namespaces = await self.kubectl.getNamespace('--no-headers', '-o name')
const namespaces = await self.kubectl2.getNamespaces()
ctx.config = {
namespace: await prompts.promptSelectNamespaceArg(task, namespace, namespaces),
nodeIds: await prompts.promptNodeIdsArg(task, nodeIds)
Expand Down
2 changes: 1 addition & 1 deletion fullstack-network-manager/src/core/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const RELEASE_NAME = 'fst'
export const NAMESPACE_NAME = `fst-${USER_SANITIZED}`

export const HELM = 'helm'
export const KUBECTL = 'kubectl'
export const CWD = process.cwd()
export const FST_CONFIG_FILE = `${FST_HOME_DIR}/fsnetman.config`
export const RESOURCES_DIR = normalize(CUR_FILE_DIR + '/../../resources')
Expand Down Expand Up @@ -69,6 +68,7 @@ export const OPERATOR_ID = process.env.FST_OPERATOR_ID || '0.0.2'
export const OPERATOR_KEY = process.env.FST_OPERATOR_KEY || '302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137'

export const POD_STATUS_RUNNING = 'Running'
export const POD_STATUS_READY = 'Ready'

// Listr related
export const LISTR_DEFAULT_RENDERER_TIMER_OPTION = {
Expand Down
9 changes: 0 additions & 9 deletions fullstack-network-manager/src/core/dependency_manager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export class DependencyManager extends ShellRunner {
// map of dependency checks
this.checks = new Map()
.set(core.constants.HELM, () => this.checkHelm())
.set(core.constants.KUBECTL, () => this.checkKubectl())
}

async runCheck (cmdString) {
Expand All @@ -31,14 +30,6 @@ export class DependencyManager extends ShellRunner {
return this.runCheck(`${core.constants.HELM} version`)
}

/**
* Check if 'kubectl' CLI program is installed or not
* @returns {Promise<boolean>}
*/
async checkKubectl () {
return this.runCheck(`${core.constants.KUBECTL} version --client`)
}

/**
* Check if the required dependency is installed or not
* @param dep is the name of the program
Expand Down
2 changes: 0 additions & 2 deletions fullstack-network-manager/src/core/index.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as logging from './logging.mjs'
import * as constants from './constants.mjs'
import { Helm } from './helm.mjs'
import { Kubectl } from './kubectl.mjs'
import { Kubectl2 } from './kubectl2.mjs'
import { PackageDownloader } from './package_downloader.mjs'
import { PlatformInstaller } from './platform_installer.mjs'
Expand All @@ -16,7 +15,6 @@ export {
logging,
constants,
Helm,
Kubectl,
Kubectl2,
PackageDownloader,
PlatformInstaller,
Expand Down
182 changes: 0 additions & 182 deletions fullstack-network-manager/src/core/kubectl.mjs

This file was deleted.

3 changes: 0 additions & 3 deletions fullstack-network-manager/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
PackageDownloader,
PlatformInstaller,
Helm,
Kubectl,
logging
} from './core/index.mjs'
import 'dotenv/config'
Expand All @@ -21,7 +20,6 @@ export function main (argv) {

try {
const helm = new Helm(logger)
const kubectl = new Kubectl(logger)
const downloader = new PackageDownloader(logger)
const chartManager = new ChartManager(helm, logger)
const configManager = new ConfigManager(logger)
Expand Down Expand Up @@ -50,7 +48,6 @@ export function main (argv) {
const opts = {
logger,
helm,
kubectl,
kubectl2,
downloader,
platformInstaller,
Expand Down
3 changes: 0 additions & 3 deletions fullstack-network-manager/test/e2e/commands/node.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
ChartManager,
ConfigManager,
Helm,
Kubectl,
Kubectl2,
PackageDownloader,
PlatformInstaller,
Expand Down Expand Up @@ -92,7 +91,6 @@ class TestHelper {

describe('NodeCommand', () => {
const helm = new Helm(testLogger)
const kubectl = new Kubectl(testLogger)
const chartManager = new ChartManager(helm, testLogger)
const configManager = new ConfigManager(testLogger)
const packageDownloader = new PackageDownloader(testLogger)
Expand All @@ -103,7 +101,6 @@ describe('NodeCommand', () => {
const nodeCmd = new NodeCommand({
logger: testLogger,
helm,
kubectl,
kubectl2,
chartManager,
configManager,
Expand Down
Loading

0 comments on commit 1194025

Please sign in to comment.