kuby-digitalocean 0.2.0 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +36 -0
- data/lib/kuby/digitalocean/config.rb +7 -0
- data/lib/kuby/digitalocean/provider.rb +23 -8
- data/lib/kuby/digitalocean/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e634fdfb6ddb23305dc7f7fa7305a930316e6cbde11a8d8a20410978ed9b6767
|
4
|
+
data.tar.gz: ec0047d9b187c1f1ed31c6ea888ca3d5a0dc5999f6f12d24c25b2a0c7fa4c2e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dbc54986ddc3293495f49b1b1386af7a04b7f684f6ec9eb344ef957fef1c947a43e129a8c3515fc803554a86c25213bac2b1ce937075a1d025a5803e8e19fe6
|
7
|
+
data.tar.gz: 0f1cae30703cfe7adb1bdeea1404f63e08c6cfb00cc418324fb81f4772e50b0f49d8a5f6c1897c4238f35756bb8a83d8345239d365fac48bfb99d415a4286f43
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## 0.4.3
|
2
|
+
* Add a unique hash of the configuration options to the kubeconfig path (#3, @pandwoter)
|
3
|
+
|
4
|
+
## 0.4.2
|
5
|
+
* Avoid `instance_eval`ing a `nil` block during configuration.
|
6
|
+
|
7
|
+
## 0.4.1
|
8
|
+
* Fix bug causing kubeconfig to not get refreshed prior to executing commands.
|
9
|
+
|
10
|
+
## 0.4.0
|
11
|
+
* Accept `environment` instead of `definition` instances.
|
12
|
+
|
13
|
+
## 0.3.0
|
14
|
+
* Refresh kubeconfig in more places.
|
15
|
+
- Before setup
|
16
|
+
- Before deploy
|
17
|
+
|
1
18
|
## 0.2.0
|
2
19
|
* Refresh kubeconfig earlier and more often so it's ready during setup.
|
3
20
|
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
## kuby-digitalocean
|
2
|
+
|
3
|
+
DigitalOcean provider for [Kuby](https://github.com/getkuby/kuby-core).
|
4
|
+
|
5
|
+
## Intro
|
6
|
+
|
7
|
+
In Kuby parlance, a "provider" is an [adapter](https://en.wikipedia.org/wiki/Adapter_pattern) that enables Kuby to deploy apps to a specific cloud provider. In this case, we're talking about [DigitalOcean](https://www.digitalocean.com/).
|
8
|
+
|
9
|
+
All providers adhere to a specific interface, meaning you can swap out one provider for another without having to change your code.
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Enable the DigitalOcean provider like so:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
Kuby.define(:production) do
|
17
|
+
kubernetes do
|
18
|
+
|
19
|
+
provider :digitalocean do
|
20
|
+
access_token 'my-digitalocean-access-token'
|
21
|
+
cluster_id 'my-cluster-id'
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
Once configured, you should be able to run all the Kuby rake tasks as you would with any provider.
|
29
|
+
|
30
|
+
## License
|
31
|
+
|
32
|
+
Licensed under the MIT license. See LICENSE for details.
|
33
|
+
|
34
|
+
## Authors
|
35
|
+
|
36
|
+
* Cameron C. Dutro: http://github.com/camertron
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'kube-dsl'
|
2
|
+
require 'digest'
|
2
3
|
|
3
4
|
module Kuby
|
4
5
|
module DigitalOcean
|
@@ -6,6 +7,12 @@ module Kuby
|
|
6
7
|
extend ::KubeDSL::ValueFields
|
7
8
|
|
8
9
|
value_fields :access_token, :cluster_id
|
10
|
+
|
11
|
+
def hash_value
|
12
|
+
Digest::SHA256.hexdigest(
|
13
|
+
[access_token, cluster_id].join(':')
|
14
|
+
)
|
15
|
+
end
|
9
16
|
end
|
10
17
|
end
|
11
18
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'kuby'
|
2
2
|
require 'droplet_kit'
|
3
3
|
require 'fileutils'
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'digest'
|
4
6
|
|
5
7
|
module Kuby
|
6
8
|
module DigitalOcean
|
@@ -11,17 +13,22 @@ module Kuby
|
|
11
13
|
attr_reader :config
|
12
14
|
|
13
15
|
def configure(&block)
|
14
|
-
config.instance_eval(&block)
|
16
|
+
config.instance_eval(&block) if block
|
15
17
|
end
|
16
18
|
|
17
19
|
def kubeconfig_path
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
File.join(
|
21
|
+
kubeconfig_dir,
|
22
|
+
"#{environment.app_name.downcase}-#{config.hash_value}-kubeconfig.yaml"
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def before_setup
|
27
|
+
refresh_kubeconfig
|
21
28
|
end
|
22
29
|
|
23
30
|
def after_setup
|
24
|
-
if nginx_ingress =
|
31
|
+
if nginx_ingress = environment.kubernetes.plugin(:nginx_ingress)
|
25
32
|
service = ::KubeDSL::Resource.new(
|
26
33
|
kubernetes_cli.get_object(
|
27
34
|
'service', nginx_ingress.namespace, nginx_ingress.service_name
|
@@ -48,7 +55,7 @@ module Kuby
|
|
48
55
|
end
|
49
56
|
end
|
50
57
|
|
51
|
-
def
|
58
|
+
def before_deploy(*)
|
52
59
|
refresh_kubeconfig
|
53
60
|
end
|
54
61
|
|
@@ -56,6 +63,14 @@ module Kuby
|
|
56
63
|
STORAGE_CLASS_NAME
|
57
64
|
end
|
58
65
|
|
66
|
+
def kubernetes_cli
|
67
|
+
@kubernetes_cli ||= ::KubernetesCLI.new(kubeconfig_path).tap do |cli|
|
68
|
+
cli.before_execute do
|
69
|
+
refresh_kubeconfig
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
59
74
|
private
|
60
75
|
|
61
76
|
def after_initialize
|
@@ -83,8 +98,8 @@ module Kuby
|
|
83
98
|
end
|
84
99
|
|
85
100
|
def kubeconfig_dir
|
86
|
-
@kubeconfig_dir ||=
|
87
|
-
|
101
|
+
@kubeconfig_dir ||= File.join(
|
102
|
+
Dir.tmpdir, 'kuby-digitalocean'
|
88
103
|
)
|
89
104
|
end
|
90
105
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuby-digitalocean
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dutro
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: droplet_kit
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- CHANGELOG.md
|
49
49
|
- Gemfile
|
50
50
|
- LICENSE
|
51
|
+
- README.md
|
51
52
|
- Rakefile
|
52
53
|
- kuby-digitalocean.gemspec
|
53
54
|
- lib/kuby/digitalocean.rb
|
@@ -57,7 +58,7 @@ files:
|
|
57
58
|
homepage: http://github.com/getkuby/kuby-digitalocean
|
58
59
|
licenses: []
|
59
60
|
metadata: {}
|
60
|
-
post_install_message:
|
61
|
+
post_install_message:
|
61
62
|
rdoc_options: []
|
62
63
|
require_paths:
|
63
64
|
- lib
|
@@ -72,8 +73,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
73
|
- !ruby/object:Gem::Version
|
73
74
|
version: '0'
|
74
75
|
requirements: []
|
75
|
-
rubygems_version: 3.
|
76
|
-
signing_key:
|
76
|
+
rubygems_version: 3.1.4
|
77
|
+
signing_key:
|
77
78
|
specification_version: 4
|
78
79
|
summary: DigitalOcean provider for Kuby.
|
79
80
|
test_files: []
|