Skip to content

Commit e52de92

Browse files
authored
Develop (#88)
* 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 * Release/0 5 1 (#74) * Update Documentation on master branch (#72) * 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> * TK8-47 add infrastructure only flag https://kubernauts.atlassian.net/browse/TK8-47 * Bug/version (#75) * #67 | modify | remove not needed requirements Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * #66 | fix | Getting started link Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * #66 | modify | change path relative Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * Update Documentation on master branch (#72) * 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> Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * 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 Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * BUG | Fix Version display The version is not display like accepted This will fix it Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * Add rke provisioner related variables Signed-off-by: Shantanu Deshpande <shantanud106@gmail.com> * RKE provisioner changes (#81) * Add documentation for using rke provisioner Signed-off-by: Shantanu Deshpande <shantanud106@gmail.com> * Add changes for rke provisioner configuration Signed-off-by: Shantanu Deshpande <shantanud106@gmail.com> * update the documentation add tk8 addon install rancher Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * move common stuff to the main pkg Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * Fix doc path rke Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * RKE region issue fix Signed-off-by: Shantanu Deshpande <shantanud106@gmail.com> * Fixing typo (#84) Signed-off-by: Imran Pochi <pochiimran@yahoo.co.in> * Bug/addon install bug (#87) * Release 0.6.0 (#83) * 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 * Release/0 5 1 (#74) * Update Documentation on master branch (#72) * 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> * TK8-47 add infrastructure only flag https://kubernauts.atlassian.net/browse/TK8-47 * Bug/version (#75) * #67 | modify | remove not needed requirements Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * #66 | fix | Getting started link Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * #66 | modify | change path relative Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * Update Documentation on master branch (#72) * 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> Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * 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 Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * BUG | Fix Version display The version is not display like accepted This will fix it Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * Add rke provisioner related variables Signed-off-by: Shantanu Deshpande <shantanud106@gmail.com> * RKE provisioner changes (#81) * Add documentation for using rke provisioner Signed-off-by: Shantanu Deshpande <shantanud106@gmail.com> * Add changes for rke provisioner configuration Signed-off-by: Shantanu Deshpande <shantanud106@gmail.com> * update the documentation add tk8 addon install rancher Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * move common stuff to the main pkg Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * Fix doc path rke Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * RKE region issue fix Signed-off-by: Shantanu Deshpande <shantanud106@gmail.com> * add signed #86 | BUG | Addon | fx addon bug Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * Tweaking addon addition/removal functionality (#89) * Adding functionality for addons where different main.sh is required for removal and installation. example: helm where installation and removal of tiller componenet happens with hte helm of helm init and helm reset and not yaml files Signed-off-by: Imran Pochi <pochiimran@yahoo.co.in> * Cleanup - removing unnecessary print statements Signed-off-by: Imran Pochi <pochiimran@yahoo.co.in>
1 parent b8e4219 commit e52de92

File tree

5 files changed

+89
-43
lines changed

5 files changed

+89
-43
lines changed

cmd/cli/addon.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
)
2626

2727
var Addon addon.Addon
28+
var scope string
2829

2930
// addonCmd represents the addon command
3031
var addonCmd = &cobra.Command{
@@ -51,7 +52,7 @@ var addonInstallCmd = &cobra.Command{
5152
cmd.Help()
5253
os.Exit(1)
5354
}
54-
Addon.Install(args[0])
55+
Addon.Install(args[0], scope)
5556
},
5657
}
5758

@@ -66,7 +67,7 @@ var addonDestroyCmd = &cobra.Command{
6667
cmd.Help()
6768
os.Exit(1)
6869
}
69-
Addon.Destroy(args[0])
70+
Addon.Destroy(args[0], scope)
7071
},
7172
}
7273

@@ -144,4 +145,7 @@ func init() {
144145
addonCmd.AddCommand(addonDestroyCmd)
145146

146147
addonCmd.PersistentFlags().StringVar(&addon.KubeConfig, "kubeconfig", "", "kubeconfig path")
148+
addonInstallCmd.Flags().StringVarP(&scope, "scope", "s", "", "Namespace scope in which the addon is installed")
149+
addonDestroyCmd.Flags().StringVarP(&scope, "scope", "s", "", "Namespace scope in which the installed addon is to be destroyed")
150+
147151
}

cmd/cli/provisioner.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var provisioners = map[string]provisioner.Provisioner{
4444
}
4545

4646
var provisionerInstallCmd = &cobra.Command{
47-
Use: "install [" + GetAvaibleProvisioner() + "]",
47+
Use: "install [" + GetAvailableProvisioner() + "]",
4848
TraverseChildren: true,
4949

5050
Short: "install the infrastructure",
@@ -61,7 +61,7 @@ var provisionerInstallCmd = &cobra.Command{
6161
}
6262

6363
var provisionerScaleCmd = &cobra.Command{
64-
Use: "scale [" + GetAvaibleProvisioner() + "]",
64+
Use: "scale [" + GetAvailableProvisioner() + "]",
6565
TraverseChildren: true,
6666

6767
Short: "scale up the infrastructure",
@@ -75,7 +75,7 @@ var provisionerScaleCmd = &cobra.Command{
7575
}
7676

7777
var provisionerResetCmd = &cobra.Command{
78-
Use: "reset [" + GetAvaibleProvisioner() + "]",
78+
Use: "reset [" + GetAvailableProvisioner() + "]",
7979
TraverseChildren: true,
8080

8181
Short: "reset the infrastructure",
@@ -89,7 +89,7 @@ var provisionerResetCmd = &cobra.Command{
8989
}
9090

9191
var provisionerRemoveCmd = &cobra.Command{
92-
Use: "remove [" + GetAvaibleProvisioner() + "]",
92+
Use: "remove [" + GetAvailableProvisioner() + "]",
9393
TraverseChildren: true,
9494

9595
Short: "scale down the infrastructure",
@@ -103,7 +103,7 @@ var provisionerRemoveCmd = &cobra.Command{
103103
}
104104

105105
var provisionerDestroyCmd = &cobra.Command{
106-
Use: "destroy [" + GetAvaibleProvisioner() + "]",
106+
Use: "destroy [" + GetAvailableProvisioner() + "]",
107107
TraverseChildren: true,
108108
Short: "destroy the infrastructure",
109109
Long: `This command will destroy the infrastructure which was created with the install command.`,
@@ -116,7 +116,7 @@ var provisionerDestroyCmd = &cobra.Command{
116116
}
117117

118118
var provisionerUpgradeCmd = &cobra.Command{
119-
Use: "upgrade [" + GetAvaibleProvisioner() + "]",
119+
Use: "upgrade [" + GetAvailableProvisioner() + "]",
120120
TraverseChildren: true,
121121
Short: "Manages the infrastructure on AWS",
122122
Long: `
@@ -148,7 +148,7 @@ func ArgsValidation(cmd *cobra.Command, args []string) error {
148148

149149
}
150150

151-
func GetAvaibleProvisioner() string {
151+
func GetAvailableProvisioner() string {
152152
keys := make([]string, 0, len(provisioners))
153153
for k := range provisioners {
154154
keys = append(keys, k)

docs/de/provisioner/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Tk8 unterstützt verschiedene Platformen zur Bereitstellung eines Kubernetes Clustes.
44

5-
## Avaible Provisioner
5+
## Available Provisioner
66

77
* [AWS](aws/introduction.md)
88
* [EKS](aws/introduction.md)

docs/en/provisioner/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Tk8 supports different platforms to provide a Kubernetes Cluster.
44

5-
## Avaible Provisioner
5+
## Available Provisioner
66

77
* [AWS](aws/introduction.md)
88
* [EKS](aws/introduction.md)

internal/addon/main.go

Lines changed: 74 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,23 @@ func (a *Addon) Create(addonName string) (error, string) {
1919
return nil, addonName
2020
}
2121

22-
func (a *Addon) Destroy(addonNameOrGitPath string) (error, string) {
22+
func (a *Addon) Destroy(addonNameOrGitPath, scope string) (error, string) {
2323
_, addonName := a.Get(addonNameOrGitPath)
2424
fmt.Println("Destroying", strings.Replace(addonName, "tk8-addon-", "", 1))
25-
executeMainSh(addonName)
26-
deleteMainYml(addonName, "yml")
27-
deleteMainYml(addonName, "yaml")
25+
err := executeDestroySh(addonName, scope)
26+
if err != nil && !os.IsNotExist(err) {
27+
fmt.Println("Error in executing destroy.sh , aborting addon removal.")
28+
return err, addonName
29+
}
30+
if os.IsNotExist(err) {
31+
err = executeMainSh(addonName, scope)
32+
if err != nil {
33+
fmt.Println("Error in executing main.sh , aborting addon removal.")
34+
return err, addonName
35+
}
36+
}
37+
deleteMainYml(addonName)
2838
fmt.Println(strings.Replace(addonName, "tk8-addon-", "", 1), "destroy complete")
29-
3039
return nil, addonName
3140
}
3241

@@ -46,60 +55,89 @@ func (a *Addon) Get(addonNameOrGitPath string) (error, string) {
4655
fmt.Println("check if provided a url")
4756
if strings.Contains(addonNameOrGitPath, "http://") || strings.Contains(addonNameOrGitPath, "https://") {
4857
fmt.Println("Load Addon from external path", addonNameOrGitPath)
49-
common.CloneGit("./addons", addonNameOrGitPath, addonName)
50-
return nil, addonName
58+
err := common.CloneGit("./addons", addonNameOrGitPath, addonName)
59+
return err, extractAddonName(addonName)
5160
}
5261

5362
fmt.Println("Search addon on kubernauts space.")
54-
common.CloneGit("./addons", "https://github.com/kubernauts/tk8-addon-"+addonName, addonName)
55-
return nil, "tk8-addon-" + addonName
63+
err := common.CloneGit("./addons", "https://github.com/kubernauts/tk8-addon-"+addonName, addonName)
64+
return err, addonName
5665

5766
}
58-
return nil, "tk8-addon-" + addonName
67+
return nil, addonName
5968

6069
}
6170

62-
func (a *Addon) Install(addonNameOrGitPath string) {
71+
func (a *Addon) Install(addonNameOrGitPath string, scope string) {
6372
_, addonName := a.Get(addonNameOrGitPath)
64-
fmt.Println("Install", strings.Replace(addonName, "tk8-addon-", "", 1), addonName)
65-
66-
executeMainSh(addonName)
67-
applyMainYml(addonName, "yml")
68-
applyMainYml(addonName, "yaml")
69-
fmt.Println(addonName, "installation complete")
70-
73+
fmt.Println("Install", addonName)
74+
err := executeMainSh(addonName, scope)
75+
if err != nil {
76+
fmt.Println("Error in executing main.sh , aborting addon installation.")
77+
return
78+
}
79+
err = applyMainYml(addonName)
80+
if err == nil {
81+
fmt.Println(addonName, "installation complete")
82+
} else {
83+
fmt.Println(err)
84+
}
7185
}
7286

7387
// KubeConfig provide the path to the local kube config
7488
var KubeConfig string
7589

76-
func applyMainYml(addonName string, fileType string) {
90+
func applyMainYml(addonName string) error {
7791

7892
var cEx *exec.Cmd
79-
_, err := os.Stat("./addons/" + addonName + "/main." + fileType)
93+
fileName := "main.yml"
94+
if _, err := os.Stat("./addons/" + addonName + "/" + fileName); err != nil {
95+
fileName = "main.yaml"
96+
}
97+
_, err := os.Stat("./addons/" + addonName + "/" + fileName)
8098
if err == nil {
81-
fmt.Println("apply main." + fileType)
99+
fmt.Println("apply " + addonName + "/" + fileName)
82100
if len(KubeConfig) > 1 {
83-
cEx = exec.Command("kubectl", "--kubeconfig", KubeConfig, "apply", "-f", "main."+fileType)
101+
cEx = exec.Command("kubectl", "--kubeconfig", KubeConfig, "apply", "-f", fileName)
84102
} else {
85-
cEx = exec.Command("kubectl", "apply", "-f", "main."+fileType)
103+
cEx = exec.Command("kubectl", "apply", "-f", fileName)
86104
}
87105
cEx.Dir = "./addons/" + addonName
88106
printTerminalLog(cEx)
89107
cEx.Wait()
90-
return
108+
return nil
91109
}
110+
return err
92111
}
93112

94-
func executeMainSh(addonName string) {
113+
func executeMainSh(addonName, scope string) error {
95114
if _, err := os.Stat("./addons/" + addonName + "/main.sh"); err == nil {
96115
fmt.Println("execute main.sh")
97-
cEx := exec.Command("/bin/sh", "./main.sh")
116+
cEx := exec.Command("/bin/sh", "./main.sh", scope)
98117
cEx.Dir = "./addons/" + addonName
99118
printTerminalLog(cEx)
100-
cEx.Wait()
101-
return
119+
err = cEx.Wait()
120+
if err != nil {
121+
return err
122+
}
102123
}
124+
return nil
125+
}
126+
127+
func executeDestroySh(addonName, scope string) error {
128+
_, err := os.Stat("./addons/" + addonName + "/destroy.sh")
129+
if err != nil {
130+
return err
131+
}
132+
fmt.Println("execute destroy.sh")
133+
cEx := exec.Command("/bin/sh", "./destroy.sh", scope)
134+
cEx.Dir = "./addons/" + addonName
135+
printTerminalLog(cEx)
136+
err = cEx.Wait()
137+
if err != nil {
138+
return err
139+
}
140+
return nil
103141
}
104142

105143
func printTerminalLog(cEx *exec.Cmd) {
@@ -137,15 +175,19 @@ func cloneExample(addonName string) {
137175
common.CloneGit("./addons", "https://github.com/kubernauts/tk8-addon-develop", addonName)
138176
}
139177

140-
func deleteMainYml(addonName string, fileType string) {
178+
func deleteMainYml(addonName string) {
141179

142180
var cEx *exec.Cmd
143-
if _, err := os.Stat("./addons/" + addonName + "/main." + fileType); err == nil {
181+
fileName := "main.yml"
182+
if _, err := os.Stat("./addons/" + addonName + "/" + fileName); err != nil {
183+
fileName = "main.yaml"
184+
}
185+
if _, err := os.Stat("./addons/" + addonName + "/" + fileName); err == nil {
144186
fmt.Println("delete", strings.Replace(addonName, "tk8-addon-", "", 1), "from cluster")
145187
if len(KubeConfig) > 1 {
146-
cEx = exec.Command("kubectl", "--kubeconfig="+KubeConfig, "delete", "-f", "main."+fileType)
188+
cEx = exec.Command("kubectl", "--kubeconfig="+KubeConfig, "delete", "-f", fileName)
147189
} else {
148-
cEx = exec.Command("kubectl", "delete", "-f", "main."+fileType)
190+
cEx = exec.Command("kubectl", "delete", "-f", fileName)
149191
}
150192
cEx.Dir = "./addons/" + addonName
151193
printTerminalLog(cEx)

0 commit comments

Comments
 (0)