Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
25ea8f7
prepare migration v3.0.0
mms-gianni Feb 26, 2025
3788429
Bump github.com/go-git/go-git/v5 from 5.13.2 to 5.14.0
dependabot[bot] Mar 3, 2025
454ced5
Bump golang.org/x/crypto from 0.34.0 to 0.35.0
dependabot[bot] Mar 3, 2025
9323f4c
migrate authentication to JWT
mms-gianni Mar 3, 2025
5f632f3
Update command names and descriptions for clarity and consistency.
mms-gianni Mar 4, 2025
f03b5de
migration: pipelines and apps
mms-gianni Mar 7, 2025
6a932e5
Merge pull request #52 from kubero-dev/dependabot/go_modules/golang.o…
mms-gianni Mar 7, 2025
a771a9a
Merge pull request #51 from kubero-dev/dependabot/go_modules/github.c…
mms-gianni Mar 7, 2025
1f059eb
migration pipeline create
mms-gianni Mar 7, 2025
7b624be
improve authentication and toke validation
mms-gianni Mar 7, 2025
153527c
migrate to v3
mms-gianni Mar 9, 2025
c61abf7
Update command aliases and descriptions for 'remote' in Kubero CLI, …
mms-gianni Mar 11, 2025
0e339a5
Merge branch 'main' into release/v3.0.0
mms-gianni Apr 12, 2025
09e1abd
Update CLI version to v3.0.0 in the CLI_VERSION file.
mms-gianni Apr 12, 2025
61d55b3
minor small improvements
mms-gianni Apr 14, 2025
b7b9297
minor installer improvements
mms-gianni Apr 14, 2025
30ce5a5
fix buildpacks type
mms-gianni Apr 16, 2025
6a02408
migrate buildpacks to runpacks
mms-gianni Jun 13, 2025
994a045
improve help
mms-gianni Jun 13, 2025
25e7dec
remove deprecated install routines
mms-gianni Aug 2, 2025
0393de5
Merge branch 'main' into release/v3.0.0
mms-gianni Aug 11, 2025
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
8 changes: 4 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ builds:
- CGO_ENABLED=0
goos:
- linux
- windows
# - windows
- darwin
archives:
- name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
format_overrides:
- goos: windows
format: zip
# format_overrides:
# - goos: windows
# format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
Expand Down
74 changes: 52 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,34 +165,64 @@ Kubero CLI currently supports the following cloud providers:
```plaintext
kubero
├── install # Create a Kubernetes cluster and install Kubero with all required components
├── list # List all running clusters
├── login # Log in to Kubero and save credentials
├── logout # Log out from Kubero and remove saved credentials
├── create # Create new app and pipeline configurations
│ ├── app
│ └── pipeline
├── up # Deploy apps and pipelines
│ ├── app
│ └── pipeline
├── down # Remove apps and pipelines
│ ├── app
│ └── pipeline
├── fetch # Sync configurations to local files
│ ├── app
│ └── pipeline
├── dashboard # Open the Kubero dashboard
├── tunnel # Open a tunnel to a NAT-ed cluster
├── instance # Manage Kubero instances
│ ├── create # Create an instance configuration
│ ├── delete # Delete an instance configuration
│ └── select # Select an active instance
| # Can also be used to install Kubero on an existing cluster
├── login (li) # Log in to Kubero and save credentials
├── logout (lo) # Log out from Kubero and remove saved credentials
├── remote (r) # List Kubero cluster
│ ├── create # Create a cluster configuration
│ ├── delete # Delete a cluster configuration
│ └── select # Select a cluster
├── app (a) # List Kubero apps
│ ├── create # Create an app
│ └── delete # Delete an app
├── pipeline (p) # List Kubero pipelines
│ ├── create # Create a pipeline
│ └── delete # Delete a pipeline
├── config # View available configurations
│ ├── addons # List addons
│ ├── buildpacks # List buildpacks
│ ├── runpacks # List runpacks
│ └── podsizes # List pod size configurations
├── dashboard (db) # Open the Kubero dashboard
├── debug # Gather debug information
├── tunnel (t) # Open a tunnel to a NAT-ed cluster
└── help # Display help for commands
```

### Usage with most common commands
Create a new cluster and install Kubero:

```shell
kubero install
```

Create a new app configuration:
```shell
kubero app create
```

Destroy an app:
```shell
kubero app delete
```

List all running pipelines:
```shell
kubero pipelines
```

Open the Kubero dashboard:

```shell
kubero dashboard
```

For more information, use the `--help` flag with any command:

```shell
kubero --help
```


---

## Provider Credentials
Expand Down
28 changes: 27 additions & 1 deletion cmd/kuberoCli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,50 @@ package kuberoCli

import (
"encoding/json"
"fmt"
"kubero/pkg/kuberoApi"
"log"
"os"
"strings"

"github.com/i582/cfmt/cmd/cfmt"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

var AppCmd = &cobra.Command{
Use: "app",
Aliases: []string{"apps", "application", "applications", "a"},
Short: "List apps in a Pipeline",
Long: `Create a new app in a Pipeline.

If called without arguments, it will ask for all the required information`,
Run: func(cmd *cobra.Command, args []string) {

pipelinesList := getAllRemotePipelines()
fmt.Println(pipelinesList)
ensurePipelineIsSet(pipelinesList)
//ensureStageNameIsSet()
//ensureAppNameIsSet()
appsList()

},
}

func init() {
rootCmd.AddCommand(AppCmd)
AppCmd.PersistentFlags().StringVarP(&pipelineName, "pipeline", "p", "", "name of the pipeline")
}

func appsList() {

pipelineResp, _ := api.GetPipelineApps(pipelineName)

var pl Pipeline
jsonUnmarshalErr := json.Unmarshal(pipelineResp.Body(), &pl)
if jsonUnmarshalErr != nil {
log.Fatal(jsonUnmarshalErr)
log.Fatal("appsList ", jsonUnmarshalErr)
return
}

Expand Down
121 changes: 121 additions & 0 deletions cmd/kuberoCli/appCreate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package kuberoCli

import (
"fmt"
"kubero/pkg/kuberoApi"
"os"
"strconv"

"github.com/i582/cfmt/cmd/cfmt"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
)

var createAppCmd = &cobra.Command{
Use: "create",
Short: "Create a new app in a Pipeline",
Long: `Create a new app in a Pipeline.

If called without arguments, it will ask for all the required information`,
Run: func(cmd *cobra.Command, args []string) {

pipelinesList := getAllRemotePipelines()
ensurePipelineIsSet(pipelinesList)
ensureStageNameIsSet()
ensureAppNameIsSet()
createRemoteApp()

},
}

func init() {
AppCmd.AddCommand(createAppCmd)
createAppCmd.Flags().StringVarP(&pipelineName, "pipeline", "p", "", "Name of the pipeline")
createAppCmd.Flags().StringVarP(&stageName, "stage", "s", "", "Name of the stage")
createAppCmd.Flags().StringVarP(&appName, "app", "a", "", "Name of the app")
}

func appForm() kuberoApi.AppCRD {

var appCRD kuberoApi.AppCRD

pipelineConfig := loadPipelineConfig(pipelineName, false)

appCRD.APIVersion = "application.kubero.dev/v1alpha1"
appCRD.Kind = "KuberoApp"

appCRD.Spec.Name = appName
appCRD.Spec.Pipeline = pipelineName
appCRD.Spec.Phase = stageName

appCRD.Spec.Domain = promptLine("Domain", "", "")
gitURL := pipelineConfig.Spec.Git.Repository.SshUrl
if gitURL != "" {
appCRD.Spec.Branch = promptLine("Branch", gitURL+":", "main")
} else {
appCRD.Spec.Branch = promptLine("Branch", "", "main")
}

appCRD.Spec.Buildpack = pipelineConfig.Spec.Buildpack.Name

autodeploy := promptLine("Autodeploy", "[y,n]", "n")
if autodeploy == "Y" {
appCRD.Spec.Autodeploy = true
} else {
appCRD.Spec.Autodeploy = false
}

envCount, _ := strconv.Atoi(promptLine("Number of Env Vars", "", "0"))
appCRD.Spec.EnvVars = []string{}
for i := 0; i < envCount; i++ {
appCRD.Spec.EnvVars = append(appCRD.Spec.EnvVars, promptLine("Env Var", "", ""))
}

appCRD.Spec.Image.ContainerPort, _ = strconv.Atoi(promptLine("Container Port", "8080", "8080"))

appCRD.Spec.Web = kuberoApi.Web{}
appCRD.Spec.Web.ReplicaCount, _ = strconv.Atoi(promptLine("Web Pods", "1", "1"))

appCRD.Spec.Worker = kuberoApi.Worker{}
appCRD.Spec.Worker.ReplicaCount, _ = strconv.Atoi(promptLine("Worker Pods", "0", "0"))

return appCRD
}

func createRemoteApp() {
appCRD := appForm()

_, err := api.DeployApp(pipelineName, stageName, appName, appCRD)
if err != nil {
fmt.Println(err)
return
} else {
_, _ = cfmt.Print("\n{{Created appCRD}}::green\n\n")
}

}

func creatIacApp() {

appCRD := appForm()

writeAppYaml(appCRD)

_, _ = cfmt.Println("\n\n{{Created appCRD.yaml}}::green")
}

func writeAppYaml(appCRD kuberoApi.AppCRD) {
// write pipeline.yaml
yamlData, err := yaml.Marshal(&appCRD)

if err != nil || appCRD.Spec.Name == "" {
panic("Unable to write data into the file")
}

fileName := ".kubero/" + appCRD.Spec.Pipeline + "/" + appCRD.Spec.Phase + "/" + appCRD.Spec.Name + ".yaml"

err = os.WriteFile(fileName, yamlData, 0644)
if err != nil {
panic("Unable to write data into the file")
}
}
45 changes: 45 additions & 0 deletions cmd/kuberoCli/appDelete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package kuberoCli

/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/

import (
"github.com/spf13/cobra"
)

// appCmd represents the app command
var deleteAppCmd = &cobra.Command{
Use: "delete",
Aliases: []string{"d"},
Short: "Deletes an app from the cluster",
Long: `Use the app subcommand to undeploy your apps from the cluster`,
Run: func(cmd *cobra.Command, args []string) {
downApp()
},
}

func init() {
AppCmd.AddCommand(deleteAppCmd)
deleteAppCmd.Flags().StringVarP(&pipelineName, "pipeline", "p", "", "name of the pipeline")
deleteAppCmd.Flags().StringVarP(&stageName, "stage", "s", "", "Name of the stage [test|stage|production]")
deleteAppCmd.Flags().StringVarP(&appName, "app", "a", "", "name of the app")
}

func downApp() {

pipelinesList := getAllRemotePipelines()
ensurePipelineIsSet(pipelinesList)

ensureStageNameIsSet()

appsList := getAllRemoteApps()
ensureAppNameIsSelected(appsList)

confirmationLine("Are you sure you want to undeploy the app "+appName+" from "+stageName+" in "+pipelineName+"?", "y")

_, err := api.DeleteApp(pipelineName, stageName, appName)
if err != nil {
panic("Unable to undeploy App")
}
}
Loading