kuby-azure 0.1.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +54 -0
- data/kuby-azure.gemspec +0 -1
- data/lib/kuby/azure/config.rb +10 -0
- data/lib/kuby/azure/provider.rb +19 -9
- data/lib/kuby/azure/version.rb +1 -1
- metadata +7 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 843b278c3e282adca8a249e1e82cbe53f11d61508bc943a842612923dc5bffb8
|
4
|
+
data.tar.gz: 2ec6da6f810679586997592b4b6eb55b15c2509f052fbc1b122bf567206d30b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02e7d0be446f09f5d5fd158adee1f122173f8d78e5479e93ee2946f786ac1a8f41b3b1eef19f2850cea8e4fc7c76763ad27a15f23e4fd9fd30da08d2bd924e42
|
7
|
+
data.tar.gz: 0f53e31bf7ff3714823d8a21a1028f9c211df621bf0e23019ac4edb980e476ad9a469ef6fc61f99b05a309e8791924d3f51f4ea80e81cd8a084b98bd99dffb9b
|
data/CHANGELOG.md
CHANGED
@@ -1,2 +1,17 @@
|
|
1
|
+
## 0.3.2
|
2
|
+
* Refresh kubeconfig before CLI object is constructed.
|
3
|
+
|
4
|
+
## 0.3.1
|
5
|
+
* Add a unique hash of the configuration options to the kubeconfig path (#1, @pandwoter)
|
6
|
+
|
7
|
+
## 0.3.0
|
8
|
+
* Accept `environment` instead of `definition` instances.
|
9
|
+
|
10
|
+
## 0.2.0
|
11
|
+
* Remove dependency on rails app.
|
12
|
+
* Refresh kubeconfig in more places.
|
13
|
+
- Before setup
|
14
|
+
- Before deploy
|
15
|
+
|
1
16
|
## 0.1.0
|
2
17
|
* Birthday!
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
## kuby-azure
|
2
|
+
|
3
|
+
Azure 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 Microsoft's [Azure](https://azure.microsoft.com/), specifically their managed Kubernetes offering.
|
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 Azure provider like so:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
Kuby.define('MyApp') do
|
17
|
+
environment(:production) do
|
18
|
+
kubernetes do
|
19
|
+
|
20
|
+
provider :azure do
|
21
|
+
# Visible in the subscription overview.
|
22
|
+
subscription_id 'my-subscription-id'
|
23
|
+
|
24
|
+
# Visible in Azure Active Directory.
|
25
|
+
tenant_id 'my-tenant-id'
|
26
|
+
|
27
|
+
# These must be configured in Azure Active Directory -> App
|
28
|
+
# Registrations. It's easiest to generate a client id and
|
29
|
+
# secret for the service principal.
|
30
|
+
client_id 'my-client-id'
|
31
|
+
client_secret 'my-client-secret'
|
32
|
+
|
33
|
+
# Your cluster should have been created inside a resource group.
|
34
|
+
# Put its name here.
|
35
|
+
resource_group_name 'my-resource-group-name'
|
36
|
+
|
37
|
+
# The name of your cluster.
|
38
|
+
resource_name 'my-resource-name'
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
Once configured, you should be able to run all the Kuby rake tasks as you would with any provider.
|
47
|
+
|
48
|
+
## License
|
49
|
+
|
50
|
+
Licensed under the MIT license. See LICENSE for details.
|
51
|
+
|
52
|
+
## Authors
|
53
|
+
|
54
|
+
* Cameron C. Dutro: http://github.com/camertron
|
data/kuby-azure.gemspec
CHANGED
data/lib/kuby/azure/config.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'kube-dsl'
|
2
|
+
require 'digest'
|
2
3
|
|
3
4
|
module Kuby
|
4
5
|
module Azure
|
@@ -7,6 +8,15 @@ module Kuby
|
|
7
8
|
|
8
9
|
value_fields :tenant_id, :client_id, :client_secret, :subscription_id
|
9
10
|
value_fields :resource_group_name, :resource_name
|
11
|
+
|
12
|
+
def hash_value
|
13
|
+
parts = [
|
14
|
+
tenant_id, client_id, client_secret, subscription_id,
|
15
|
+
resource_group_name, resource_name
|
16
|
+
]
|
17
|
+
|
18
|
+
Digest::SHA256.hexdigest(parts.join(':'))
|
19
|
+
end
|
10
20
|
end
|
11
21
|
end
|
12
22
|
end
|
data/lib/kuby/azure/provider.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'azure_mgmt_container_service'
|
3
|
+
require 'tmpdir'
|
4
|
+
require 'digest'
|
3
5
|
|
4
6
|
module Kuby
|
5
7
|
module Azure
|
@@ -13,23 +15,28 @@ module Kuby
|
|
13
15
|
end
|
14
16
|
|
15
17
|
def kubeconfig_path
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def after_configuration
|
22
|
-
refresh_kubeconfig
|
18
|
+
File.join(
|
19
|
+
kubeconfig_dir,
|
20
|
+
"#{environment.app_name.downcase}-#{config.hash_value}-kubeconfig.yaml"
|
21
|
+
)
|
23
22
|
end
|
24
23
|
|
25
24
|
def storage_class_name
|
26
25
|
STORAGE_CLASS_NAME
|
27
26
|
end
|
28
27
|
|
28
|
+
def kubernetes_cli
|
29
|
+
@kubernetes_cli ||= begin
|
30
|
+
refresh_kubeconfig
|
31
|
+
super
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
29
35
|
private
|
30
36
|
|
31
37
|
def after_initialize
|
32
38
|
@config = Config.new
|
39
|
+
@kubeconfig_refreshed = false
|
33
40
|
end
|
34
41
|
|
35
42
|
def client
|
@@ -56,10 +63,13 @@ module Kuby
|
|
56
63
|
kubeconfig = cred.kubeconfigs.first.value.pack('C*')
|
57
64
|
File.write(kubeconfig_path, kubeconfig)
|
58
65
|
|
66
|
+
@kubeconfig_refreshed = true
|
67
|
+
|
59
68
|
Kuby.logger.info('Successfully refreshed kubeconfig!')
|
60
69
|
end
|
61
70
|
|
62
71
|
def should_refresh_kubeconfig?
|
72
|
+
return false if @kubeconfig_refreshed
|
63
73
|
!File.exist?(kubeconfig_path) || !can_communicate_with_cluster?
|
64
74
|
end
|
65
75
|
|
@@ -70,8 +80,8 @@ module Kuby
|
|
70
80
|
end
|
71
81
|
|
72
82
|
def kubeconfig_dir
|
73
|
-
@kubeconfig_dir ||=
|
74
|
-
|
83
|
+
@kubeconfig_dir ||= File.join(
|
84
|
+
Dir.tmpdir, 'kuby-azure'
|
75
85
|
)
|
76
86
|
end
|
77
87
|
end
|
data/lib/kuby/azure/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuby-azure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.2
|
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:
|
11
|
+
date: 2022-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: faraday
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.17'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0.17'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: kube-dsl
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,6 +48,7 @@ files:
|
|
62
48
|
- CHANGELOG.md
|
63
49
|
- Gemfile
|
64
50
|
- LICENSE
|
51
|
+
- README.md
|
65
52
|
- Rakefile
|
66
53
|
- kuby-azure.gemspec
|
67
54
|
- lib/kuby/azure.rb
|
@@ -71,7 +58,7 @@ files:
|
|
71
58
|
homepage: http://github.com/getkuby/kuby-azure
|
72
59
|
licenses: []
|
73
60
|
metadata: {}
|
74
|
-
post_install_message:
|
61
|
+
post_install_message:
|
75
62
|
rdoc_options: []
|
76
63
|
require_paths:
|
77
64
|
- lib
|
@@ -86,8 +73,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
73
|
- !ruby/object:Gem::Version
|
87
74
|
version: '0'
|
88
75
|
requirements: []
|
89
|
-
rubygems_version: 3.
|
90
|
-
signing_key:
|
76
|
+
rubygems_version: 3.2.22
|
77
|
+
signing_key:
|
91
78
|
specification_version: 4
|
92
79
|
summary: Azure provider for Kuby.
|
93
80
|
test_files: []
|