From 10dc4329db464483c4f56cbee8358187a13e3c62 Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Mon, 19 Nov 2018 21:30:08 +0100 Subject: [PATCH 01/17] Allow more args for the install addon command Signed-off-by: Waleed Gadelkareem --- cmd/cluster_addon.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cluster_addon.go b/cmd/cluster_addon.go index ed873aef..4ff6b305 100644 --- a/cmd/cluster_addon.go +++ b/cmd/cluster_addon.go @@ -51,7 +51,7 @@ func validateAddonSubCommand(cmd *cobra.Command, args []string) error { if idx == -1 { return fmt.Errorf("cluster '%s' not found", name) } - if len(args) != 1 { + if len(args) < 1 { return errors.New("exactly one argument expected") } addonName := args[0] From 7584930bacf898e08ccc6994b7bd256915f1b33f Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Mon, 19 Nov 2018 21:30:43 +0100 Subject: [PATCH 02/17] pass args to the addon Signed-off-by: Waleed Gadelkareem --- cmd/cluster_addon_install.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cluster_addon_install.go b/cmd/cluster_addon_install.go index 6cff7f87..b8a56111 100644 --- a/cmd/cluster_addon_install.go +++ b/cmd/cluster_addon_install.go @@ -44,7 +44,7 @@ var clusterAddonInstallCmd = &cobra.Command{ FatalOnError(err) addon := addonService.GetAddon(addonName) - addon.Install() + addon.Install(args...) log.Printf("addon %s successfully installed", addonName) }, From 8d402d8a49d11653e2fc246d09e2e48e7e1d4d77 Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Mon, 19 Nov 2018 21:35:29 +0100 Subject: [PATCH 03/17] add script runner addon Signed-off-by: Waleed Gadelkareem --- pkg/addons/addon_script_runner.go | 75 +++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 pkg/addons/addon_script_runner.go diff --git a/pkg/addons/addon_script_runner.go b/pkg/addons/addon_script_runner.go new file mode 100644 index 00000000..74be5f4c --- /dev/null +++ b/pkg/addons/addon_script_runner.go @@ -0,0 +1,75 @@ +package addons + +import ( + "fmt" + + "github.com/xetys/hetzner-kube/pkg/clustermanager" + "io/ioutil" + "log" + "time" +) + +//ScriptRunnerAddon installs script runner +type ScriptRunnerAddon struct { + masterNode *clustermanager.Node + communicator clustermanager.NodeCommunicator + nodes []clustermanager.Node +} + +//NewScriptRunnerAddon installs script runner to the cluster +func NewScriptRunnerAddon(provider clustermanager.ClusterProvider, communicator clustermanager.NodeCommunicator) ClusterAddon { + masterNode, _ := provider.GetMasterNode() + return ScriptRunnerAddon{masterNode: masterNode, communicator: communicator, nodes: provider.GetAllNodes()} +} + +func init() { + addAddon(NewScriptRunnerAddon) +} + +//Name returns the addons name +func (addon ScriptRunnerAddon) Name() string { + return "script-runner" +} + +//Requires returns a slice with the name of required addons +func (addon ScriptRunnerAddon) Requires() []string { + return []string{} +} + +//Description returns the addons description +func (addon ScriptRunnerAddon) Description() string { + return "Bash remote script runner" +} + +//URL returns the URL of the addons underlying project +func (addon ScriptRunnerAddon) URL() string { + return "https://www.gnu.org/software/bash/" +} + +//Install performs all steps to install the addon +func (addon ScriptRunnerAddon) Install(args ...string) { + + if len(args) < 1 { + log.Fatal("path argument is missing") + } + scriptPath := args[1] + scriptContents, err := ioutil.ReadFile(scriptPath) + FatalOnError(err) + + var output string + for _, node := range addon.nodes { + scriptRemotePath := "/tmp/script-" + time.Now().Format("20060102150405") + ".sh" + err = addon.communicator.WriteFile(node, scriptRemotePath, string(scriptContents), true) + FatalOnError(err) + + output, err = addon.communicator.RunCmd(node, "bash "+scriptRemotePath) + FatalOnError(err) + } + + fmt.Println("Script ran successfully:\n", output) +} + +//Uninstall performs all steps to remove the addon +func (addon ScriptRunnerAddon) Uninstall() { + fmt.Println("no uninstall for this addon") +} From 5e2623c19684e9df7044d39b2373daed2656bf73 Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Mon, 19 Nov 2018 21:56:45 +0100 Subject: [PATCH 04/17] Fix index out of range error Signed-off-by: Waleed Gadelkareem --- pkg/addons/addon_script_runner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/addons/addon_script_runner.go b/pkg/addons/addon_script_runner.go index 74be5f4c..dc797561 100644 --- a/pkg/addons/addon_script_runner.go +++ b/pkg/addons/addon_script_runner.go @@ -49,7 +49,7 @@ func (addon ScriptRunnerAddon) URL() string { //Install performs all steps to install the addon func (addon ScriptRunnerAddon) Install(args ...string) { - if len(args) < 1 { + if len(args) < 2 { log.Fatal("path argument is missing") } scriptPath := args[1] From 0ec83748555b2e0b196d68a37e8b0718c01d41e4 Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Wed, 21 Nov 2018 19:08:59 +0100 Subject: [PATCH 05/17] Add Node Group property --- pkg/clustermanager/types.go | 1 + pkg/hetzner/hetzner_provider.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/clustermanager/types.go b/pkg/clustermanager/types.go index 387ed00e..e6005506 100644 --- a/pkg/clustermanager/types.go +++ b/pkg/clustermanager/types.go @@ -4,6 +4,7 @@ package clustermanager type Node struct { Name string `json:"name"` Type string `json:"type"` + Group string `json:"group"` IsMaster bool `json:"is_master"` IsEtcd bool `json:"is_etcd"` IPAddress string `json:"ip_address"` diff --git a/pkg/hetzner/hetzner_provider.go b/pkg/hetzner/hetzner_provider.go index b0a62c34..03e9f9f4 100644 --- a/pkg/hetzner/hetzner_provider.go +++ b/pkg/hetzner/hetzner_provider.go @@ -41,7 +41,7 @@ func NewHetznerProvider(context context.Context, client *hcloud.Client, cluster } // CreateNodes creates hetzner nodes -func (provider *Provider) CreateNodes(suffix string, template clustermanager.Node, datacenters []string, count int, offset int) ([]clustermanager.Node, error) { +func (provider *Provider) CreateNodes(template clustermanager.Node, datacenters []string, count int, offset int) ([]clustermanager.Node, error) { sshKey, _, err := provider.client.SSHKey.Get(provider.context, template.SSHKeyName) if err != nil { @@ -52,7 +52,7 @@ func (provider *Provider) CreateNodes(suffix string, template clustermanager.Nod return nil, fmt.Errorf("we got some problem with the SSH-Key '%s', chances are you are in the wrong context", template.SSHKeyName) } - serverNameTemplate := fmt.Sprintf("%s-%s-@idx", provider.clusterName, suffix) + serverNameTemplate := fmt.Sprintf("%s-%s-@idx", provider.clusterName, template.Group) serverOptsTemplate := hcloud.ServerCreateOpts{ Name: serverNameTemplate, ServerType: &hcloud.ServerType{ @@ -127,20 +127,20 @@ func (provider *Provider) CreateNodes(suffix string, template clustermanager.Nod // CreateEtcdNodes creates nodes with type 'etcd' func (provider *Provider) CreateEtcdNodes(sshKeyName string, masterServerType string, datacenters []string, count int) ([]clustermanager.Node, error) { - template := clustermanager.Node{SSHKeyName: sshKeyName, IsEtcd: true, Type: masterServerType} - return provider.CreateNodes("etcd", template, datacenters, count, 0) + template := clustermanager.Node{SSHKeyName: sshKeyName, IsEtcd: true, Type: masterServerType, Group: "etcd"} + return provider.CreateNodes(template, datacenters, count, 0) } // CreateMasterNodes creates nodes with type 'master' func (provider *Provider) CreateMasterNodes(sshKeyName string, masterServerType string, datacenters []string, count int, isEtcd bool) ([]clustermanager.Node, error) { - template := clustermanager.Node{SSHKeyName: sshKeyName, IsMaster: true, Type: masterServerType, IsEtcd: isEtcd} - return provider.CreateNodes("master", template, datacenters, count, 0) + template := clustermanager.Node{SSHKeyName: sshKeyName, IsMaster: true, Type: masterServerType, IsEtcd: isEtcd, Group: "master"} + return provider.CreateNodes(template, datacenters, count, 0) } // CreateWorkerNodes create new worker node on provider func (provider *Provider) CreateWorkerNodes(sshKeyName string, workerServerType string, datacenters []string, count int, offset int) ([]clustermanager.Node, error) { - template := clustermanager.Node{SSHKeyName: sshKeyName, IsMaster: false, Type: workerServerType} - return provider.CreateNodes("worker", template, datacenters, count, offset) + template := clustermanager.Node{SSHKeyName: sshKeyName, IsMaster: false, Type: workerServerType, Group: "worker"} + return provider.CreateNodes(template, datacenters, count, offset) } // GetAllNodes retrieves all nodes From a138604c646f09e0fb249c0c65a7715fcaee6a1e Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Wed, 21 Nov 2018 19:11:37 +0100 Subject: [PATCH 06/17] Send node group and cluster info as bash params --- pkg/addons/addon_script_runner.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pkg/addons/addon_script_runner.go b/pkg/addons/addon_script_runner.go index dc797561..cfae4e70 100644 --- a/pkg/addons/addon_script_runner.go +++ b/pkg/addons/addon_script_runner.go @@ -7,19 +7,20 @@ import ( "io/ioutil" "log" "time" + "encoding/json" + "strings" ) //ScriptRunnerAddon installs script runner type ScriptRunnerAddon struct { - masterNode *clustermanager.Node communicator clustermanager.NodeCommunicator nodes []clustermanager.Node + cluster clustermanager.Cluster } //NewScriptRunnerAddon installs script runner to the cluster func NewScriptRunnerAddon(provider clustermanager.ClusterProvider, communicator clustermanager.NodeCommunicator) ClusterAddon { - masterNode, _ := provider.GetMasterNode() - return ScriptRunnerAddon{masterNode: masterNode, communicator: communicator, nodes: provider.GetAllNodes()} + return ScriptRunnerAddon{communicator: communicator, nodes: provider.GetAllNodes(), cluster: provider.GetCluster()} } func init() { @@ -56,13 +57,24 @@ func (addon ScriptRunnerAddon) Install(args ...string) { scriptContents, err := ioutil.ReadFile(scriptPath) FatalOnError(err) + clusterInfoBin, err := json.Marshal(addon.cluster) + FatalOnError(err) + + replacer := strings.NewReplacer("\n", "", "'", "\\'") + clusterInfo := replacer.Replace(string(clusterInfoBin)) + var output string for _, node := range addon.nodes { scriptRemotePath := "/tmp/script-" + time.Now().Format("20060102150405") + ".sh" err = addon.communicator.WriteFile(node, scriptRemotePath, string(scriptContents), true) FatalOnError(err) - output, err = addon.communicator.RunCmd(node, "bash "+scriptRemotePath) + output, err = addon.communicator.RunCmd( + node, + "bash "+ + scriptRemotePath+ + " "+node.Group+ + " '"+clusterInfo+"'") FatalOnError(err) } From 3899e7615ba98642ac4488f743fbcc3281d91a2f Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Wed, 21 Nov 2018 19:26:43 +0100 Subject: [PATCH 07/17] Fix formatting issue Signed-off-by: Waleed Gadelkareem --- pkg/addons/addon_script_runner.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/addons/addon_script_runner.go b/pkg/addons/addon_script_runner.go index cfae4e70..b0b1c6df 100644 --- a/pkg/addons/addon_script_runner.go +++ b/pkg/addons/addon_script_runner.go @@ -3,12 +3,12 @@ package addons import ( "fmt" + "encoding/json" "github.com/xetys/hetzner-kube/pkg/clustermanager" "io/ioutil" "log" - "time" - "encoding/json" "strings" + "time" ) //ScriptRunnerAddon installs script runner From 8a1bee2384cb53044825e5c0c2e08bf6b258cb5d Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Wed, 21 Nov 2018 23:30:58 +0100 Subject: [PATCH 08/17] move output inside the loop Signed-off-by: Waleed Gadelkareem --- pkg/addons/addon_script_runner.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/addons/addon_script_runner.go b/pkg/addons/addon_script_runner.go index b0b1c6df..57c5f8a1 100644 --- a/pkg/addons/addon_script_runner.go +++ b/pkg/addons/addon_script_runner.go @@ -63,22 +63,20 @@ func (addon ScriptRunnerAddon) Install(args ...string) { replacer := strings.NewReplacer("\n", "", "'", "\\'") clusterInfo := replacer.Replace(string(clusterInfoBin)) - var output string for _, node := range addon.nodes { scriptRemotePath := "/tmp/script-" + time.Now().Format("20060102150405") + ".sh" err = addon.communicator.WriteFile(node, scriptRemotePath, string(scriptContents), true) FatalOnError(err) - output, err = addon.communicator.RunCmd( + output, err := addon.communicator.RunCmd( node, "bash "+ scriptRemotePath+ " "+node.Group+ " '"+clusterInfo+"'") FatalOnError(err) + fmt.Println(node.Name+" "+node.IPAddress+": script ran successfully..\n", output) } - - fmt.Println("Script ran successfully:\n", output) } //Uninstall performs all steps to remove the addon From 5dc3f5562e0572e83a5831f102f61d129b93b2e8 Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Mon, 26 Nov 2018 21:06:57 +0100 Subject: [PATCH 09/17] update comments --- pkg/addons/addon_script_runner.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/addons/addon_script_runner.go b/pkg/addons/addon_script_runner.go index 57c5f8a1..44798f30 100644 --- a/pkg/addons/addon_script_runner.go +++ b/pkg/addons/addon_script_runner.go @@ -11,14 +11,14 @@ import ( "time" ) -//ScriptRunnerAddon installs script runner +// ScriptRunnerAddon installs script runner type ScriptRunnerAddon struct { communicator clustermanager.NodeCommunicator nodes []clustermanager.Node cluster clustermanager.Cluster } -//NewScriptRunnerAddon installs script runner to the cluster +// NewScriptRunnerAddon installs script runner to the cluster func NewScriptRunnerAddon(provider clustermanager.ClusterProvider, communicator clustermanager.NodeCommunicator) ClusterAddon { return ScriptRunnerAddon{communicator: communicator, nodes: provider.GetAllNodes(), cluster: provider.GetCluster()} } @@ -27,27 +27,27 @@ func init() { addAddon(NewScriptRunnerAddon) } -//Name returns the addons name +// Name returns the addons name func (addon ScriptRunnerAddon) Name() string { return "script-runner" } -//Requires returns a slice with the name of required addons +// Requires returns a slice with the name of required addons func (addon ScriptRunnerAddon) Requires() []string { return []string{} } -//Description returns the addons description +// Description returns the addons description func (addon ScriptRunnerAddon) Description() string { return "Bash remote script runner" } -//URL returns the URL of the addons underlying project +// URL returns the URL of the addons underlying project func (addon ScriptRunnerAddon) URL() string { return "https://www.gnu.org/software/bash/" } -//Install performs all steps to install the addon +// Install performs all steps to install the addon func (addon ScriptRunnerAddon) Install(args ...string) { if len(args) < 2 { @@ -79,7 +79,7 @@ func (addon ScriptRunnerAddon) Install(args ...string) { } } -//Uninstall performs all steps to remove the addon +// Uninstall performs all steps to remove the addon func (addon ScriptRunnerAddon) Uninstall() { fmt.Println("no uninstall for this addon") } From 94eee1c2ee0d6cc08f9b906c0d6f446b41c2a28c Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Mon, 26 Nov 2018 21:10:29 +0100 Subject: [PATCH 10/17] update error msg --- cmd/cluster_addon.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cluster_addon.go b/cmd/cluster_addon.go index 4ff6b305..8a605da6 100644 --- a/cmd/cluster_addon.go +++ b/cmd/cluster_addon.go @@ -52,7 +52,7 @@ func validateAddonSubCommand(cmd *cobra.Command, args []string) error { return fmt.Errorf("cluster '%s' not found", name) } if len(args) < 1 { - return errors.New("exactly one argument expected") + return errors.New("please add the addon name argument") } addonName := args[0] provider := hetzner.NewHetznerProvider(AppConf.Context, AppConf.Client, *cluster, AppConf.CurrentContext.Token) From 343b8792ad8981d94ce9c6557e28792b2d86401c Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Mon, 26 Nov 2018 21:19:46 +0100 Subject: [PATCH 11/17] use sprintf --- pkg/addons/addon_script_runner.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/addons/addon_script_runner.go b/pkg/addons/addon_script_runner.go index 44798f30..9579f14d 100644 --- a/pkg/addons/addon_script_runner.go +++ b/pkg/addons/addon_script_runner.go @@ -68,12 +68,10 @@ func (addon ScriptRunnerAddon) Install(args ...string) { err = addon.communicator.WriteFile(node, scriptRemotePath, string(scriptContents), true) FatalOnError(err) + output, err := addon.communicator.RunCmd( node, - "bash "+ - scriptRemotePath+ - " "+node.Group+ - " '"+clusterInfo+"'") + fmt.Sprintf("bash %s %s '%s'", scriptRemotePath, node.Group, clusterInfo)) FatalOnError(err) fmt.Println(node.Name+" "+node.IPAddress+": script ran successfully..\n", output) } From d27dc88cd0a6ee29e67505ca539628fa88c589c2 Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Mon, 26 Nov 2018 21:28:56 +0100 Subject: [PATCH 12/17] add rand number to the script --- pkg/addons/addon_script_runner.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/addons/addon_script_runner.go b/pkg/addons/addon_script_runner.go index 9579f14d..2a857941 100644 --- a/pkg/addons/addon_script_runner.go +++ b/pkg/addons/addon_script_runner.go @@ -2,6 +2,7 @@ package addons import ( "fmt" + "math/rand" "encoding/json" "github.com/xetys/hetzner-kube/pkg/clustermanager" @@ -64,11 +65,10 @@ func (addon ScriptRunnerAddon) Install(args ...string) { clusterInfo := replacer.Replace(string(clusterInfoBin)) for _, node := range addon.nodes { - scriptRemotePath := "/tmp/script-" + time.Now().Format("20060102150405") + ".sh" + scriptRemotePath := fmt.Sprintf("/tmp/script-%s-%d.sh", time.Now().Format("20060102150405"), rand.Int31()) err = addon.communicator.WriteFile(node, scriptRemotePath, string(scriptContents), true) FatalOnError(err) - output, err := addon.communicator.RunCmd( node, fmt.Sprintf("bash %s %s '%s'", scriptRemotePath, node.Group, clusterInfo)) From 159f4c1a2a5e0e70eb44d3635f0c2cf969d87a6a Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Mon, 26 Nov 2018 21:29:56 +0100 Subject: [PATCH 13/17] Update import order --- pkg/addons/addon_script_runner.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/addons/addon_script_runner.go b/pkg/addons/addon_script_runner.go index 2a857941..ca3dc5d9 100644 --- a/pkg/addons/addon_script_runner.go +++ b/pkg/addons/addon_script_runner.go @@ -1,15 +1,15 @@ package addons import ( - "fmt" - "math/rand" - "encoding/json" - "github.com/xetys/hetzner-kube/pkg/clustermanager" + "fmt" "io/ioutil" "log" + "math/rand" "strings" "time" + + "github.com/xetys/hetzner-kube/pkg/clustermanager" ) // ScriptRunnerAddon installs script runner From 7b764438912bfab2c7998d98262e86afb7521e60 Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Mon, 26 Nov 2018 21:32:14 +0100 Subject: [PATCH 14/17] use printf --- pkg/addons/addon_script_runner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/addons/addon_script_runner.go b/pkg/addons/addon_script_runner.go index ca3dc5d9..e1c25065 100644 --- a/pkg/addons/addon_script_runner.go +++ b/pkg/addons/addon_script_runner.go @@ -73,7 +73,7 @@ func (addon ScriptRunnerAddon) Install(args ...string) { node, fmt.Sprintf("bash %s %s '%s'", scriptRemotePath, node.Group, clusterInfo)) FatalOnError(err) - fmt.Println(node.Name+" "+node.IPAddress+": script ran successfully..\n", output) + fmt.Printf("%s %s: script ran successfully..\n%s\n", node.Name, node.IPAddress, output) } } From 167322aae653cd0c5b4e32b19b264d42e4e7d37e Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Tue, 27 Nov 2018 20:51:30 +0100 Subject: [PATCH 15/17] add docs --- README.md | 4 ++++ docs/script-runner-addon.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 docs/script-runner-addon.md diff --git a/README.md b/README.md index 514348ec..f10bc445 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,10 @@ You can install some addons to your cluster using the `cluster addon` sub-comman $ hetzner-kube cluster addon list ``` +## Script Runner Addon + +The addon lets you run bash scripts on the running nodes, check [Script Runner Guide](docs/script-runner-addon.md) for more info. + ### contributing new addons You want to add some cool stuff to hetzner-kube? It's quite easy! Learn how to add new addons in the [Developing Addons](docs/cluster-addons.md) documentation. diff --git a/docs/script-runner-addon.md b/docs/script-runner-addon.md new file mode 100644 index 00000000..8fc0887e --- /dev/null +++ b/docs/script-runner-addon.md @@ -0,0 +1,28 @@ +# Script Runner Addon Guide + +Script Runner lets you run a bash script on all your cluster nodes with one command. It uploads the bash script to each node then execute. The script will receive two arguments upon execution: +1) Node group, for example (master, worker, etcd) +2) Cluster info JSON config, which is similar to the hetzner-kube config found in `~/.hetzner-kube/config.json` + +### Example +hetzner-kube Command: +```bash +hetzner-kube cluster addon install --name demo script-runner /path/to/script.sh +``` +Example script.sh: +```bash + +#node group +echo $1 +#cluster info +echo $2 + +if [ "$1" == "worker" ]; then + apt-get install ceph-fs-common ceph-common -y +fi + + +echo $2 | python -c "import sys, json; print json.load(sys.stdin)[0]['name']" + +``` + From 7a6f3a5c174ce76701c272041d4baed69ada37ec Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Wed, 28 Nov 2018 20:08:38 +0100 Subject: [PATCH 16/17] apply some styling to docs --- docs/script-runner-addon.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/script-runner-addon.md b/docs/script-runner-addon.md index 8fc0887e..a69d1735 100644 --- a/docs/script-runner-addon.md +++ b/docs/script-runner-addon.md @@ -1,16 +1,18 @@ # Script Runner Addon Guide Script Runner lets you run a bash script on all your cluster nodes with one command. It uploads the bash script to each node then execute. The script will receive two arguments upon execution: -1) Node group, for example (master, worker, etcd) -2) Cluster info JSON config, which is similar to the hetzner-kube config found in `~/.hetzner-kube/config.json` +1. Node group, allowed values are `master`, `worker` and `etcd` +2. Cluster info JSON config, which is similar to the hetzner-kube config found in `~/.hetzner-kube/config.json` ### Example + hetzner-kube Command: ```bash hetzner-kube cluster addon install --name demo script-runner /path/to/script.sh ``` Example script.sh: ```bash +#!/bin/bash #node group echo $1 From c3147f3d1c05e454dfa71be8c561c200995119f8 Mon Sep 17 00:00:00 2001 From: Waleed Gadelkareem Date: Wed, 28 Nov 2018 20:10:49 +0100 Subject: [PATCH 17/17] fix typo --- docs/script-runner-addon.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/script-runner-addon.md b/docs/script-runner-addon.md index a69d1735..5a9a7b55 100644 --- a/docs/script-runner-addon.md +++ b/docs/script-runner-addon.md @@ -1,6 +1,6 @@ # Script Runner Addon Guide -Script Runner lets you run a bash script on all your cluster nodes with one command. It uploads the bash script to each node then execute. The script will receive two arguments upon execution: +Script Runner lets you run a bash script on all your cluster nodes with one command. It uploads the bash script to each node then execute it. The script will receive two arguments upon execution: 1. Node group, allowed values are `master`, `worker` and `etcd` 2. Cluster info JSON config, which is similar to the hetzner-kube config found in `~/.hetzner-kube/config.json`