Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): use kubernetes javascript client instead of invoking kubctl CLI #673

Merged
merged 39 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
bfd72cf
feat: implement Kubectl class using kubernetes javascript client
leninmehedy Jan 15, 2024
df76d00
feat: implement copy file to container
leninmehedy Jan 15, 2024
f90450c
cleanup
leninmehedy Jan 15, 2024
66a4817
feat: implement hasDir and hasFile
leninmehedy Jan 15, 2024
cade2bc
fix: remove unused args
leninmehedy Jan 15, 2024
33913a9
fix: rewrite async function of a promise with polling
leninmehedy Jan 15, 2024
aad0af9
add timeout arg
leninmehedy Jan 15, 2024
7e03a6e
remove incorrect docs
leninmehedy Jan 15, 2024
fc26a01
fix: use exec status to exit from polling and code cleanup
leninmehedy Jan 15, 2024
2eddad2
feat: implement port forward and polling utility function
leninmehedy Jan 16, 2024
d51cdfa
fix: refactor config manager to contain the config
leninmehedy Jan 17, 2024
02fdaa8
fix: remove unnecessary polling from exec call and cache configManage…
leninmehedy Jan 17, 2024
82a80f4
feat: implement wait for pod and add check for copy methods
leninmehedy Jan 17, 2024
f24f9d3
remove unused import
leninmehedy Jan 18, 2024
1415260
fix: replace old kubectl with kubectl2 in chart command
leninmehedy Jan 19, 2024
26dc63c
fix: use Kubect2 for node commands
leninmehedy Jan 19, 2024
75f3c63
test: fix tests for missing kubect2
leninmehedy Jan 19, 2024
6a4226c
fix: do not require kind and cluster creation functionalities
leninmehedy Jan 22, 2024
ec8dd5c
fix: split platform code copy and extract into separate steps for bet…
leninmehedy Jan 22, 2024
b663d57
fix: get pod IP and copy files checks
leninmehedy Jan 22, 2024
214daba
fix: use default namespace for cluster setup
leninmehedy Jan 22, 2024
12c94ab
fix node setup
leninmehedy Jan 22, 2024
90b0f4d
fix: check for namespace
leninmehedy Jan 22, 2024
1a5981b
fix: e2e tests and CI pipelline
leninmehedy Jan 22, 2024
2b3f9a3
fix: e2e tests
leninmehedy Jan 23, 2024
505ab8d
fix: check for pod readiness individually to show more info to the user
leninmehedy Jan 23, 2024
644c0e0
add setup script for e2e test
leninmehedy Jan 23, 2024
468b0b0
Merge branch 'main' into 605-kubernetes-javascript-client
leninmehedy Jan 24, 2024
5a9b96c
fix: make waitForPod non-blocking
leninmehedy Jan 24, 2024
af5e7a4
fix: do not poll after copyToPod or copyFromPod
leninmehedy Jan 24, 2024
7387dff
fix: add clone method for Kubectl2
leninmehedy Jan 24, 2024
1194025
fix: remove kubectl usage
leninmehedy Jan 24, 2024
5ba143c
fix: waitForPod
leninmehedy Jan 24, 2024
acd277f
fix: relay command
leninmehedy Jan 24, 2024
a911703
fix: rename Kubectl2 to K8
leninmehedy Jan 24, 2024
1c8ee25
fix test
leninmehedy Jan 24, 2024
6956df2
rename test setup script
leninmehedy Jan 24, 2024
e9555a2
fix: allow namespace to be created during chart install
leninmehedy Jan 24, 2024
0933869
Merge branch 'main' into 605-kubernetes-javascript-client
leninmehedy Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: check for namespace
Signed-off-by: Lenin Mehedy <lenin.mehedy@swirldslabs.com>
  • Loading branch information
leninmehedy committed Jan 22, 2024
commit 90b0f4dbe90c06db90ec5a9b65a6a9974bf95e35
4 changes: 4 additions & 0 deletions fullstack-network-manager/src/commands/chart.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export class ChartCommand extends BaseCommand {
config.enableTls, config.tlsClusterIssuerName, config.tlsClusterIssuerNamespace, config.enableHederaExplorerTls,
config.acmeClusterIssuer, config.selfSignedClusterIssuer)

if (!await this.kubectl2.hasNamespace(config.namespace)) {
throw new FullstackTestingError(`namespace ${config.namespace} does not exist`)
}

return config
}

Expand Down
13 changes: 12 additions & 1 deletion fullstack-network-manager/src/commands/node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ export class NodeCommand extends BaseCommand {
chainId: await prompts.promptChainId(task, argv.chainId)
}

if (!await this.kubectl2.hasNamespace(config.namespace)) {
throw new FullstackTestingError(`namespace ${config.namespace} does not exist`)
}

// compute other config parameters
config.releasePrefix = Templates.prepareReleasePrefix(config.releaseTag)
config.buildZipFile = `${config.cacheDir} /${config.releasePrefix}/build-${config.releaseTag}.zip`
Expand Down Expand Up @@ -215,6 +219,10 @@ export class NodeCommand extends BaseCommand {
namespace: await prompts.promptSelectNamespaceArg(task, namespace, namespaces),
nodeIds: await prompts.promptNodeIdsArg(task, argv.nodeIds)
}

if (!await this.kubectl2.hasNamespace(ctx.config.namespace)) {
throw new FullstackTestingError(`namespace ${ctx.config.namespace} does not exist`)
}
}
},
{
Expand Down Expand Up @@ -289,11 +297,14 @@ export class NodeCommand extends BaseCommand {

// get existing choices
const namespaces = await self.kubectl2.getNamespaces()

ctx.config = {
namespace: await prompts.promptSelectNamespaceArg(task, namespace, namespaces),
nodeIds: await prompts.promptNodeIdsArg(task, argv.nodeIds)
}

if (!await this.kubectl2.hasNamespace(ctx.config.namespace)) {
throw new FullstackTestingError(`namespace ${ctx.config.namespace} does not exist`)
}
}
},
{
Expand Down
10 changes: 10 additions & 0 deletions fullstack-network-manager/src/core/kubectl2.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ export class Kubectl2 {
throw new FullstackTestingError('incorrect response received from kubernetes API. Unable to list namespaces')
}

/**
* Returns true if a namespace exists with the given name
* @param namespace namespace name
* @return {Promise<boolean>}
*/
async hasNamespace (namespace) {
const namespaces = await this.getNamespaces()
return namespaces.includes(namespace)
}

/**
* Get a podName by name
* @param name podName name
Expand Down