rops 1.0.3 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +12 -19
- data/bin/rops +4 -4
- data/lib/deployer.rb +4 -4
- data/lib/image.rb +4 -2
- 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: 78cb1cdfa255b9f24c33cce2dafaaad811526e980fb28df95939024e04ec8324
|
4
|
+
data.tar.gz: c20c8891b751fa8d7a75103d3ed4516920fbbb7ac91e52020f8a35cdb3fddbe7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2add816686a5d4a0e2a94ca1d342af659ba0963e8df4fb2b7e167a4d774ce3696697bfd9467793bb65c14b7c58285516ba6c717891c9a5c58257bc23bf85d7c7
|
7
|
+
data.tar.gz: 1697452d48bbd3cd5ed1501380ba5cb7956474b0aca3b4c2c0a15b2d86d28fa592a2f7a5baf3958e1411d2d5cf81ad30886fe3da21baf6735fb61692b6832049
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,26 +2,23 @@
|
|
2
2
|
|
3
3
|
The Record360 Operations tool - checkout, build, deploy
|
4
4
|
|
5
|
-
##
|
5
|
+
## Description
|
6
6
|
|
7
7
|
This tool implements the Record360 Best Practices for building and deploying projects. It interfaces with Git (for source control), Docker/Podman (for container images), and Kubernetes (cluster deployments).
|
8
8
|
|
9
|
-
|
9
|
+
## Installation
|
10
10
|
|
11
|
-
|
11
|
+
Download and install with:
|
12
12
|
|
13
|
-
```
|
14
|
-
|
15
|
-
group :development do
|
16
|
-
gem 'rops', github: 'Record360/rops'
|
17
|
-
end
|
13
|
+
```shell
|
14
|
+
gem install rops
|
18
15
|
```
|
19
16
|
|
20
|
-
|
17
|
+
## Configuration
|
21
18
|
|
22
19
|
`rops` has several opinionated defaults, which can be overridden by command line options or a configuration file.
|
23
20
|
|
24
|
-
|
21
|
+
### Project Root Directory
|
25
22
|
By default, the current working directory when `rops` runs. It can be overridden with the `--root=<DIR>` option.
|
26
23
|
|
27
24
|
The project root directory must contain:
|
@@ -34,7 +31,7 @@ end
|
|
34
31
|
* `./platform/rops.yaml`
|
35
32
|
* `./config/rops.yaml`
|
36
33
|
|
37
|
-
|
34
|
+
### Docker Container Images
|
38
35
|
By default, a single image named from the the Project root directory and built from `./Dockerfile`. May be overridden by setting the `images` array in the configuration file, e.g.:
|
39
36
|
|
40
37
|
```yaml
|
@@ -45,23 +42,22 @@ images:
|
|
45
42
|
dockerfile: dockerfiles/second.Dockerfile
|
46
43
|
```
|
47
44
|
|
48
|
-
|
45
|
+
### Git Default Branch
|
49
46
|
The Git branch to build, by default `master`. Overridden with the `default_branch` field in the configuration file.
|
50
47
|
|
51
|
-
|
48
|
+
### Docker Registry
|
52
49
|
The Docker registry to push container images. By default, `r360`, which is probably not what you want and should be overridden by setting the `registry` field in the configuration file.
|
53
50
|
|
54
|
-
|
51
|
+
### Kubernetes Context
|
55
52
|
The name of the Kubernetes context to deploy to (as listed in `~/.kube/config`). Defaults to `staging` and overridden with the `default_context` field in the configuration file.
|
56
53
|
|
57
54
|
There are extra safety features when deploying to the production context, which defaults to `production` and may be overridden with the `production_context` field in the configuration file.
|
58
55
|
|
59
56
|
Kubernetes configuration is organized by Kubernetes context name, under the `./platform` directory. For example, the Kubernetes configuration for the default contexts (`staging` and `production`) is stored under `./platform/staging` and `./platform/production` respectively.
|
60
57
|
|
61
|
-
|
58
|
+
## Operations
|
62
59
|
|
63
60
|
### Status
|
64
|
-
|
65
61
|
Arguments:
|
66
62
|
* `context`: Kubernetes context (default `staging`, or the value of `staging_context`)
|
67
63
|
|
@@ -80,7 +76,6 @@ Currently running (staging):
|
|
80
76
|
```
|
81
77
|
|
82
78
|
### Build
|
83
|
-
|
84
79
|
Arguments:
|
85
80
|
* `branch`: Git branch/commit (default `master`, or the value of `default_branch`)
|
86
81
|
|
@@ -105,7 +100,6 @@ Successfully tagged localhost/web:gfc50028b-feature
|
|
105
100
|
```
|
106
101
|
|
107
102
|
### Push
|
108
|
-
|
109
103
|
Arguments:
|
110
104
|
* `branch`: Git branch/commit (default `master`, or the value of `default_branch`)
|
111
105
|
|
@@ -120,7 +114,6 @@ Storing signatures
|
|
120
114
|
```
|
121
115
|
|
122
116
|
### Deploy
|
123
|
-
|
124
117
|
Arguments:
|
125
118
|
* `branch`: Git branch/commit (default `master`, or the value of `default_branch`)
|
126
119
|
* `context`: Kubernetes context (default `staging`, or the value of `default_context`)
|
data/bin/rops
CHANGED
@@ -150,8 +150,8 @@ module Record360
|
|
150
150
|
end
|
151
151
|
|
152
152
|
class BuildImage < Dry::CLI::Command
|
153
|
-
desc "Build the docker image"
|
154
|
-
argument :branch, desc: "Branch (or commit) to build"
|
153
|
+
desc "Build the docker image"
|
154
|
+
argument :branch, desc: "Branch (or commit) to build"
|
155
155
|
include Common
|
156
156
|
|
157
157
|
def call(**)
|
@@ -222,10 +222,10 @@ module Record360
|
|
222
222
|
end
|
223
223
|
|
224
224
|
if $stdout.tty?
|
225
|
-
print "Deploy #{branch} (#{image_tag}) to #{context}? (y/N): "
|
225
|
+
print "Deploy #{deployer.branch} (#{image_tag}) to #{context}? (y/N): "
|
226
226
|
exit(-1) unless $stdin.gets&.chomp == 'y'
|
227
227
|
else
|
228
|
-
puts "Deploying #{branch} (#{image_tag}) to #{context}"
|
228
|
+
puts "Deploying #{deployer.branch} (#{image_tag}) to #{context}"
|
229
229
|
end
|
230
230
|
|
231
231
|
deployer.deploy!(context)
|
data/lib/deployer.rb
CHANGED
@@ -44,8 +44,8 @@ class Deployer
|
|
44
44
|
|
45
45
|
short_id = @commit[0, 8]
|
46
46
|
@image_tag = "g#{short_id}"
|
47
|
-
if
|
48
|
-
@image_tag += "-#{branch}"
|
47
|
+
if (@branch != default_branch) && !@branch.start_with?(short_id)
|
48
|
+
@image_tag += "-#{@branch}"
|
49
49
|
end
|
50
50
|
images.each do |image|
|
51
51
|
image.commit = commit
|
@@ -68,7 +68,7 @@ class Deployer
|
|
68
68
|
end
|
69
69
|
|
70
70
|
statuses, stderr, success = kubectl(context, cmd)
|
71
|
-
unless success || stderr.match(/not found/)
|
71
|
+
unless (success || stderr.match(/not found/)) && statuses.present?
|
72
72
|
puts stderr if stderr.present?
|
73
73
|
return nil
|
74
74
|
end
|
@@ -135,7 +135,7 @@ class Deployer
|
|
135
135
|
cmd = "kubectl --context #{context} #{cmd}"
|
136
136
|
|
137
137
|
if ssh_host.blank?
|
138
|
-
stdout, stderr, cmd_status = Open3.capture3(cmd)
|
138
|
+
stdout, stderr, cmd_status = Open3.capture3(cmd, stdin_data: data)
|
139
139
|
[ stdout, stderr, cmd_status.success? ]
|
140
140
|
else
|
141
141
|
require 'net/ssh'
|
data/lib/image.rb
CHANGED
@@ -54,7 +54,9 @@ class Image
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def local_exists?
|
57
|
-
|
57
|
+
if @local_exists.nil?
|
58
|
+
@local_exists = system("#{Deployer.docker} image exists #{local_image}")
|
59
|
+
end
|
58
60
|
end
|
59
61
|
|
60
62
|
def remote_image
|
@@ -68,7 +70,7 @@ class Image
|
|
68
70
|
if status.success? || stderr.include?('error parsing manifest blob')
|
69
71
|
@remote_exists = true
|
70
72
|
else
|
71
|
-
puts stderr if stderr.present? && !stderr.include?('manifest unknown')
|
73
|
+
puts stderr if stderr.present? && !stderr.include?('manifest unknown') && !stderr.include?('no such manifest')
|
72
74
|
@remote_exists = false
|
73
75
|
end
|
74
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Sloan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|