configgin 0.14.0 → 0.14.1

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
  SHA1:
3
- metadata.gz: 593236064eaa183069525e4725950e8bc4f39c0f
4
- data.tar.gz: 8b4a9485d62dcd0a64170772b85285679ce25362
3
+ metadata.gz: 57e22a993e395b62b0e774967bc18ae370ac25ad
4
+ data.tar.gz: a7336574e707fdafd1f94700969a221cd9cd7fea
5
5
  SHA512:
6
- metadata.gz: 2cb081da7e7eb7468c7d2eb6c109ae430270d37a65d5a0f9ac2de41fc2bc32d6fe9a3f47ca999be61bac1d93dd5f37dbec5bc7bd9fdab1416a7fc3d1c20d0e98
7
- data.tar.gz: 5005cc57cc29062bfa89e209b23c56dc870629e0be1b45af05bc950f7b68d55c56526dba3b6cce814e255968e9978aa54337744c3e32386f5f21ac62849c823d
6
+ metadata.gz: c8a346691d24d176cb5d3ab5baa34050467d60380acb30d1fd9116cf20a1c237bc0674174692ebb4edd8b12fc9427c938ac6ac732141f1639fbdd659ac977283
7
+ data.tar.gz: 4621b053cc303f2c4aa82b9fe8b0007339fd2c78bd608b71d3b1843723e84bdb49ab9839f6386f4b534dbe1750573b5b32bb102ca544d37bc005dfee7af8f770
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- configgin (0.14.0)
4
+ configgin (0.14.1)
5
5
  bosh-template (~> 2.0)
6
6
  deep_merge (~> 1.1)
7
7
  kubeclient (~> 2.0)
@@ -16,11 +16,11 @@ GEM
16
16
  ast (2.3.0)
17
17
  bosh-template (2.0.0)
18
18
  semi_semantic (~> 1.2.0)
19
- deep_merge (1.1.1)
19
+ deep_merge (1.2.1)
20
20
  diff-lcs (1.3)
21
21
  domain_name (0.5.20170404)
22
22
  unf (>= 0.0.5, < 1.0.0)
23
- http (0.9.8)
23
+ http (2.2.2)
24
24
  addressable (~> 2.3)
25
25
  http-cookie (~> 1.0)
26
26
  http-form_data (~> 1.0.1)
@@ -29,9 +29,9 @@ GEM
29
29
  domain_name (~> 0.5)
30
30
  http-form_data (1.0.3)
31
31
  http_parser.rb (0.6.0)
32
- kubeclient (2.5.1)
33
- http (= 0.9.8)
34
- recursive-open-struct (= 1.0.0)
32
+ kubeclient (2.5.2)
33
+ http (>= 0.98, < 3)
34
+ recursive-open-struct (~> 1.0.0)
35
35
  rest-client
36
36
  mime-types (3.1)
37
37
  mime-types-data (~> 3.2015)
@@ -44,7 +44,7 @@ GEM
44
44
  public_suffix (3.0.1)
45
45
  rainbow (2.1.0)
46
46
  rake (10.4.2)
47
- recursive-open-struct (1.0.0)
47
+ recursive-open-struct (1.0.5)
48
48
  rest-client (2.0.2)
49
49
  http-cookie (>= 1.0.2, < 2.0)
50
50
  mime-types (>= 1.16, < 4.0)
@@ -72,7 +72,7 @@ GEM
72
72
  semi_semantic (1.2.0)
73
73
  unf (0.1.4)
74
74
  unf_ext
75
- unf_ext (0.0.7.4)
75
+ unf_ext (0.0.7.5)
76
76
  unicode-display_width (1.2.1)
77
77
 
78
78
  PLATFORMS
@@ -86,4 +86,4 @@ DEPENDENCIES
86
86
  rubocop
87
87
 
88
88
  BUNDLED WITH
89
- 1.14.6
89
+ 1.15.1
data/bin/configgin CHANGED
@@ -33,6 +33,19 @@ kube_client = Kubeclient::Client.new(
33
33
  bearer_token: File.read("#{SVC_ACC_PATH}/token")
34
34
  }
35
35
  )
36
+ kube_client_stateful_set = Kubeclient::Client.new(
37
+ URI::HTTPS.build(host: ENV['KUBERNETES_SERVICE_HOST'],
38
+ port: ENV['KUBERNETES_SERVICE_PORT_HTTPS'],
39
+ path: '/apis/apps'),
40
+ 'v1beta1',
41
+ ssl_options: {
42
+ ca_file: "#{SVC_ACC_PATH}/ca.crt",
43
+ verify_ssl: OpenSSL::SSL::VERIFY_PEER
44
+ },
45
+ auth_options: {
46
+ bearer_token: File.read("#{SVC_ACC_PATH}/token")
47
+ }
48
+ )
36
49
  kube_namespace = File.read("#{SVC_ACC_PATH}/namespace")
37
50
 
38
51
  jobs = {}
@@ -49,7 +62,7 @@ job_configs.each do |job, job_config|
49
62
  exit 1
50
63
  end
51
64
 
52
- jobs[job] = Job.new(bosh_spec, kube_namespace, kube_client)
65
+ jobs[job] = Job.new(bosh_spec, kube_namespace, kube_client, kube_client_stateful_set)
53
66
  end
54
67
 
55
68
  exported_properties = Hash[jobs.map { |name, job| [name, job.exported_properties] }]
@@ -1,3 +1,3 @@
1
1
  module Configgin
2
- VERSION = '0.14.0'.freeze
2
+ VERSION = '0.14.1'.freeze
3
3
  end
data/lib/job.rb CHANGED
@@ -4,11 +4,11 @@ require_relative 'kube_link_generator'
4
4
 
5
5
  # Job describes a single BOSH job
6
6
  class Job
7
- def initialize(spec, namespace, client)
7
+ def initialize(spec, namespace, client, client_stateful_set)
8
8
  @spec = spec
9
9
  @namespace = namespace
10
10
  @client = client
11
- @spec['links'] = KubeLinkSpecs.new(@spec, @namespace, @client)
11
+ @spec['links'] = KubeLinkSpecs.new(@spec, @namespace, @client, client_stateful_set)
12
12
  end
13
13
 
14
14
  attr_reader :spec
@@ -8,9 +8,10 @@ class KubeLinkSpecs
8
8
  # ANNOTATION_AZ is the Kube annotation for the (availability) zone
9
9
  ANNOTATION_AZ = 'failure-domain.beta.kubernetes.io/zone'.freeze
10
10
 
11
- def initialize(spec, namespace, kube_client)
11
+ def initialize(spec, namespace, kube_client, kube_client_stateful_set)
12
12
  @links = {}
13
13
  @client = kube_client
14
+ @client_stateful_set = kube_client_stateful_set
14
15
  @namespace = namespace
15
16
  @spec = spec || {}
16
17
  end
@@ -104,6 +105,31 @@ class KubeLinkSpecs
104
105
  }
105
106
  end
106
107
 
108
+ def get_statefulset_instance_info(role_name, job)
109
+ ss = @client_stateful_set.get_stateful_set(role_name, @namespace)
110
+ pod = get_pods_for_role(role_name, false).first
111
+ properties = JSON.parse(pod.metadata.annotations['skiff-exported-properties'])
112
+
113
+ Array.new(ss.spec.replicas) do |i|
114
+ {
115
+ 'name' => ss.metadata.name,
116
+ 'index' => i,
117
+ 'id' => ss.metadata.name,
118
+ 'az' => pod.metadata.annotations['failure-domain.beta.kubernetes.io/zone'] || 'az0',
119
+ 'address' => "#{ss.metadata.name}-#{i}.#{ss.spec.serviceName}",
120
+ 'properties' => properties.fetch(job, {}),
121
+ 'bootstrap' => i.zero?
122
+ }
123
+ end
124
+ end
125
+
126
+ def service?(role_name)
127
+ @client.get_service(role_name, @namespace)
128
+ true
129
+ rescue KubeException
130
+ false
131
+ end
132
+
107
133
  def [](key)
108
134
  return @links[key] if @links.key? key
109
135
 
@@ -120,10 +146,14 @@ class KubeLinkSpecs
120
146
  pods = get_pods_for_role(provider['role'], true)
121
147
  pods_per_image = get_pods_per_image(pods)
122
148
  instances = pods.map { |p| get_pod_instance_info(p, provider['job'], pods_per_image) }
123
- else
149
+ elsif service? provider['role']
124
150
  # Getting pods for a different service; since we have kube services, we don't handle it in configgin
125
151
  $stderr.puts "Resolving link #{key} via service #{provider}"
126
152
  instances = [get_svc_instance_info(provider['role'], provider['job'])]
153
+ else
154
+ # If there's no service associated, check the statefulset instead
155
+ $stderr.puts "Resolving link #{key} via statefulset #{provider}"
156
+ instances = get_statefulset_instance_info(provider['role'], provider['job'])
127
157
  end
128
158
 
129
159
  @links[key] = {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configgin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SUSE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-08 00:00:00.000000000 Z
11
+ date: 2018-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  version: '0'
178
178
  requirements: []
179
179
  rubyforge_project:
180
- rubygems_version: 2.6.14
180
+ rubygems_version: 2.6.13
181
181
  signing_key:
182
182
  specification_version: 4
183
183
  summary: A simple cli app in Ruby to generate configurations using BOSH ERB templates