sct 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitlab/merge_request_templates/DefinitionOfDone.md +12 -0
- data/lib/sct/commands/cluster.rb +124 -44
- data/lib/sct/version.rb +1 -1
- data/resources/corefile.yml +45 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2cc3d1d71c372b97290ca23b05a60bfeabd5240a81ed72ca16c433f1ee6dae5
|
4
|
+
data.tar.gz: e85b9c5e1643ee6d9eb794c54e187f9e7637ccb89c37943383cab8802938af7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42001ffa5ccd0cf558a1f38fde92e58908b7621e2b3a98c975cb2f40afd2ec34c6ce9fd1fa105b6cc6097143f272a2407d3f31573cd4429937babc490d103375
|
7
|
+
data.tar.gz: 23fbd32a6a5cc1cdaa0fc7b32006097a16bcd2bb4b5b543f57dc63e3ba6c806bcb163b0f7b1a332a70f747c208b9db81a72c3a1633b0d5a75b8b10295ea83d06
|
@@ -0,0 +1,12 @@
|
|
1
|
+
The Definition of a Done Code Review
|
2
|
+
====================================
|
3
|
+
| by _The Team_ |
|
4
|
+
|---------------------------------:|
|
5
|
+
|
6
|
+
- [ ] Approved (thumbs up) by three other team members (from different operating systems).
|
7
|
+
- [ ] Verified if it worked on all operating systems.
|
8
|
+
- [ ] Verified if it solved the problem.
|
9
|
+
- [ ] Verified if the help section is updated.
|
10
|
+
- [ ] Verified if it complied with Ruby code standards.
|
11
|
+
- [ ] Documentation is updated, 100% complete.
|
12
|
+
- [ ] SCT documentation.
|
data/lib/sct/commands/cluster.rb
CHANGED
@@ -5,11 +5,11 @@ module Sct
|
|
5
5
|
class ClusterCommand
|
6
6
|
|
7
7
|
IS_PUBLIC_COMMAND = true
|
8
|
-
SYNTAX = 'sct cluster up | sct cluster down | sct cluster reset | sct cluster update-config'
|
9
|
-
SUMMARY = '
|
10
|
-
EXAMPLE = 'sct cluster up | sct cluster down | sct cluster reset | sct cluster update-config'
|
11
|
-
EXAMPLE_DESCRIPTION = '
|
12
|
-
DESCRIPTION = "sct cluster allows you to start, stop, reset
|
8
|
+
SYNTAX = 'sct cluster up | sct cluster down | sct cluster setup | sct cluster reset | sct cluster update-config | sct cluster delete-stalled-pods'
|
9
|
+
SUMMARY = 'Perform actions on the minikube cluster.'
|
10
|
+
EXAMPLE = 'sct cluster up | sct cluster down | sct cluster setup | sct cluster reset | sct cluster update-config | sct cluster delete-stalled-pods'
|
11
|
+
EXAMPLE_DESCRIPTION = 'Perform actions on the minikube cluster.'
|
12
|
+
DESCRIPTION = "sct cluster allows you to start, stop, setup/reset, update the config, or delete the stalled pods of the Spend Cloud minikube cluster."
|
13
13
|
|
14
14
|
OPTIONS = []
|
15
15
|
|
@@ -23,22 +23,41 @@ module Sct
|
|
23
23
|
down
|
24
24
|
when "update-config"
|
25
25
|
update_config
|
26
|
-
when "reset"
|
26
|
+
when "setup", "reset"
|
27
27
|
reset
|
28
|
+
when "delete-stalled-pods"
|
29
|
+
delete_stalled_pods(feedback: true)
|
28
30
|
else
|
29
|
-
puts "Unknown or missing argument. Please run 'sct cluster up','sct cluster down'
|
31
|
+
puts "Unknown or missing argument. Please run 'sct cluster up', 'sct cluster down', 'sct cluster setup', 'sct cluster reset', 'sct cluster update-config', or 'sct cluster delete-stalled-pods'.".red
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
35
|
def up
|
34
36
|
start
|
35
|
-
|
36
|
-
|
37
|
+
run_command "kubectl delete pod -n kube-system #{pods("kube-system").map { |pod| pod[:name] if pod[:name].start_with? "registry-creds" } .compact.join(" ")}"
|
38
|
+
run_command "kubectl rollout status -n kube-system deployment/registry-creds"
|
37
39
|
post_start
|
38
40
|
end
|
39
41
|
|
40
42
|
def down
|
41
|
-
|
43
|
+
run_command "#{minikube} stop"
|
44
|
+
end
|
45
|
+
|
46
|
+
def reset
|
47
|
+
run_command "#{minikube} delete"
|
48
|
+
start
|
49
|
+
create_secrets
|
50
|
+
run_command "#{minikube} addons enable registry-creds"
|
51
|
+
run_command "#{minikube} addons enable ingress"
|
52
|
+
run_command "kubectl rollout status -n kube-system deployment/registry-creds"
|
53
|
+
run_command "kubectl rollout status -n kube-system deployment/nginx-ingress-controller"
|
54
|
+
wait_for_gcr_secret
|
55
|
+
run_command "kubectl apply -f ~/development/spend-cloud/k8s/ingress.yml"
|
56
|
+
wait_for_ingress_ip
|
57
|
+
run_command "kubectl apply -f ~/development/spend-cloud/k8s/dependencies.yml"
|
58
|
+
wait_for_pods
|
59
|
+
run_command "kubectl apply -f ~/development/spend-cloud/k8s/"
|
60
|
+
post_start
|
42
61
|
end
|
43
62
|
|
44
63
|
def update_config
|
@@ -50,59 +69,120 @@ module Sct
|
|
50
69
|
return puts "#{kube_file_path} doesn't exist".red
|
51
70
|
end
|
52
71
|
|
53
|
-
|
72
|
+
run_command "sed -e 's~\\\\~/~g' -e 's~C:~/mnt/c~g' < #{kube_file_path} > ~/.kube/minikube-config"
|
54
73
|
|
55
74
|
puts "#{kube_file_path} copied to ~/.kube/minikube-config".green
|
56
75
|
end
|
57
76
|
|
58
|
-
|
77
|
+
run_command "kubectl config use-context minikube"
|
78
|
+
|
79
|
+
run_command "kubectl replace -n kube-system -f #{File.expand_path('../../../resources/corefile.yml', __dir__)}"
|
80
|
+
run_command "kubectl delete pod -n kube-system #{pods("kube-system").map { |pod| pod[:name] if pod[:name].start_with? "coredns" } .compact.join(" ")}"
|
81
|
+
run_command "kubectl rollout status -n kube-system deployment/coredns"
|
59
82
|
end
|
60
83
|
|
61
|
-
def
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
system "kubectl create secret generic -n kube-system registry-creds-gcr --from-file=\"$(echo ~)/.config/gcloud/application_default_credentials.json\" --from-literal=gcrurl=\"https://eu.gcr.io\""
|
70
|
-
system "kubectl patch secret -n kube-system registry-creds-gcr -p='{\"metadata\": {\"labels\": { \"app\": \"registry-creds\", \"cloud\": \"gcr\", \"kubernetes.io/minikube-addons\": \"registry-creds\"}}}'"
|
71
|
-
system "kubectl create secret generic -n kube-system registry-creds-acr --from-literal ACR_PASSWORD=changeme --from-literal ACR_CLIENT_ID=changeme --from-literal ACR_URL=changeme"
|
72
|
-
system "kubectl patch secret -n kube-system registry-creds-acr -p='{\"metadata\": {\"labels\": { \"app\": \"registry-creds\", \"cloud\": \"acr\", \"kubernetes.io/minikube-addons\": \"registry-creds\"}}}'"
|
73
|
-
system "#{minikube} addons enable registry-creds"
|
74
|
-
system "#{minikube} addons enable ingress"
|
75
|
-
system "kubectl rollout status -n kube-system deployment/registry-creds"
|
76
|
-
system "kubectl rollout status -n kube-system deployment/nginx-ingress-controller"
|
77
|
-
wait_for_gcr_secret
|
78
|
-
system "kubectl apply -f ~/development/spend-cloud/k8s/"
|
79
|
-
post_start
|
84
|
+
def delete_stalled_pods(feedback: false)
|
85
|
+
stalled_pods = pods.select { |pod| pod[:stalled] }
|
86
|
+
|
87
|
+
if stalled_pods.empty?
|
88
|
+
puts "There are no stalled pods.".green if feedback
|
89
|
+
else
|
90
|
+
run_command "kubectl delete pods #{stalled_pods.map { |pod| pod[:name] } .join(" ")}"
|
91
|
+
end
|
80
92
|
end
|
81
93
|
|
82
94
|
def start
|
83
|
-
|
84
|
-
|
95
|
+
if Sct::Helpers.operatingSystem == Sct::Helpers::MAC_OS
|
96
|
+
run_command "#{minikube} start --cpus=$(sysctl -n hw.ncpu) --memory=8G"
|
97
|
+
else
|
98
|
+
run_command "#{minikube} start --cpus=$(cat /proc/cpuinfo | grep processor | wc -l) --memory=10G"
|
99
|
+
end
|
100
|
+
run_command "#{minikube} ssh -- 'sudo su -c \"echo 10048576 > /proc/sys/fs/inotify/max_user_watches\"'"
|
85
101
|
update_config
|
86
102
|
end
|
87
103
|
|
88
104
|
def post_start
|
89
|
-
|
90
|
-
|
91
|
-
puts "\n✔️ You can visit your environment at 👉 https://spend-cloud.spend.cloud.local 👌
|
105
|
+
wait_for_pods
|
106
|
+
run_command "sudo sct hostfile"
|
107
|
+
puts "\n✔️ You can visit your environment at 👉 https://spend-cloud.spend.cloud.local 👌"
|
108
|
+
end
|
109
|
+
|
110
|
+
def create_secrets
|
111
|
+
run_command "kubectl create secret generic gcloud-credentials --from-file=\"$(echo ~)/.config/gcloud/application_default_credentials.json\""
|
112
|
+
run_command "kubectl create secret generic -n kube-system registry-creds-dpr --from-literal DOCKER_PRIVATE_REGISTRY_PASSWORD=changeme --from-literal DOCKER_PRIVATE_REGISTRY_SERVER=changeme --from-literal DOCKER_PRIVATE_REGISTRY_USER=changeme"
|
113
|
+
run_command "kubectl patch secret -n kube-system registry-creds-dpr -p='{\"metadata\": {\"labels\": { \"app\": \"registry-creds\", \"cloud\": \"dpr\", \"kubernetes.io/minikube-addons\": \"registry-creds\"}}}'"
|
114
|
+
run_command "kubectl create secret generic -n kube-system registry-creds-ecr --from-literal AWS_ACCESS_KEY_ID=changeme --from-literal AWS_SECRET_ACCESS_KEY=changeme --from-literal AWS_SESSION_TOKEN=\"\" --from-literal aws-account=changeme --from-literal aws-assume-role=changeme --from-literal aws-region=changeme"
|
115
|
+
run_command "kubectl patch secret -n kube-system registry-creds-ecr -p='{\"metadata\": {\"labels\": { \"app\": \"registry-creds\", \"cloud\": \"ecr\", \"kubernetes.io/minikube-addons\": \"registry-creds\"}}}'"
|
116
|
+
run_command "kubectl create secret generic -n kube-system registry-creds-gcr --from-file=\"$(echo ~)/.config/gcloud/application_default_credentials.json\" --from-literal=gcrurl=\"https://eu.gcr.io\""
|
117
|
+
run_command "kubectl patch secret -n kube-system registry-creds-gcr -p='{\"metadata\": {\"labels\": { \"app\": \"registry-creds\", \"cloud\": \"gcr\", \"kubernetes.io/minikube-addons\": \"registry-creds\"}}}'"
|
118
|
+
run_command "kubectl create secret generic -n kube-system registry-creds-acr --from-literal ACR_PASSWORD=changeme --from-literal ACR_CLIENT_ID=changeme --from-literal ACR_URL=changeme"
|
119
|
+
run_command "kubectl patch secret -n kube-system registry-creds-acr -p='{\"metadata\": {\"labels\": { \"app\": \"registry-creds\", \"cloud\": \"acr\", \"kubernetes.io/minikube-addons\": \"registry-creds\"}}}'"
|
92
120
|
end
|
93
121
|
|
94
122
|
def wait_for_gcr_secret
|
95
123
|
puts "Waiting for Google Cloud Registry secret to become available...".yellow
|
96
124
|
|
97
|
-
while
|
98
|
-
|
125
|
+
while ! `kubectl get secrets`.include? "gcr-secret"
|
126
|
+
sleep 5
|
127
|
+
end
|
99
128
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
129
|
+
puts "Google Cloud Registry secret is now available.".green
|
130
|
+
end
|
131
|
+
|
132
|
+
def wait_for_ingress_ip
|
133
|
+
puts "Waiting for ingress IP to become available...".yellow
|
134
|
+
|
135
|
+
while `kubectl describe ingress | grep "Address" | awk '{print $2}'`.empty?
|
136
|
+
sleep 5
|
137
|
+
end
|
138
|
+
|
139
|
+
puts "Ingress IP is now available.".green
|
140
|
+
end
|
141
|
+
|
142
|
+
def wait_for_pods
|
143
|
+
puts "Waiting for pods to become ready...".yellow
|
144
|
+
|
145
|
+
while ! pods.all? { |pod| pod[:status] == "Running" }
|
146
|
+
delete_stalled_pods
|
147
|
+
|
148
|
+
sleep 5
|
149
|
+
end
|
150
|
+
|
151
|
+
puts "Pods are now ready.".green
|
152
|
+
end
|
153
|
+
|
154
|
+
def pods(namespace = nil)
|
155
|
+
if namespace
|
156
|
+
output = `kubectl get pods -n #{namespace}`
|
157
|
+
else
|
158
|
+
output = `kubectl get pods`
|
159
|
+
end
|
160
|
+
|
161
|
+
# split output lines
|
162
|
+
lines = output.split "\n"
|
163
|
+
|
164
|
+
# exclude first line (table header)
|
165
|
+
lines = lines[1..-1]
|
166
|
+
|
167
|
+
# get name and status of each pod
|
168
|
+
lines.map do |line|
|
169
|
+
columns = line.split(" ")
|
170
|
+
|
171
|
+
name = columns[0]
|
172
|
+
status = columns[2]
|
173
|
+
stalled = status == "ErrImagePull" || status == "ImagePullBackOff"
|
174
|
+
|
175
|
+
{
|
176
|
+
name: name,
|
177
|
+
status: status,
|
178
|
+
stalled: stalled
|
179
|
+
}
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def run_command command
|
184
|
+
if ! system command
|
185
|
+
raise command.red
|
106
186
|
end
|
107
187
|
end
|
108
188
|
|
data/lib/sct/version.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
apiVersion: v1
|
2
|
+
data:
|
3
|
+
Corefile: |
|
4
|
+
.:53 {
|
5
|
+
errors
|
6
|
+
health {
|
7
|
+
lameduck 5s
|
8
|
+
}
|
9
|
+
ready
|
10
|
+
kubernetes cluster.local in-addr.arpa ip6.arpa {
|
11
|
+
pods insecure
|
12
|
+
fallthrough in-addr.arpa ip6.arpa
|
13
|
+
ttl 30
|
14
|
+
}
|
15
|
+
prometheus :9153
|
16
|
+
forward . 8.8.8.8
|
17
|
+
cache 30
|
18
|
+
loop
|
19
|
+
reload
|
20
|
+
loadbalance
|
21
|
+
}
|
22
|
+
Corefile-backup: |
|
23
|
+
.:53 {
|
24
|
+
errors
|
25
|
+
health {
|
26
|
+
lameduck 5s
|
27
|
+
}
|
28
|
+
ready
|
29
|
+
kubernetes cluster.local in-addr.arpa ip6.arpa {
|
30
|
+
pods insecure
|
31
|
+
fallthrough in-addr.arpa ip6.arpa
|
32
|
+
ttl 30
|
33
|
+
}
|
34
|
+
prometheus :9153
|
35
|
+
forward . /etc/resolv.conf
|
36
|
+
cache 30
|
37
|
+
loop
|
38
|
+
reload
|
39
|
+
loadbalance
|
40
|
+
}
|
41
|
+
kind: ConfigMap
|
42
|
+
metadata:
|
43
|
+
creationTimestamp: null
|
44
|
+
name: coredns
|
45
|
+
selfLink: /api/v1/namespaces/kube-system/configmaps/coredns
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reshad Farid
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: class_interface
|
@@ -133,6 +133,7 @@ extra_rdoc_files: []
|
|
133
133
|
files:
|
134
134
|
- ".DS_Store"
|
135
135
|
- ".gitignore"
|
136
|
+
- ".gitlab/merge_request_templates/DefinitionOfDone.md"
|
136
137
|
- ".rspec"
|
137
138
|
- ".travis.yml"
|
138
139
|
- CODE_OF_CONDUCT.md
|
@@ -165,6 +166,7 @@ files:
|
|
165
166
|
- lib/sct/docker/yarn.rb
|
166
167
|
- lib/sct/setup/helpers.rb
|
167
168
|
- lib/sct/version.rb
|
169
|
+
- resources/corefile.yml
|
168
170
|
- sct.gemspec
|
169
171
|
homepage: https://gitlab.com/proactive-software/packages/sct
|
170
172
|
licenses:
|