kuby-azure 0.2.0 → 0.3.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 +13 -0
- data/README.md +20 -18
- data/lib/kuby/azure/config.rb +10 -0
- data/lib/kuby/azure/provider.rb +15 -13
- data/lib/kuby/azure/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: 0b314dd23ada59d875f5c1affa60fead32e729488a9ab10b0421094689faadeb
|
4
|
+
data.tar.gz: 6d3ba0f33f82c32da6f7e8bb70cd53a14c9fc4fe6fd8d18129513b3abab273ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bb31401305129d8e4e280a1ff45eef067bd2d0a8903be954c60691b9a92a65fb372c0da5578a802a5d1914d9bc09bdd9cdb127fa2f09fbfa94a2ad7fa13aa22
|
7
|
+
data.tar.gz: 386587ddd5741f4537e41391cc7c80536f1ea1b976d887f039f2cc8e17e5a41298d7d22edc040dd057544a99467fa6200628ce34138d62bc77c90dbb953c3787
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## 0.3.3
|
2
|
+
* Avoid using `kubernetes_cli` during kubeconfig refresh.
|
3
|
+
- Fixes infinite recursion.
|
4
|
+
|
5
|
+
## 0.3.2
|
6
|
+
* Refresh kubeconfig before CLI object is constructed.
|
7
|
+
|
8
|
+
## 0.3.1
|
9
|
+
* Add a unique hash of the configuration options to the kubeconfig path (#1, @pandwoter)
|
10
|
+
|
11
|
+
## 0.3.0
|
12
|
+
* Accept `environment` instead of `definition` instances.
|
13
|
+
|
1
14
|
## 0.2.0
|
2
15
|
* Remove dependency on rails app.
|
3
16
|
* Refresh kubeconfig in more places.
|
data/README.md
CHANGED
@@ -13,30 +13,32 @@ All providers adhere to a specific interface, meaning you can swap out one provi
|
|
13
13
|
Enable the Azure provider like so:
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
Kuby.define(
|
17
|
-
|
16
|
+
Kuby.define('MyApp') do
|
17
|
+
environment(:production) do
|
18
|
+
kubernetes do
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
provider :azure do
|
21
|
+
# Visible in the subscription overview.
|
22
|
+
subscription_id 'my-subscription-id'
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
# Visible in Azure Active Directory.
|
25
|
+
tenant_id 'my-tenant-id'
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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'
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
# Your cluster should have been created inside a resource group.
|
34
|
+
# Put its name here.
|
35
|
+
resource_group_name 'my-resource-group-name'
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
# The name of your cluster.
|
38
|
+
resource_name 'my-resource-name'
|
39
|
+
end
|
39
40
|
|
41
|
+
end
|
40
42
|
end
|
41
43
|
end
|
42
44
|
```
|
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,6 +1,7 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'azure_mgmt_container_service'
|
3
3
|
require 'tmpdir'
|
4
|
+
require 'digest'
|
4
5
|
|
5
6
|
module Kuby
|
6
7
|
module Azure
|
@@ -14,8 +15,9 @@ module Kuby
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def kubeconfig_path
|
17
|
-
|
18
|
-
kubeconfig_dir,
|
18
|
+
File.join(
|
19
|
+
kubeconfig_dir,
|
20
|
+
"#{environment.app_name.downcase}-#{config.hash_value}-kubeconfig.yaml"
|
19
21
|
)
|
20
22
|
end
|
21
23
|
|
@@ -23,22 +25,18 @@ module Kuby
|
|
23
25
|
STORAGE_CLASS_NAME
|
24
26
|
end
|
25
27
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
refresh_kubeconfig
|
28
|
+
def kubernetes_cli
|
29
|
+
@kubernetes_cli ||= begin
|
30
|
+
refresh_kubeconfig
|
31
|
+
super
|
32
|
+
end
|
32
33
|
end
|
33
34
|
|
34
35
|
private
|
35
36
|
|
36
37
|
def after_initialize
|
37
38
|
@config = Config.new
|
38
|
-
|
39
|
-
kubernetes_cli.before_execute do
|
40
|
-
refresh_kubeconfig
|
41
|
-
end
|
39
|
+
@kubeconfig_refreshed = false
|
42
40
|
end
|
43
41
|
|
44
42
|
def client
|
@@ -65,15 +63,19 @@ module Kuby
|
|
65
63
|
kubeconfig = cred.kubeconfigs.first.value.pack('C*')
|
66
64
|
File.write(kubeconfig_path, kubeconfig)
|
67
65
|
|
66
|
+
@kubeconfig_refreshed = true
|
67
|
+
|
68
68
|
Kuby.logger.info('Successfully refreshed kubeconfig!')
|
69
69
|
end
|
70
70
|
|
71
71
|
def should_refresh_kubeconfig?
|
72
|
+
return false if @kubeconfig_refreshed
|
72
73
|
!File.exist?(kubeconfig_path) || !can_communicate_with_cluster?
|
73
74
|
end
|
74
75
|
|
75
76
|
def can_communicate_with_cluster?
|
76
|
-
|
77
|
+
cli = ::KubernetesCLI.new(kubeconfig_path)
|
78
|
+
cmd = [cli.executable, '--kubeconfig', kubeconfig_path, 'get', 'ns']
|
77
79
|
`#{cmd.join(' ')}`
|
78
80
|
$?.success?
|
79
81
|
end
|
data/lib/kuby/azure/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dutro
|
8
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
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kube-dsl
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
|
-
rubygems_version: 3.
|
76
|
+
rubygems_version: 3.2.22
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: Azure provider for Kuby.
|