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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 005be68800cb10ba770e629b590f8a28351f0ff3486341bac289c8e1b1294b52
4
- data.tar.gz: 9b9d4d95f9dbc7f2142cd85a5a77a29a338bd9f3abe77e9b779845e62e5074ab
3
+ metadata.gz: 843b278c3e282adca8a249e1e82cbe53f11d61508bc943a842612923dc5bffb8
4
+ data.tar.gz: 2ec6da6f810679586997592b4b6eb55b15c2509f052fbc1b122bf567206d30b2
5
5
  SHA512:
6
- metadata.gz: b28395e1dc1fea92e5eaf98627ae0eb2f83373372b426485e8b222288aed86d866b632dc0978bf455125062f85a822c86d5072322a330c2324d51db37df06fe0
7
- data.tar.gz: c9ebb9d52f0850b780f0d3ac95e33c2ac7911fb77c707630ea48c774484582f1b2d0b25532263a044c3fb8fd204d02c339383da581e461439315062ec929c3a8
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
@@ -12,7 +12,6 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.platform = Gem::Platform::RUBY
14
14
 
15
- s.add_dependency 'faraday', '~> 0.17'
16
15
  s.add_dependency 'kube-dsl', '~> 0.1'
17
16
  s.add_dependency 'azure_mgmt_container_service', '~> 0.20'
18
17
 
@@ -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
@@ -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
- @kubeconfig_path ||= kubeconfig_dir.join(
17
- "#{definition.app_name.downcase}-kubeconfig.yaml"
18
- ).to_s
19
- end
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 ||= definition.app.root.join(
74
- 'tmp', 'kuby-azure'
83
+ @kubeconfig_dir ||= File.join(
84
+ Dir.tmpdir, 'kuby-azure'
75
85
  )
76
86
  end
77
87
  end
@@ -1,5 +1,5 @@
1
1
  module Kuby
2
2
  module Azure
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.3.2'.freeze
4
4
  end
5
5
  end
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.1.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: 2020-06-11 00:00:00.000000000 Z
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.0.6
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: []