-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommandBuilder.go
156 lines (151 loc) · 5.33 KB
/
commandBuilder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package main
import (
"github.com/plunder-app/plunder/pkg/parlay/parlaytypes"
)
func uptimeCommand(host string) parlaytypes.TreasureMap {
return parlaytypes.TreasureMap{
Deployments: []parlaytypes.Deployment{
parlaytypes.Deployment{
Name: "Cluster-API provisioning",
Parallel: false,
Hosts: []string{host},
Actions: []parlaytypes.Action{
parlaytypes.Action{
ActionType: "command",
Command: "uptime",
Name: "Cluster-API provisioning uptime command",
},
},
},
},
}
}
func kubeCreateHostCommand(host string) parlaytypes.TreasureMap {
return parlaytypes.TreasureMap{
Deployments: []parlaytypes.Deployment{
parlaytypes.Deployment{
Name: "Cluster-API provisioning",
Parallel: false,
Hosts: []string{host},
Actions: []parlaytypes.Action{
parlaytypes.Action{
ActionType: "command",
Command: "tee /etc/apt/sources.list",
CommandPipeCmd: "echo -e \"deb http://uk.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse\"",
Name: "Cluster-API provisioning [reset Ubuntu repositories]",
CommandSudo: "root",
IgnoreFailure: true,
},
parlaytypes.Action{
ActionType: "command",
Command: "sudo apt-get update",
Name: "Cluster-API provisioning [Ubuntu package update]",
CommandSudo: "root",
IgnoreFailure: true,
},
parlaytypes.Action{
ActionType: "command",
Command: "apt-get install curl apt-transport-https gnupg-agent ca-certificates software-properties-common ethtool socat ebtables conntrack libnetfilter-conntrack3 -y",
Name: "Cluster-API provisioning [Ubuntu package installation]",
CommandSudo: "root",
},
parlaytypes.Action{
ActionType: "command",
Command: "tee /etc/apt/sources.list.d/docker.list",
CommandPipeCmd: "echo \"deb https://download.docker.com/linux/ubuntu xenial stable\"",
Name: "Cluster-API provisioning [set Docker Repository]",
CommandSudo: "root",
},
parlaytypes.Action{
ActionType: "command",
Command: "tee /etc/apt/sources.list.d/kubernetes.list",
CommandPipeCmd: "echo \"deb https://apt.kubernetes.io/ kubernetes-xenial main\"",
Name: "Cluster-API provisioning [set Kubernetes Repository]",
CommandSudo: "root",
},
parlaytypes.Action{
ActionType: "command",
Command: "curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -",
Name: "Cluster-API provisioning [add Docker GPG Key]",
CommandSudo: "root",
},
parlaytypes.Action{
ActionType: "command",
Command: "curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -",
Name: "Cluster-API provisioning [add Kubernetes GPG Key]",
CommandSudo: "root",
},
parlaytypes.Action{
ActionType: "command",
Command: "sudo apt-get update",
Name: "Cluster-API provisioning [Ubuntu package update]",
CommandSudo: "root",
IgnoreFailure: true,
},
parlaytypes.Action{
ActionType: "command",
Command: "apt-get install -y docker-ce=18.06.1~ce~3-0~ubuntu kubelet=1.14.1-00 kubeadm=1.14.1-00 kubectl=1.14.1-00 kubernetes-cni cri-tools",
Name: "Cluster-API provisioning [install Kubernetes (1.14.1) packages]",
CommandSudo: "root",
},
parlaytypes.Action{
ActionType: "command",
Command: "systemctl enable kubelet.service",
Name: "Cluster-API provisioning [enable Kubernetes Kubelet]",
CommandSudo: "root",
},
},
},
},
}
}
func kubeadmActions() []parlaytypes.Action {
return []parlaytypes.Action{
parlaytypes.Action{
ActionType: "command",
Command: "kubeadm init --kubernetes-version \"v1.14.1\" --pod-network-cidr=172.16.0.0/16",
Name: "Cluster-API provisioning [Initialise Kubernetes v1.14.1 Cluster]",
CommandSudo: "root",
},
parlaytypes.Action{
ActionType: "command",
Command: "rm -rf ~/.kube ; mkdir -p ~/.kube ; sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config ; sudo chown $(id -u):$(id -g) $HOME/.kube/config",
Name: "Cluster-API provisioning [Set kubeconfig]",
CommandSudo: "root",
},
}
}
func destroyCommand(host string) parlaytypes.TreasureMap {
return parlaytypes.TreasureMap{
Deployments: []parlaytypes.Deployment{
parlaytypes.Deployment{
Name: "Cluster-API provisioning",
Parallel: false,
Hosts: []string{host},
Actions: []parlaytypes.Action{
parlaytypes.Action{
ActionType: "command",
Command: "tee /proc/sys/kernel/sysrq",
CommandPipeCmd: "echo \"1\"",
Name: "Cluster-API machine [enable sysrq]",
CommandSudo: "root",
},
parlaytypes.Action{
ActionType: "command",
Command: "dd if=/dev/zero of=/dev/sda bs=1024k count=1000",
Name: "Cluster-API machine [disk wipe]",
CommandSudo: "root",
},
parlaytypes.Action{
ActionType: "command",
Command: "tee /proc/sysrq-trigger",
CommandPipeCmd: "echo \"b\"",
Name: "Cluster-API machine [reset]",
CommandSudo: "root",
Timeout: 2,
},
},
},
},
}
}