Skip to content

Commit

Permalink
Merge pull request #32 from ksctl/ksctl-v1_2_5
Browse files Browse the repository at this point in the history
update deps and the code changes
  • Loading branch information
dipankardas011 authored Aug 1, 2024
2 parents 81ecac0 + 1056b7b commit 3d509d5
Show file tree
Hide file tree
Showing 65 changed files with 659 additions and 317 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test-mock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ jobs:
- name: aws create
run: |
# ${{env.KSCTL_BIN}} create aws -n demo -r fake-region --nodeSizeMP "fake" --version 1.27.1 -s store-local --verbose -1 --yes
${{env.KSCTL_BIN}} create aws -n demo -r fake-region --nodeSizeMP "fake" --version 1.30 -s store-local --verbose -1 --yes
#${{env.KSCTL_BIN}} info -p aws -n demo -r fake-region -s store-local --verbose -1
${{env.KSCTL_BIN}} info -p aws -n demo -r fake-region -s store-local --verbose -1
${{env.KSCTL_BIN}} create ha-aws -n ha-demo-k3s --nodeSizeDS "fake" --version 1.27.1 --nodeSizeLB "fake" --nodeSizeCP "fake" --nodeSizeWP "fake" -r fake-region --verbose -1 -s store-local --yes --bootstrap k3s
Expand Down Expand Up @@ -198,7 +198,7 @@ jobs:
- name: aws switch
run: |
# ${{env.KSCTL_BIN}} switch -p aws -n demo -s store-local -r fake-region
${{env.KSCTL_BIN}} switch -p aws -n demo -s store-local -r fake-region
${{env.KSCTL_BIN}} switch -p ha-aws -n ha-demo-k3s -s store-local -r fake-region
${{env.KSCTL_BIN}} switch -p ha-aws -n ha-demo-kubeadm -s store-local -r fake-region
Expand Down
22 changes: 22 additions & 0 deletions cli/cmd/createCluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ ksctl create-cluster azure -n demo -r eastus -s store-local --nodeSizeMP Standar
},
}

var createClusterAws = &cobra.Command{
Use: "aws",
Example: `
ksctl create-cluster aws -n demo -r ap-south-1 -s store-local --nodeSizeMP t2.micro --noMP 3
`,
Short: "Use to create a EKS cluster in Aws",
Long: "It is used to create cluster with the given name from user",
Run: func(cmd *cobra.Command, args []string) {
verbosity, _ := cmd.Flags().GetInt("verbose")
var log types.LoggerFactory = logger.NewLogger(verbosity, os.Stdout)
SetRequiredFeatureFlags(ctx, log, cmd)

cli.Client.Metadata.Provider = consts.CloudAws

SetDefaults(consts.CloudAws, consts.ClusterTypeMang)

createManaged(ctx, log, cmd.Flags().Lookup("yes").Changed)
},
}

var createClusterCivo = &cobra.Command{
Use: "civo",
Example: `
Expand Down Expand Up @@ -150,8 +170,10 @@ func init() {
createClusterCmd.AddCommand(createClusterHACivo)
createClusterCmd.AddCommand(createClusterHAAzure)
createClusterCmd.AddCommand(createClusterHAAws)
createClusterCmd.AddCommand(createClusterAws)

createClusterAzure.MarkFlagRequired("name")
createClusterAws.MarkFlagRequired("name")
createClusterCivo.MarkFlagRequired("name")
createClusterCivo.MarkFlagRequired("region")
createClusterLocal.MarkFlagRequired("name")
Expand Down
24 changes: 24 additions & 0 deletions cli/cmd/deleteCluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ksctl delete local --name demo --storage store-local
deleteManaged(ctx, log, cmd.Flags().Lookup("yes").Changed)
},
}

var deleteClusterAzure = &cobra.Command{
Use: "azure",
Example: `
Expand All @@ -58,6 +59,26 @@ ksctl delete azure --name demo --region eastus --storage store-local
},
}

var deleteClusterAws = &cobra.Command{
Use: "aws",
Example: `
ksctl delete aws --name demo --region ap-south-1 --storage store-local
`,
Short: "Use to deletes a EKS cluster",
Long: "It is used to delete cluster of given provider",
Run: func(cmd *cobra.Command, args []string) {
verbosity, _ := cmd.Flags().GetInt("verbose")
var log types.LoggerFactory = logger.NewLogger(verbosity, os.Stdout)
SetRequiredFeatureFlags(ctx, log, cmd)

cli.Client.Metadata.Provider = consts.CloudAws

SetDefaults(consts.CloudAws, consts.ClusterTypeMang)

deleteManaged(ctx, log, cmd.Flags().Lookup("yes").Changed)
},
}

var deleteClusterCivo = &cobra.Command{
Use: "civo",
Example: `
Expand Down Expand Up @@ -147,7 +168,10 @@ func init() {
deleteClusterCmd.AddCommand(deleteClusterAzure)
deleteClusterCmd.AddCommand(deleteClusterLocal)
deleteClusterCmd.AddCommand(deleteClusterHAAws)
deleteClusterCmd.AddCommand(deleteClusterAws)

deleteClusterAws.MarkFlagRequired("name")
deleteClusterAws.MarkFlagRequired("region")
deleteClusterAzure.MarkFlagRequired("name")
deleteClusterAzure.MarkFlagRequired("region")
deleteClusterCivo.MarkFlagRequired("name")
Expand Down
4 changes: 4 additions & 0 deletions cli/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ func verboseFlags() {
msgApproval := "approval to avoid showMsg"

createClusterAzure.Flags().IntP("verbose", "v", 0, msgVerbose)
createClusterAws.Flags().IntP("verbose", "v", 0, msgVerbose)
createClusterCivo.Flags().IntP("verbose", "v", 0, msgVerbose)
createClusterLocal.Flags().IntP("verbose", "v", 0, msgVerbose)
createClusterHACivo.Flags().IntP("verbose", "v", 0, msgVerbose)
Expand All @@ -18,6 +19,7 @@ func verboseFlags() {
deleteClusterHAAzure.Flags().IntP("verbose", "v", 0, msgVerbose)
deleteClusterHACivo.Flags().IntP("verbose", "v", 0, msgVerbose)
deleteClusterHAAws.Flags().IntP("verbose", "v", 0, msgVerbose)
deleteClusterAws.Flags().IntP("verbose", "v", 0, msgVerbose)
deleteClusterLocal.Flags().IntP("verbose", "v", 0, msgVerbose)

addMoreWorkerNodesHAAzure.Flags().IntP("verbose", "v", 0, msgVerbose)
Expand All @@ -33,6 +35,7 @@ func verboseFlags() {
infoClusterCmd.Flags().IntP("verbose", "v", 0, msgVerbose)

createClusterAzure.Flags().BoolP("yes", "y", true, msgApproval)
createClusterAws.Flags().BoolP("yes", "y", true, msgApproval)
createClusterCivo.Flags().BoolP("yes", "y", true, msgApproval)
createClusterLocal.Flags().BoolP("yes", "y", true, msgApproval)
createClusterHACivo.Flags().BoolP("yes", "y", true, msgApproval)
Expand All @@ -41,6 +44,7 @@ func verboseFlags() {

deleteClusterLocal.Flags().BoolP("yes", "y", true, msgApproval)
deleteClusterAzure.Flags().BoolP("yes", "y", true, msgApproval)
deleteClusterAws.Flags().BoolP("yes", "y", true, msgApproval)
deleteClusterCivo.Flags().BoolP("yes", "y", true, msgApproval)
deleteClusterHAAzure.Flags().BoolP("yes", "y", true, msgApproval)
deleteClusterHACivo.Flags().BoolP("yes", "y", true, msgApproval)
Expand Down
3 changes: 3 additions & 0 deletions cli/cmd/infoCluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ ksctl info -p ha-azure -n ha-demo-kubeadm -r eastus -s store-local --verbose -1
cli.Client.Metadata.Provider = consts.CloudAws
cli.Client.Metadata.IsHA = true

case string(consts.CloudAws):
cli.Client.Metadata.Provider = consts.CloudAws

case string(consts.CloudAzure):
cli.Client.Metadata.Provider = consts.CloudAzure
default:
Expand Down
4 changes: 4 additions & 0 deletions cli/cmd/switchCluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ksctl switch-context --provider azure --name <clustername> --region <region>
ksctl switch-context --provider ha-civo --name <clustername> --region <region>
ksctl switch-context --provider ha-azure --name <clustername> --region <region>
ksctl switch-context --provider ha-aws --name <clustername> --region <region>
ksctl switch-context --provider aws --name <clustername> --region <region>
For Storage specific
Expand Down Expand Up @@ -61,6 +62,9 @@ ksctl switch-context -s external-store-mongodb -p civo -n <clustername> -r <regi
cli.Client.Metadata.Provider = consts.CloudAws
cli.Client.Metadata.IsHA = true

case string(consts.CloudAws):
cli.Client.Metadata.Provider = consts.CloudAws

case string(consts.CloudAzure):
cli.Client.Metadata.Provider = consts.CloudAzure
}
Expand Down
34 changes: 34 additions & 0 deletions cli/cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,23 @@ func SetDefaults(provider consts.KsctlCloud, clusterType consts.KsctlClusterType
storage = string(consts.StoreLocal)
}

case string(consts.CloudAws) + string(consts.ClusterTypeMang):
if len(nodeSizeMP) == 0 {
nodeSizeMP = "t2.micro"
}
if noMP == -1 {
noMP = 2
}
if len(region) == 0 {
region = "ap-south-1"
}
if len(k8sVer) == 0 {
k8sVer = "1.30"
}
if len(storage) == 0 {
storage = string(consts.StoreLocal)
}

case string(consts.CloudAws) + string(consts.ClusterTypeHa):
if len(nodeSizeCP) == 0 {
if distro == string(consts.K8sKubeadm) {
Expand Down Expand Up @@ -431,6 +448,17 @@ func argsFlags() {
cniFlag(createClusterAzure)
storageFlag(createClusterAzure)

// Managed Aws
clusterNameFlag(createClusterAws)
nodeSizeManagedFlag(createClusterAws)
regionFlag(createClusterAws)
noOfMPFlag(createClusterAws)
k8sVerFlag(createClusterAws)
distroFlag(createClusterAws)
appsFlag(createClusterAws)
cniFlag(createClusterAws)
storageFlag(createClusterAws)

// Managed Civo
clusterNameFlag(createClusterCivo)
nodeSizeManagedFlag(createClusterCivo)
Expand Down Expand Up @@ -509,6 +537,11 @@ func argsFlags() {
regionFlag(deleteClusterAzure)
storageFlag(deleteClusterAzure)

// managed Aws
clusterNameFlag(deleteClusterAws)
regionFlag(deleteClusterAws)
storageFlag(deleteClusterAws)

// Managed Civo
clusterNameFlag(deleteClusterCivo)
regionFlag(deleteClusterCivo)
Expand Down Expand Up @@ -540,6 +573,7 @@ func AllFeatures() {
featureFlag(createClusterHACivo)
featureFlag(createClusterLocal)
featureFlag(createClusterHAAws)
featureFlag(createClusterAws)

featureFlag(deleteClusterAzure)
featureFlag(deleteClusterHAAzure)
Expand Down
2 changes: 1 addition & 1 deletion gen/docs.md/ksctl.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ from local clusters to cloud provider specific clusters.
* [ksctl switch-cluster](ksctl_switch-cluster.md) - Use to switch between clusters
* [ksctl version](ksctl_version.md) - Print the version number of ksctl

###### Auto generated by spf13/cobra on 21-Jun-2024
###### Auto generated by spf13/cobra on 1-Aug-2024
3 changes: 2 additions & 1 deletion gen/docs.md/ksctl_create-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ ksctl create --help
### SEE ALSO

* [ksctl](ksctl.md) - CLI tool for managing multiple K8s clusters
* [ksctl create-cluster aws](ksctl_create-cluster_aws.md) - Use to create a EKS cluster in Aws
* [ksctl create-cluster azure](ksctl_create-cluster_azure.md) - Use to create a AKS cluster in Azure
* [ksctl create-cluster civo](ksctl_create-cluster_civo.md) - Use to create a Civo managed k3s cluster
* [ksctl create-cluster ha-aws](ksctl_create-cluster_ha-aws.md) - Use to create a self-managed Highly Available cluster on AWS
* [ksctl create-cluster ha-azure](ksctl_create-cluster_ha-azure.md) - Use to create a self-managed Highly-Available cluster on Azure
* [ksctl create-cluster ha-civo](ksctl_create-cluster_ha-civo.md) - Use to create a self-managed Highly Available cluster on Civo
* [ksctl create-cluster local](ksctl_create-cluster_local.md) - Use to create a kind cluster

###### Auto generated by spf13/cobra on 21-Jun-2024
###### Auto generated by spf13/cobra on 1-Aug-2024
41 changes: 41 additions & 0 deletions gen/docs.md/ksctl_create-cluster_aws.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## ksctl create-cluster aws

Use to create a EKS cluster in Aws

### Synopsis

It is used to create cluster with the given name from user

```
ksctl create-cluster aws [flags]
```

### Examples

```
ksctl create-cluster aws -n demo -r ap-south-1 -s store-local --nodeSizeMP t2.micro --noMP 3
```

### Options

```
--apps string Pre-Installed Applications
--bootstrap string Kubernetes Bootstrap
--cni string CNI
--feature-flags string Experimental Features: Supported values with comma seperated: [autoscale]
-h, --help help for aws
-n, --name string Cluster Name (default "demo")
--noMP int Number of Managed Nodes (default -1)
--nodeSizeMP string Node size of managed cluster nodes
-r, --region string Region
-s, --storage string storage provider
--version string Kubernetes Version
```

### SEE ALSO

* [ksctl create-cluster](ksctl_create-cluster.md) - Use to create a cluster

###### Auto generated by spf13/cobra on 1-Aug-2024
2 changes: 1 addition & 1 deletion gen/docs.md/ksctl_create-cluster_azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ ksctl create-cluster azure -n demo -r eastus -s store-local --nodeSizeMP Standar

* [ksctl create-cluster](ksctl_create-cluster.md) - Use to create a cluster

###### Auto generated by spf13/cobra on 21-Jun-2024
###### Auto generated by spf13/cobra on 1-Aug-2024
2 changes: 1 addition & 1 deletion gen/docs.md/ksctl_create-cluster_civo.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ ksctl create-cluster civo --name demo --region LON1 --storage store-local --node

* [ksctl create-cluster](ksctl_create-cluster.md) - Use to create a cluster

###### Auto generated by spf13/cobra on 21-Jun-2024
###### Auto generated by spf13/cobra on 1-Aug-2024
2 changes: 1 addition & 1 deletion gen/docs.md/ksctl_create-cluster_ha-aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ ksctl create-cluster ha-aws -n demo -r us-east-1 --bootstrap k3s -s store-local
* [ksctl create-cluster](ksctl_create-cluster.md) - Use to create a cluster
* [ksctl create-cluster ha-aws add-nodes](ksctl_create-cluster_ha-aws_add-nodes.md) - Use to add more worker nodes in self-managed Highly-Available cluster on Aws

###### Auto generated by spf13/cobra on 21-Jun-2024
###### Auto generated by spf13/cobra on 1-Aug-2024
2 changes: 1 addition & 1 deletion gen/docs.md/ksctl_create-cluster_ha-aws_add-nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ ksctl create ha-aws add-nodes -n demo -r ap-south-1 -s store-local --noWP 3 --no

* [ksctl create-cluster ha-aws](ksctl_create-cluster_ha-aws.md) - Use to create a self-managed Highly Available cluster on AWS

###### Auto generated by spf13/cobra on 21-Jun-2024
###### Auto generated by spf13/cobra on 1-Aug-2024
2 changes: 1 addition & 1 deletion gen/docs.md/ksctl_create-cluster_ha-azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ ksctl create-cluster ha-azure --name demo --region eastus --bootstrap kubeadm --
* [ksctl create-cluster](ksctl_create-cluster.md) - Use to create a cluster
* [ksctl create-cluster ha-azure add-nodes](ksctl_create-cluster_ha-azure_add-nodes.md) - Use to add more worker nodes in self-managed Highly-Available cluster on Azure

###### Auto generated by spf13/cobra on 21-Jun-2024
###### Auto generated by spf13/cobra on 1-Aug-2024
2 changes: 1 addition & 1 deletion gen/docs.md/ksctl_create-cluster_ha-azure_add-nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ ksctl create ha-azure add-nodes -n demo -r eastus -s store-local --noWP 3 --node

* [ksctl create-cluster ha-azure](ksctl_create-cluster_ha-azure.md) - Use to create a self-managed Highly-Available cluster on Azure

###### Auto generated by spf13/cobra on 21-Jun-2024
###### Auto generated by spf13/cobra on 1-Aug-2024
2 changes: 1 addition & 1 deletion gen/docs.md/ksctl_create-cluster_ha-civo.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ ksctl create-cluster ha-civo --name demo --region LON1 --bootstrap kubeadm --sto
* [ksctl create-cluster](ksctl_create-cluster.md) - Use to create a cluster
* [ksctl create-cluster ha-civo add-nodes](ksctl_create-cluster_ha-civo_add-nodes.md) - Use to add more worker nodes in self-managed Highly-Available cluster on Civo

###### Auto generated by spf13/cobra on 21-Jun-2024
###### Auto generated by spf13/cobra on 1-Aug-2024
2 changes: 1 addition & 1 deletion gen/docs.md/ksctl_create-cluster_ha-civo_add-nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ ksctl create ha-civo add-nodes -n demo -r LON1 -s store-local --noWP 3 --nodeSiz

* [ksctl create-cluster ha-civo](ksctl_create-cluster_ha-civo.md) - Use to create a self-managed Highly Available cluster on Civo

###### Auto generated by spf13/cobra on 21-Jun-2024
###### Auto generated by spf13/cobra on 1-Aug-2024
2 changes: 1 addition & 1 deletion gen/docs.md/ksctl_create-cluster_local.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ ksctl create-cluster local --name demo --storage store-local --noMP 3

* [ksctl create-cluster](ksctl_create-cluster.md) - Use to create a cluster

###### Auto generated by spf13/cobra on 21-Jun-2024
###### Auto generated by spf13/cobra on 1-Aug-2024
2 changes: 1 addition & 1 deletion gen/docs.md/ksctl_cred.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ ksctl cred [flags]

* [ksctl](ksctl.md) - CLI tool for managing multiple K8s clusters

###### Auto generated by spf13/cobra on 21-Jun-2024
###### Auto generated by spf13/cobra on 1-Aug-2024
3 changes: 2 additions & 1 deletion gen/docs.md/ksctl_delete-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ ksctl delete --help
### SEE ALSO

* [ksctl](ksctl.md) - CLI tool for managing multiple K8s clusters
* [ksctl delete-cluster aws](ksctl_delete-cluster_aws.md) - Use to deletes a EKS cluster
* [ksctl delete-cluster azure](ksctl_delete-cluster_azure.md) - Use to deletes a AKS cluster
* [ksctl delete-cluster civo](ksctl_delete-cluster_civo.md) - Use to delete a Civo managed k3s cluster
* [ksctl delete-cluster ha-aws](ksctl_delete-cluster_ha-aws.md) - Use to delete a self-managed Highly Available cluster on AWS
* [ksctl delete-cluster ha-azure](ksctl_delete-cluster_ha-azure.md) - Use to delete a self-managed Highly Available cluster on Azure
* [ksctl delete-cluster ha-civo](ksctl_delete-cluster_ha-civo.md) - Use to delete a self-managed Highly Available cluster on Civo
* [ksctl delete-cluster local](ksctl_delete-cluster_local.md) - Use to delete a kind cluster

###### Auto generated by spf13/cobra on 21-Jun-2024
###### Auto generated by spf13/cobra on 1-Aug-2024
34 changes: 34 additions & 0 deletions gen/docs.md/ksctl_delete-cluster_aws.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## ksctl delete-cluster aws

Use to deletes a EKS cluster

### Synopsis

It is used to delete cluster of given provider

```
ksctl delete-cluster aws [flags]
```

### Examples

```
ksctl delete aws --name demo --region ap-south-1 --storage store-local
```

### Options

```
-h, --help help for aws
-n, --name string Cluster Name (default "demo")
-r, --region string Region
-s, --storage string storage provider
```

### SEE ALSO

* [ksctl delete-cluster](ksctl_delete-cluster.md) - Use to delete a cluster

###### Auto generated by spf13/cobra on 1-Aug-2024
Loading

0 comments on commit 3d509d5

Please sign in to comment.