@@ -4,21 +4,29 @@ import { platform } from 'os';
44import { resolve } from 'path' ;
55import * as needle from 'needle' ;
66
7+ const clusterName = 'kind' ;
8+
79export async function createCluster ( imageNameAndTag : string ) : Promise < void > {
810 const osDistro = platform ( ) ;
911 await download ( osDistro ) ;
10- const clusterName = 'kind' ;
1112 await createKindCluster ( clusterName ) ;
12- await exportKubeConfig ( clusterName ) ;
1313 await loadImageInCluster ( imageNameAndTag ) ;
1414}
1515
16- export async function deleteCluster ( clusterName = 'kind' ) : Promise < void > {
16+ export async function deleteCluster ( ) : Promise < void > {
1717 console . log ( `Deleting cluster ${ clusterName } ...` ) ;
1818 await exec ( `./kind delete cluster --name=${ clusterName } ` ) ;
1919 console . log ( `Deleted cluster ${ clusterName } !` ) ;
2020}
2121
22+ export async function exportKubeConfig ( ) : Promise < void > {
23+ console . log ( 'Exporting K8s config...' ) ;
24+ const kindResponse = await exec ( `./kind get kubeconfig-path --name="${ clusterName } "` ) ;
25+ const configPath = kindResponse . stdout . replace ( / [ \n \t \r ] / g, '' ) ;
26+ process . env . KUBECONFIG = configPath ;
27+ console . log ( 'Exported K8s config!' ) ;
28+ }
29+
2230async function download ( osDistro : string ) : Promise < void > {
2331 try {
2432 accessSync ( resolve ( process . cwd ( ) , 'kind' ) , constants . R_OK ) ;
@@ -55,14 +63,6 @@ async function createKindCluster(clusterName, kindImageTag = 'latest'): Promise<
5563 console . log ( `Created cluster ${ clusterName } !` ) ;
5664}
5765
58- async function exportKubeConfig ( clusterName ) : Promise < void > {
59- console . log ( 'Exporting K8s config...' ) ;
60- const kindResponse = await exec ( `./kind get kubeconfig-path --name="${ clusterName } "` ) ;
61- const configPath = kindResponse . stdout . replace ( / [ \n \t \r ] / g, '' ) ;
62- process . env . KUBECONFIG = configPath ;
63- console . log ( 'Exported K8s config!' ) ;
64- }
65-
6666async function loadImageInCluster ( imageNameAndTag ) : Promise < void > {
6767 console . log ( `Loading image ${ imageNameAndTag } in cluster...` ) ;
6868 await exec ( `./kind load docker-image ${ imageNameAndTag } ` ) ;
0 commit comments