vidar 0.2.1 → 0.3.0
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/Gemfile.lock +3 -3
- data/README.md +45 -11
- data/lib/vidar/k8s/container_status.rb +12 -8
- data/lib/vidar/k8s/pods.rb +23 -5
- data/lib/vidar/log.rb +4 -0
- data/lib/vidar/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd260ce9a8c7fb23a3e42a72af992f07c21d0ef5ffe30a3b96af32ffc8569d1b
|
4
|
+
data.tar.gz: 8cc9bf1d9068b7ac59e0b001a5f5f4fc45bc25f13baae05602e91697dcd9364c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dec4d553518f687ea22405189939222ebc442b5ffac32c800aa7610c8ad81a3352f621a8da065b3fef14529b45463266016f2a14403fa84cf02098431e401361
|
7
|
+
data.tar.gz: ab7f8daf3a3ad6754280b23a004599e91ce4a6d52381b13ca7feee7d3fb68f17296a7243a5329c69326d658a967177446773863d9fba24070303dc0e2a8091bd
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
vidar (0.
|
4
|
+
vidar (0.3.0)
|
5
5
|
colorize
|
6
6
|
faraday
|
7
7
|
thor (~> 0.20)
|
@@ -19,13 +19,13 @@ GEM
|
|
19
19
|
method_source (0.9.2)
|
20
20
|
multipart-post (2.1.1)
|
21
21
|
parallel (1.17.0)
|
22
|
-
parser (2.6.4.
|
22
|
+
parser (2.6.4.1)
|
23
23
|
ast (~> 2.4.0)
|
24
24
|
pry (0.12.2)
|
25
25
|
coderay (~> 1.1.0)
|
26
26
|
method_source (~> 0.9.0)
|
27
27
|
rainbow (3.0.0)
|
28
|
-
rake (
|
28
|
+
rake (13.0.0)
|
29
29
|
rspec (3.8.0)
|
30
30
|
rspec-core (~> 3.8.0)
|
31
31
|
rspec-expectations (~> 3.8.0)
|
data/README.md
CHANGED
@@ -3,9 +3,7 @@
|
|
3
3
|
|
4
4
|
# Vidar
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
+
Vidar is a set of docker & k8s deployment tools based on thor gem
|
9
7
|
|
10
8
|
## Installation
|
11
9
|
|
@@ -23,24 +21,60 @@ Or install it yourself as:
|
|
23
21
|
|
24
22
|
$ gem install vidar
|
25
23
|
|
24
|
+
|
25
|
+
#### Requirements :
|
26
|
+
|
27
|
+
* multistage `Dockerfile`, with 3 stages defined: `builder`, `runner`, `release`.
|
28
|
+
* `docker-compose.ci.yml` file with defined services for all 3 stages
|
29
|
+
* `vidar.yml` file to the project root directory, which following content:
|
30
|
+
|
31
|
+
```yml
|
32
|
+
# docker image name, required
|
33
|
+
image: gcr.io/renofiinfrastructure/vidar
|
34
|
+
# k8s namespace, required
|
35
|
+
namespace: borrower
|
36
|
+
# slack webhook url use to send deploy notifications, optional
|
37
|
+
slack_webhook_url: https://hooks.slack.com/services/....../....../....../
|
38
|
+
# github name used to conctruct slack notification content, required when slack_webhook_url is set
|
39
|
+
github: RenoFi/vidar
|
40
|
+
# Cluster url, used to conctruct slack notification content.
|
41
|
+
# Usually it displays k8 workloads filtered to current cluster and namespace.
|
42
|
+
# Similar to all other values it may contain references to others using mustache-like interpolation.
|
43
|
+
# Required when slack_webhook_url is set
|
44
|
+
cluster_url: "https://console.cloud.google.com/kubernetes/workload?cluster={{cluster_name}}&namespace={{namespace}}"
|
45
|
+
# known k8s cluster_names, used to construct regexp to fetch current cluster from kubectl context
|
46
|
+
# Required when slack_webhook_url is set
|
47
|
+
cluster_names: "cluster-A|cluster-B" cluster name from kubectl context
|
48
|
+
# docker-compose file, optional, default value: docker-compose.ci.yml
|
49
|
+
compose_file: docker-compose.ci.yml
|
50
|
+
# default_branch, optional, default value: master
|
51
|
+
default_branch: dev
|
52
|
+
```
|
53
|
+
|
26
54
|
## Usage
|
27
55
|
|
28
|
-
|
56
|
+
Available commands are:
|
57
|
+
|
58
|
+
`vidar pull` - pulls existing docker images from repository to levarage docker caching and make build faster
|
29
59
|
|
30
|
-
|
60
|
+
`vidar build` - builds docker images
|
31
61
|
|
32
|
-
|
62
|
+
`vidar cache` - caches intermediate stages
|
63
|
+
|
64
|
+
`vidar publish` - publishes docker images
|
65
|
+
|
66
|
+
`vidar release` - a set of `pull`, `build`, `cache` and `publish`
|
67
|
+
|
68
|
+
`vidar deploy` - deploys/applies release image with `REVISION` tag in given k8s namespace and cluster (unser the hood it's `kubectl set image` command). Before calling the command you must have `kubectl` context set. If you use GCP/GKE simply call `gcloud container clusters get-credentials you-cluser-name --zone=us-east4`. If you have `deploy-hook-template` job defined, it creates `deploy-hook` job with given `REVISION`.
|
69
|
+
|
70
|
+
`vidar monitor_deploy_status` - monitors if all containers are up and running, if slack_webhook_url if defined, sends a noficiation (on both failure and success).
|
33
71
|
|
34
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
35
72
|
|
36
73
|
## Contributing
|
37
74
|
|
38
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
75
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/RenoFi/vidar. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
39
76
|
|
40
77
|
## License
|
41
78
|
|
42
79
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
43
80
|
|
44
|
-
## Code of Conduct
|
45
|
-
|
46
|
-
Everyone interacting in the Vidar project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/vidar/blob/master/CODE_OF_CONDUCT.md).
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module Vidar
|
2
2
|
module K8s
|
3
3
|
class ContainerStatus
|
4
|
-
attr_reader :data, :state
|
4
|
+
attr_reader :data, :state, :namespace
|
5
5
|
|
6
6
|
def initialize(data)
|
7
7
|
@data = data
|
8
8
|
@state = data["state"]
|
9
|
+
@namespace = data["namespace"]
|
9
10
|
end
|
10
11
|
|
11
12
|
def name
|
@@ -21,23 +22,26 @@ module Vidar
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def to_text
|
24
|
-
parts = [
|
25
|
-
parts
|
25
|
+
parts = []
|
26
|
+
parts << namespace.to_s.ljust(20, " ")
|
27
|
+
parts << name.to_s.ljust(25, " ")
|
28
|
+
parts += text_statuses.map { |s| s.ljust(40, " ") }
|
29
|
+
"| #{parts.join(' | ')} |"
|
26
30
|
end
|
27
31
|
|
28
32
|
def text_statuses
|
29
33
|
if running?
|
30
34
|
if ready?
|
31
|
-
[ColorizedString["
|
35
|
+
[ColorizedString["Ready & Running"].light_green, "Started at: #{running_started_at}"]
|
32
36
|
else
|
33
|
-
[ColorizedString["
|
37
|
+
[ColorizedString["Not ready"].light_red, "Started at: #{running_started_at}"]
|
34
38
|
end
|
35
39
|
elsif terminated_completed?
|
36
|
-
[ColorizedString["
|
40
|
+
[ColorizedString["Terminated/Completed"].light_green, "Finished at: #{terminated_finished_at}"]
|
37
41
|
elsif terminated_error?
|
38
|
-
[ColorizedString["
|
42
|
+
[ColorizedString["Terminated/Error"].light_red]
|
39
43
|
elsif waiting?
|
40
|
-
[ColorizedString["
|
44
|
+
[ColorizedString["Waiting"].light_green]
|
41
45
|
else
|
42
46
|
[ColorizedString[state.inspect].light_red]
|
43
47
|
end
|
data/lib/vidar/k8s/pods.rb
CHANGED
@@ -11,29 +11,47 @@ module Vidar
|
|
11
11
|
return false
|
12
12
|
end
|
13
13
|
|
14
|
+
Log.line
|
15
|
+
|
14
16
|
container_statuses.each do |container_status|
|
15
17
|
container_status.print
|
16
18
|
end
|
17
19
|
|
18
|
-
Log.
|
20
|
+
Log.line
|
19
21
|
|
20
22
|
container_statuses.all?(&:ok?)
|
21
23
|
end
|
22
24
|
|
23
25
|
private
|
24
26
|
|
25
|
-
attr_reader :
|
27
|
+
attr_reader :namespace
|
26
28
|
|
27
29
|
def items
|
28
30
|
@items ||= begin
|
29
|
-
|
30
|
-
json = JSON.parse(output.strip)
|
31
|
+
json = JSON.parse(kubectl_get.strip)
|
31
32
|
json["items"] || []
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
36
|
+
def kubectl_get
|
37
|
+
if namespace == 'all'
|
38
|
+
`kubectl get pods --all-namespaces -o json`
|
39
|
+
else
|
40
|
+
`kubectl get pods -n #{namespace} -o json`
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
35
44
|
def container_statuses
|
36
|
-
@container_statuses ||=
|
45
|
+
@container_statuses ||= container_statuses_data.map { |status| ContainerStatus.new(status) }
|
46
|
+
end
|
47
|
+
|
48
|
+
def container_statuses_data
|
49
|
+
items.map do |i|
|
50
|
+
namespace = i.dig("metadata", "namespace")
|
51
|
+
statuses = i.dig("status", "containerStatuses") || []
|
52
|
+
statuses.each { |s| s["namespace"] = namespace }
|
53
|
+
statuses
|
54
|
+
end.flatten
|
37
55
|
end
|
38
56
|
end
|
39
57
|
end
|
data/lib/vidar/log.rb
CHANGED
data/lib/vidar/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vidar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krzysztof Knapik
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-09-
|
12
|
+
date: 2019-09-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colorize
|