mina-kubernetes 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/mina/kubernetes.rb +33 -13
- data/lib/mina/kubernetes/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a40a0047704517ce7a6e10daf7373ca3fe7398d0f655280992f3bb76ba8fff0
|
4
|
+
data.tar.gz: d7efeb94f504ece35b47829c927429b502112f511b91b552ca9c03df20d0e28d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3aaf4c5a80be9b84e75be8d2b15be9e79622ff58ed75e43ae90cde743ba944071707fee26d47e95ae6f8a504ceaa85225c18ed3c8eba5833bc3a6ff84ccbde04
|
7
|
+
data.tar.gz: 5045d3eeaae653fede93ae8bdba3631d8cdcd3297210ec8d8d3add742fbd9e5a0a062af5eaf85edd579604275e80cb89215ed97f3ad96cc84e50ba4cf2ffa67c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
|
+
## 2.7.0
|
2
|
+
|
3
|
+
*Enhancements*
|
4
|
+
|
5
|
+
- `kubernetes:command` allows to choose pod name
|
6
|
+
- `kubernetes:command` offers to kill & start fresh pod or start other pod with different name if pod already exists
|
7
|
+
|
1
8
|
## 2.6.0
|
2
9
|
|
10
|
+
*Fixes*
|
11
|
+
|
3
12
|
- Update krane gem to ~> 2.1 for compatibility with k8s >= 1.17
|
4
13
|
|
5
14
|
## 2.5.0
|
data/lib/mina/kubernetes.rb
CHANGED
@@ -84,34 +84,54 @@ end
|
|
84
84
|
|
85
85
|
def run_command(command, env_hash = {})
|
86
86
|
env = env_hash.collect{|k,v| "--env #{k}=#{v}" }.join(" ")
|
87
|
-
label = command.downcase.gsub(" ", "-").gsub(":", "-")+ "-#{`whoami`}".strip + "-#{fetch(:branch)}"
|
88
87
|
proxy_env = "HTTPS_PROXY=#{fetch(:proxy)}" if fetch(:proxy)
|
89
88
|
|
89
|
+
default_pod_name = "#{`whoami`.strip}-#{command}-#{fetch(:branch)}".downcase.gsub(" ", "-").gsub(":", "-")
|
90
|
+
pod_name = TTY::Prompt.new.ask("What name for the pod?", :value => default_pod_name)
|
91
|
+
|
90
92
|
run :local do
|
91
|
-
comment "Lauching
|
93
|
+
comment "Lauching pod #{color(pod_name, 36)} to run #{color(command, 36)}"
|
92
94
|
end
|
93
95
|
|
94
|
-
|
96
|
+
pod_run_command = "#{proxy_env} kubectl run #{pod_name} --rm -i --tty --restart=Never --overrides='#{fetch(:kubectl_pod_overrides)}' --context=#{fetch(:kubernetes_context)} --namespace=#{fetch(:namespace)} --image #{fetch(:image_repo)}:#{fetch(:image_tag)} #{env}"
|
97
|
+
running_pod_info = `#{proxy_env} kubectl get pod #{pod_name} -o json --ignore-not-found --context=#{fetch(:kubernetes_context)} --namespace=#{fetch(:namespace)}`
|
95
98
|
|
96
|
-
if
|
97
|
-
|
98
|
-
run_command = "#{proxy_env} kubectl run #{label} --rm -i --tty --restart=Never --overrides='#{fetch(:kubectl_pod_overrides)}' --context=#{fetch(:kubernetes_context)} --namespace=#{fetch(:namespace)} --image #{fetch(:image_repo)}:#{fetch(:image_tag)} #{env}"
|
99
|
-
system "#{run_command} -- #{command}"
|
99
|
+
if running_pod_info.empty?
|
100
|
+
wait_for_image_and_run_command("#{pod_run_command} -- #{command}")
|
100
101
|
else
|
101
|
-
started_at = Time.parse(JSON.parse(
|
102
|
-
choice = TTY::Prompt.new.select(
|
102
|
+
started_at = Time.parse(JSON.parse(running_pod_info)["status"]["startTime"]).strftime('%b %e, %H:%M')
|
103
|
+
choice = TTY::Prompt.new.select(
|
104
|
+
"Pod already exists, running since #{started_at} UTC, what would you like to do?",
|
105
|
+
{
|
106
|
+
"Reattach to its container" => :attach,
|
107
|
+
"Kill it and launch a fresh one" => :replace,
|
108
|
+
"Keep it and start one with a different name" => :other,
|
109
|
+
}
|
110
|
+
)
|
103
111
|
|
104
|
-
|
105
|
-
delete_command = "#{proxy_env} kubectl delete pod #{label} --context=#{fetch(:kubernetes_context)} --namespace=#{fetch(:namespace)}"
|
112
|
+
delete_command = "#{proxy_env} kubectl delete pod #{pod_name} --context=#{fetch(:kubernetes_context)} --namespace=#{fetch(:namespace)}"
|
106
113
|
|
107
|
-
|
114
|
+
case choice
|
115
|
+
when :attach
|
116
|
+
attach_command = "#{proxy_env} kubectl attach #{pod_name} -i --tty -c #{pod_name} --context=#{fetch(:kubernetes_context)} --namespace=#{fetch(:namespace)}"
|
108
117
|
system "#{attach_command} && #{delete_command}"
|
109
|
-
|
118
|
+
when :replace
|
110
119
|
system delete_command
|
120
|
+
run :local do
|
121
|
+
comment "Lauching Pod #{color(pod_name, 36)} to run #{color(command, 36)}"
|
122
|
+
end
|
123
|
+
wait_for_image_and_run_command("#{pod_run_command} -- #{command}")
|
124
|
+
when :other
|
125
|
+
run_command(command, env_hash)
|
111
126
|
end
|
112
127
|
end
|
113
128
|
end
|
114
129
|
|
130
|
+
def wait_for_image_and_run_command(command)
|
131
|
+
wait_until_image_ready(fetch(:image_tag))
|
132
|
+
system command
|
133
|
+
end
|
134
|
+
|
115
135
|
def apply_kubernetes_resources(options)
|
116
136
|
run :local do
|
117
137
|
comment "Applying all Kubernetes resources..."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mina-kubernetes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antoine Sabourin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
|
-
rubygems_version: 3.
|
144
|
+
rubygems_version: 3.1.2
|
145
145
|
signing_key:
|
146
146
|
specification_version: 4
|
147
147
|
summary: Mina plugin to streamline deployment of resources to Kubernetes cluster
|