Skip to content

Commit 73f114b

Browse files
authored
Release/0 5 1 (#73)
* Modified docs Signed-off-by: niki-1905 <nikkikokitkar@gmail.com> * Remove jmeter submodule, literatebee key, and empty vendor folder. Signed-off-by: Arush Salil <me@aru.sh> * Update Dockerfile Signed-off-by: Arush Salil <me@aru.sh> * Update Readme Signed-off-by: Arush Salil <me@aru.sh> * Update AWS documentation Signed-off-by: Arush Salil <me@aru.sh> * Add lifecycle documentation. Signed-off-by: Arush Salil <me@aru.sh> * Fix typo Signed-off-by: Arush Salil <me@aru.sh> * Refactor and add tests Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * Update documentation * Update .gitignore * add pkg provisioner * Update Makefile * TK8-47 add infrastructure only flag https://kubernauts.atlassian.net/browse/TK8-47
1 parent b67a266 commit 73f114b

39 files changed

+409
-1350
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ golint
3232

3333
# Ignore personal configs
3434
config.yml
35-
config.yaml
35+
config.yaml
36+
.scannerwork
37+
report.xml
38+
coverage.xml

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ default: bin
77

88
.PHONY: bin
99
bin:
10+
go get -u ./...
1011
go build ${BUILD_FLAGS} -o tk8 main.go
1112

1213
.PHONY: install
@@ -28,10 +29,21 @@ lint:
2829
vet:
2930
go vet $(PKGS)
3031

32+
.PHONY: test
33+
test:
34+
gocov test ./... | gocov-xml > coverage.xml
35+
gometalinter.v1 --checkstyle > report.xml
36+
sonar-scanner \
37+
-Dsonar.projectKey=mmmac \
38+
-Dsonar.host.url=http://localhost:9000 \
39+
-Dsonar.login=616782f26ee441b650bd709eff9f8acee0a0fd75 \
40+
-X
41+
42+
.PHONY: release
3143
release:
44+
go get -u ./...
3245
./scripts/check-gofmt.sh
33-
go build -o golint github.com/golang/lint/golint
34-
./golint $(PKGS)
46+
golint $(PKGS)
3547
go vet $(PKGS)
3648
go build ${BUILD_FLAGS} -o tk8 main.go
3749
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build ${BUILD_FLAGS} -o tk8-darwin-amd64 main.go

README_old.md

Lines changed: 0 additions & 87 deletions
This file was deleted.

cmd/addon.go renamed to cmd/cli/addon.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/spf13/cobra"
2525
)
2626

27-
var monitor, rancher bool
27+
var Addon addon.Addon
2828

2929
// addonCmd represents the addon command
3030
var addonCmd = &cobra.Command{
@@ -51,7 +51,7 @@ var addonInstallCmd = &cobra.Command{
5151
cmd.Help()
5252
os.Exit(1)
5353
}
54-
addon.InstallAddon(args[0])
54+
Addon.Install(args[0])
5555
},
5656
}
5757

@@ -66,23 +66,23 @@ var addonDestroyCmd = &cobra.Command{
6666
cmd.Help()
6767
os.Exit(1)
6868
}
69-
addon.DestroyAddon(args[0])
69+
Addon.Destroy(args[0])
7070
},
7171
}
7272

7373
// addonCmd represents the addon command
7474
var addonCreateCmd = &cobra.Command{
7575
Use: "create [addon name]",
7676
Short: "create a new kubernetes addon packages on your local machine for development",
77-
Long: `Create your own addons for your kubernetes cluster.
77+
Long: `Create your own addons for your kubernetes cluster.
7878
This command will prepare a example package in a folder with the addon name`,
7979
Args: cobra.MinimumNArgs(1),
8080
Run: func(cmd *cobra.Command, args []string) {
8181
if len(args) == 0 {
8282
cmd.Help()
8383
os.Exit(1)
8484
}
85-
addon.PrepareExample(args[0])
85+
Addon.Create(args[0])
8686
},
8787
}
8888

@@ -97,15 +97,16 @@ var addonGetCmd = &cobra.Command{
9797
cmd.Help()
9898
os.Exit(1)
9999
}
100-
addon.GetAddon(args[0])
100+
Addon.Get(args[0])
101101
},
102102
}
103103

104+
/*
105+
* This function gets the path to the kubeconfig, cluster details and auth
106+
* for using with the kubectl.
107+
* Then use this to install the addon on this cluster
108+
*/
104109
func getKubeConfig() string {
105-
/* This function gets the path to the kubeconfig, cluster details and auth
106-
for using with the kubectl.
107-
Then use this to install the addon on this cluster
108-
*/
109110
fmt.Println("Please enter the path to your kubeconfig:")
110111
var kubeConfig string
111112
fmt.Scanln(&kubeConfig)
@@ -117,10 +118,11 @@ func getKubeConfig() string {
117118
return kubeConfig
118119
}
119120

121+
/*
122+
* This function is used to check the whether kubectl command is installed &
123+
* it works with the kubeConfig provided
124+
*/
120125
func checkKubectl(kubeConfig string) {
121-
/*This function is used to check the whether kubectl command is installed &
122-
it works with the kubeConfig provided
123-
*/
124126
kerr, err := exec.LookPath("kubectl")
125127
if err != nil {
126128
log.Fatal("kubectl command not found, kindly check")
File renamed without changes.

cmd/completion.go renamed to cmd/cli/completion.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"fmt"
1919
"os"
2020

21-
"github.com/kubernauts/tk8/internal/cluster"
21+
"github.com/kubernauts/tk8/pkg/common"
2222
"github.com/spf13/cobra"
2323
)
2424

@@ -47,11 +47,11 @@ var bashCompletion = &cobra.Command{
4747
Long: `It will produce the bash completion script which can later be used for the autocompletion of commands in Bash.`,
4848
Run: func(cmd *cobra.Command, args []string) {
4949
script, err := os.OpenFile("tk8.sh", os.O_CREATE|os.O_WRONLY, 0600)
50-
cluster.ErrorCheck("Error creating autocompletion script file.", err)
50+
common.ErrorCheck("Error creating autocompletion script file.", err)
5151
defer script.Close()
5252

5353
err = rootCmd.GenBashCompletion(script)
54-
cluster.ErrorCheck("Error writing to Bash script file", err)
54+
common.ErrorCheck("Error writing to Bash script file", err)
5555
fmt.Printf("Successfully created the Bash completion script. Move the 'tk8.sh' file under /etc/bash_completion.d/ folder and login again.")
5656
},
5757
}
@@ -63,12 +63,12 @@ var zshCompletion = &cobra.Command{
6363
Long: `It will produce the bash completion script which can later be used for the autocompletion of commands in Zsh.`,
6464
Run: func(cmd *cobra.Command, args []string) {
6565
script, err := os.OpenFile("tk8.plugin.zsh", os.O_CREATE|os.O_WRONLY, 0600)
66-
cluster.ErrorCheck("Error creating autocompletion script file.", err)
66+
common.ErrorCheck("Error creating autocompletion script file.", err)
6767
defer script.Close()
6868

6969
fmt.Fprintf(script, "__tk8_tool_complete() {\n")
7070
err = rootCmd.GenZshCompletion(script)
71-
cluster.ErrorCheck("Error writing to Zsh plugin file", err)
71+
common.ErrorCheck("Error writing to Zsh plugin file", err)
7272
fmt.Fprintf(script, "}\ncompdef __tk8_tool_complete tk8")
7373
fmt.Printf("Successfully created the Zsh plugin. Move the 'tk8.plugin.zsh' file under your plugins folder and login again.")
7474
},

cmd/provisioner.go renamed to cmd/cli/provisioner.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,20 @@ import (
1919
"os"
2020
"strings"
2121

22-
"github.com/kubernauts/tk8/internal"
23-
2422
aws "github.com/kubernauts/tk8-provisioner-aws"
2523
azure "github.com/kubernauts/tk8-provisioner-azure"
2624
baremetal "github.com/kubernauts/tk8-provisioner-baremetal"
2725
eks "github.com/kubernauts/tk8-provisioner-eks"
2826
nutanix "github.com/kubernauts/tk8-provisioner-nutanix"
2927
openstack "github.com/kubernauts/tk8-provisioner-openstack"
30-
"github.com/kubernauts/tk8/internal/cluster"
28+
"github.com/kubernauts/tk8/pkg/common"
29+
"github.com/kubernauts/tk8/pkg/provisioner"
3130

3231
"github.com/spf13/cobra"
3332
)
3433

3534
var name string
36-
var provisioners = map[string]cluster.Provisioner{
35+
var provisioners = map[string]provisioner.Provisioner{
3736
"aws": aws.NewAWS(),
3837
"azure": azure.NewAzure(),
3938
"baremetal": baremetal.NewBaremetal(),
@@ -52,7 +51,9 @@ var provisionerInstallCmd = &cobra.Command{
5251
Run: func(cmd *cobra.Command, args []string) {
5352
if val, ok := provisioners[args[0]]; ok {
5453
val.Init(args[1:])
55-
val.Setup(args[1:])
54+
if !provisioner.IOnly {
55+
val.Setup(args[1:])
56+
}
5657
}
5758
},
5859
}
@@ -160,10 +161,11 @@ func init() {
160161
clusterCmd.AddCommand(provisionerUpgradeCmd)
161162
clusterCmd.AddCommand(provisionerDestroyCmd)
162163

163-
provisionerInstallCmd.Flags().StringVar(&cluster.Name, "name", cluster.Name, "name of the cluster workspace")
164-
provisionerScaleCmd.Flags().StringVar(&cluster.Name, "name", cluster.Name, "name of the cluster workspace")
165-
provisionerResetCmd.Flags().StringVar(&cluster.Name, "name", cluster.Name, "name of the cluster workspace")
166-
provisionerRemoveCmd.Flags().StringVar(&cluster.Name, "name", cluster.Name, "name of the cluster workspace")
167-
provisionerUpgradeCmd.Flags().StringVar(&cluster.Name, "name", cluster.Name, "name of the cluster workspace")
168-
provisionerDestroyCmd.Flags().StringVar(&cluster.Name, "name", cluster.Name, "name of the cluster workspace")
164+
provisionerInstallCmd.Flags().StringVar(&common.Name, "name", common.Name, "name of the cluster workspace")
165+
provisionerInstallCmd.Flags().BoolVarP(&provisioner.IOnly, "ionly", "i", provisioner.IOnly, "setup only the infrastructure")
166+
provisionerScaleCmd.Flags().StringVar(&common.Name, "name", common.Name, "name of the cluster workspace")
167+
provisionerResetCmd.Flags().StringVar(&common.Name, "name", common.Name, "name of the cluster workspace")
168+
provisionerRemoveCmd.Flags().StringVar(&common.Name, "name", common.Name, "name of the cluster workspace")
169+
provisionerUpgradeCmd.Flags().StringVar(&common.Name, "name", common.Name, "name of the cluster workspace")
170+
provisionerDestroyCmd.Flags().StringVar(&common.Name, "name", common.Name, "name of the cluster workspace")
169171
}
File renamed without changes.
File renamed without changes.

docs/en/provisioner/aws/lifecycle.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,18 @@ To reset the provisioned cluster run:
3333
tk8 cluster reset aws
3434
```
3535

36-
Once executed a confirmation would be needed to remove Kubernetes from your infrastructure..
36+
Once executed the current kubernetes installation get removed and a new setup will run.
37+
38+
## Remove the cluster
39+
40+
Make sure you are in the same directory where you executed `tk8 cluster install aws` with the inventory directory.
41+
If you use a different workspace name with the --name flag please provide it on resetting too.
42+
43+
To reset the provisioned cluster run:
44+
45+
```shell
46+
tk8 cluster remove aws
47+
```
48+
49+
Once executed the current kubernetes installation get removed from the infrastructure.
50+

internal/addon/common.go

Lines changed: 0 additions & 33 deletions
This file was deleted.

internal/addon/create.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)