Skip to content

Commit

Permalink
Merge pull request #25 from ksctl/release-v1_2_0
Browse files Browse the repository at this point in the history
Upgraded the cli to ksctl core v1.2.0
  • Loading branch information
dipankardas011 authored May 31, 2024
2 parents 4c54d9a + 352a51b commit b5cfe34
Show file tree
Hide file tree
Showing 26 changed files with 1,415 additions and 807 deletions.
310 changes: 123 additions & 187 deletions .github/workflows/test-mock.yml

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions .github/workflows/testLogger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Testing Logger
on:
push:
paths:
- 'logger/**'
- 'go.mod'
- 'go.sum'
branches: [ main ]
pull_request:
paths:
- 'logger/**'
- 'go.mod'
- 'go.sum'
branches: [ main ]

jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.0
- run: go version
- name: testing
working-directory: logger
run: |
go test -v ./...
4 changes: 2 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ builds:
- amd64
- arm64
ldflags:
- -s -w -X "github.com/kubesimplify/ksctl-cli/cli/cmd.BuildDate={{.Env.DATE}}"
- -s -w -X "github.com/kubesimplify/ksctl-cli/cli/cmd.Version={{.Env.VERSION}}"
- -s -w -X "github.com/ksctl/cli/cli/cmd.BuildDate={{.Env.DATE}}"
- -s -w -X "github.com/ksctl/cli/cli/cmd.Version={{.Env.VERSION}}"
env:
- CGO_ENABLED=0

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ lint: golangci-lint ## Run golangci-lint linter & yamllint
$(GOLANGCI_LINT) run && echo -e "\n=========\n\033[91m✔ PASSED\033[0m\n=========\n" || echo -e "\n=========\n\033[91m✖ FAILED\033[0m\n=========\n"


##@ Dependencies (Controller)
##@ Dependencies

## Location to install dependencies to
LOCALBIN ?= /tmp/bin
Expand Down
44 changes: 25 additions & 19 deletions cli/cmd/addNodesHAAws.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
package cmd

// authors Dipankar <dipankar@dipankar-das.com>

import (
"context"
"os"

"github.com/ksctl/ksctl/pkg/helpers"
"github.com/fatih/color"
"github.com/ksctl/cli/logger"
"github.com/ksctl/ksctl/pkg/controllers"
"github.com/ksctl/ksctl/pkg/types"

"github.com/spf13/cobra"

"github.com/ksctl/ksctl/pkg/helpers/consts"
)

var addMoreWorkerNodesHAAws = &cobra.Command{
Deprecated: color.HiYellowString("This will be removed in future releases once autoscaling is stable"),
Example: `
ksctl create ha-aws add-nodes -n demo -r ap-south-1 -s store-local --noWP 3 --nodeSizeWP t2.medium --bootstrap kubeadm # Here the noWP is the desired count of workernodes
`,
Use: "add-nodes",
Short: "Use to add more worker nodes in HA aws k3s cluster",
Long: `It is used to add nodes to worker nodes in cluster with the given name from user. For example:
ksctl create-cluster ha-azure add-nodes <arguments to civo cloud provider>
`,
Short: "Use to add more worker nodes in self-managed Highly-Available cluster on Aws",
Long: "It is used to add nodes to worker nodes in cluster with the given name from user.",
Run: func(cmd *cobra.Command, args []string) {
verbosity, _ := cmd.Flags().GetInt("verbose")
SetRequiredFeatureFlags(cmd)
var log types.LoggerFactory = logger.NewLogger(verbosity, os.Stdout)
SetRequiredFeatureFlags(ctx, log, cmd)

cli.Client.Metadata.LogVerbosity = verbosity
cli.Client.Metadata.LogWritter = os.Stdout
cli.Client.Metadata.Provider = consts.CloudAws

SetDefaults(consts.CloudAws, consts.ClusterTypeHa)
Expand All @@ -37,23 +37,29 @@ ksctl create-cluster ha-azure add-nodes <arguments to civo cloud provider>
cli.Client.Metadata.IsHA = true
cli.Client.Metadata.K8sDistro = consts.KsctlKubernetes(distro)
cli.Client.Metadata.K8sVersion = k8sVer
cli.Client.Metadata.StateLocation = consts.KsctlStore(storage)

if err := safeInitializeStorageLoggerFactory(context.WithValue(context.Background(), "USERID", helpers.GetUserName())); err != nil {
log.Error("Failed Initialize Storage Driver", "Reason", err)
if err := createApproval(ctx, log, cmd.Flags().Lookup("yes").Changed); err != nil {
log.Error(ctx, "createApproval", "Reason", err)
os.Exit(1)
}

if err := createApproval(cmd.Flags().Lookup("approve").Changed); err != nil {
log.Error(err.Error())
m, err := controllers.NewManagerClusterSelfManaged(
ctx,
log,
&cli.Client,
)
if err != nil {
log.Error(ctx, "Failed to init manager", "Reason", err)
os.Exit(1)
}

err := controller.AddWorkerPlaneNode(&cli.Client)
err = m.AddWorkerPlaneNodes()
if err != nil {
log.Error("Failed to scale up", "Reason", err)
log.Error(ctx, "Failed to scale up", "Reason", err)
os.Exit(1)
}
log.Success("Scale up successful")
log.Success(ctx, "Scale up successful")
},
}

Expand Down
45 changes: 26 additions & 19 deletions cli/cmd/addNodesHAAzure.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
package cmd

// authors Dipankar <dipankar@dipankar-das.com>

import (
"context"
"os"

"github.com/ksctl/ksctl/pkg/helpers"
"github.com/fatih/color"

"github.com/ksctl/cli/logger"
"github.com/ksctl/ksctl/pkg/controllers"
"github.com/ksctl/ksctl/pkg/types"

"github.com/spf13/cobra"

"github.com/ksctl/ksctl/pkg/helpers/consts"
)

var addMoreWorkerNodesHAAzure = &cobra.Command{
Deprecated: color.HiYellowString("This will be removed in future releases once autoscaling is stable"),
Example: `
ksctl create ha-azure add-nodes -n demo -r eastus -s store-local --noWP 3 --nodeSizeWP Standard_F2s --bootstrap kubeadm # Here the noWP is the desired count of workernodes
`,
Use: "add-nodes",
Short: "Use to add more worker nodes in HA azure k3s cluster",
Long: `It is used to add nodes to worker nodes in cluster with the given name from user. For example:
ksctl create-cluster ha-azure add-nodes <arguments to civo cloud provider>
`,
Short: "Use to add more worker nodes in self-managed Highly-Available cluster on Azure",
Long: "It is used to add nodes to worker nodes in cluster with the given name from user",
Run: func(cmd *cobra.Command, args []string) {
verbosity, _ := cmd.Flags().GetInt("verbose")
SetRequiredFeatureFlags(cmd)
var log types.LoggerFactory = logger.NewLogger(verbosity, os.Stdout)
SetRequiredFeatureFlags(ctx, log, cmd)

cli.Client.Metadata.LogVerbosity = verbosity
cli.Client.Metadata.LogWritter = os.Stdout
cli.Client.Metadata.Provider = consts.CloudAzure

SetDefaults(consts.CloudAzure, consts.ClusterTypeHa)
Expand All @@ -37,23 +38,29 @@ ksctl create-cluster ha-azure add-nodes <arguments to civo cloud provider>
cli.Client.Metadata.IsHA = true
cli.Client.Metadata.K8sDistro = consts.KsctlKubernetes(distro)
cli.Client.Metadata.K8sVersion = k8sVer
cli.Client.Metadata.StateLocation = consts.KsctlStore(storage)

if err := safeInitializeStorageLoggerFactory(context.WithValue(context.Background(), "USERID", helpers.GetUserName())); err != nil {
log.Error("Failed Inialize Storage Driver", "Reason", err)
if err := createApproval(ctx, log, cmd.Flags().Lookup("yes").Changed); err != nil {
log.Error(ctx, "createApproval", "Reason", err)
os.Exit(1)
}

if err := createApproval(cmd.Flags().Lookup("approve").Changed); err != nil {
log.Error(err.Error())
m, err := controllers.NewManagerClusterSelfManaged(
ctx,
log,
&cli.Client,
)
if err != nil {
log.Error(ctx, "Failed to init manager", "Reason", err)
os.Exit(1)
}

err := controller.AddWorkerPlaneNode(&cli.Client)
err = m.AddWorkerPlaneNodes()
if err != nil {
log.Error("Failed to scale up", "Reason", err)
log.Error(ctx, "Failed to scale up", "Reason", err)
os.Exit(1)
}
log.Success("Scale up successful")
log.Success(ctx, "Scale up successful")
},
}

Expand Down
46 changes: 27 additions & 19 deletions cli/cmd/addNodesHACivo.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
package cmd

// authors Dipankar <dipankar@dipankar-das.com>

import (
"context"
"os"

"github.com/ksctl/ksctl/pkg/helpers"
"github.com/fatih/color"

"github.com/ksctl/ksctl/pkg/controllers"
"github.com/ksctl/ksctl/pkg/logger"
"github.com/ksctl/ksctl/pkg/types"

"github.com/ksctl/ksctl/pkg/helpers/consts"
"github.com/spf13/cobra"
)

var addMoreWorkerNodesHACivo = &cobra.Command{
Deprecated: color.HiYellowString("This will be removed in future releases once autoscaling is stable"),
Example: `
ksctl create ha-civo add-nodes -n demo -r LON1 -s store-local --noWP 3 --nodeSizeWP g3.medium --bootstrap kubeadm # Here the noWP is the desired count of workernodes
`,
Use: "add-nodes",
Short: "Use to add more worker nodes in HA CIVO k3s cluster",
Long: `It is used to add nodes to worker nodes in cluster with the given name from user. For example:
ksctl create-cluster ha-civo add-nodes <arguments to civo cloud provider>
`,
Short: "Use to add more worker nodes in self-managed Highly-Available cluster on Civo",
Long: "It is used to add nodes to worker nodes in cluster with the given name from user.",
Run: func(cmd *cobra.Command, args []string) {
verbosity, _ := cmd.Flags().GetInt("verbose")
SetRequiredFeatureFlags(cmd)

cli.Client.Metadata.LogVerbosity = verbosity
cli.Client.Metadata.LogWritter = os.Stdout
var log types.LoggerFactory = logger.NewGeneralLogger(verbosity, os.Stdout)
SetRequiredFeatureFlags(ctx, log, cmd)

cli.Client.Metadata.Provider = consts.CloudCivo

SetDefaults(consts.CloudCivo, consts.ClusterTypeHa)
Expand All @@ -36,23 +38,29 @@ ksctl create-cluster ha-civo add-nodes <arguments to civo cloud provider>
cli.Client.Metadata.K8sDistro = consts.KsctlKubernetes(distro)
cli.Client.Metadata.K8sVersion = k8sVer
cli.Client.Metadata.IsHA = true
cli.Client.Metadata.StateLocation = consts.KsctlStore(storage)

if err := safeInitializeStorageLoggerFactory(context.WithValue(context.Background(), "USERID", helpers.GetUserName())); err != nil {
log.Error("Failed Inialize Storage Driver", "Reason", err)
if err := createApproval(ctx, log, cmd.Flags().Lookup("yes").Changed); err != nil {
log.Error(ctx, "createApproval", "Reason", err)
os.Exit(1)
}

if err := createApproval(cmd.Flags().Lookup("approve").Changed); err != nil {
log.Error(err.Error())
m, err := controllers.NewManagerClusterSelfManaged(
ctx,
log,
&cli.Client,
)
if err != nil {
log.Error(ctx, "Failed to init manager", "Reason", err)
os.Exit(1)
}

err := controller.AddWorkerPlaneNode(&cli.Client)
err = m.AddWorkerPlaneNodes()
if err != nil {
log.Error("Failed to scale up", "Reason", err)
log.Error(ctx, "Failed to scale up", "Reason", err)
os.Exit(1)
}
log.Success("Scale up successful")
log.Success(ctx, "Scale up successful")
},
}

Expand Down
Loading

0 comments on commit b5cfe34

Please sign in to comment.