beaker-gke 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubcop.yaml +14 -0
- data/beaker-gke.gemspec +13 -31
- data/bin/beaker-gke +1 -0
- data/config/pod.yaml +34 -19
- data/config/service.yaml +12 -11
- data/lib/beaker-gke.rb +2 -0
- data/lib/beaker-gke/version.rb +3 -1
- data/lib/beaker/hypervisor/gke.rb +44 -38
- metadata +11 -149
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 009e87947781520d425d4ba4e3578cd563a86839
|
4
|
+
data.tar.gz: 2754f9512a7dba47bb2330b12d4a3b215fdadd91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8088bc44df805f9cf03895b178d761869f7dbe7d79e7f216d8f66dfd2fe9041687405a6698cb273d49a421d09b0292f4288af703dae8192608a8fb4e6dd4380
|
7
|
+
data.tar.gz: ff708f8ef2966f8254c054fe4449f7fc1461d6ab487e41cbcd2eef5bf345b580a413447ef39abe1c973e5cd2a0f8528b291d1438586e2d0bf5cc436af894a008
|
data/.rubcop.yaml
ADDED
data/beaker-gke.gemspec
CHANGED
@@ -1,43 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
4
|
+
|
3
5
|
require 'beaker-gke/version'
|
4
6
|
|
5
7
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
8
|
+
s.name = 'beaker-gke'
|
7
9
|
s.version = BeakerGke::VERSION
|
8
10
|
s.authors = ["Night's Watch"]
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
11
|
-
s.summary =
|
12
|
-
s.description =
|
13
|
-
s.license = '
|
11
|
+
s.email = ['team-nw@puppet.com']
|
12
|
+
s.homepage = 'https://github.com/puppetlabs/beaker-gke'
|
13
|
+
s.summary = 'Beaker hypervisor for GKE!'
|
14
|
+
s.description = 'Add GKE support to Beaker acceptance testing tool'
|
15
|
+
s.license = 'Apache-2.0'
|
14
16
|
|
15
17
|
s.files = `git ls-files`.split("\n")
|
16
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |
|
18
|
-
s.require_paths = [
|
19
|
-
|
20
|
-
# Testing dependencies
|
21
|
-
s.add_development_dependency 'rspec', '~> 3.0'
|
22
|
-
s.add_development_dependency 'rspec-its'
|
23
|
-
# pin fakefs for Ruby < 2.3
|
24
|
-
if RUBY_VERSION < "2.3"
|
25
|
-
s.add_development_dependency 'fakefs', '~> 0.6', '< 0.14'
|
26
|
-
else
|
27
|
-
s.add_development_dependency 'fakefs', '~> 0.6'
|
28
|
-
end
|
29
|
-
s.add_development_dependency 'rake', '~> 10.1'
|
30
|
-
s.add_development_dependency 'simplecov'
|
31
|
-
s.add_development_dependency 'pry', '~> 0.10'
|
32
|
-
|
33
|
-
# Documentation dependencies
|
34
|
-
s.add_development_dependency 'yard'
|
35
|
-
s.add_development_dependency 'markdown'
|
36
|
-
s.add_development_dependency 'thin'
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |file| File.basename(file) }
|
20
|
+
s.require_paths = ['lib']
|
37
21
|
|
38
22
|
# Run time dependencies
|
23
|
+
s.add_runtime_dependency 'googleauth', '~> 0.9'
|
39
24
|
s.add_runtime_dependency 'kubeclient', '~> 4.4.0'
|
40
|
-
|
41
|
-
s.add_runtime_dependency 'googleauth'
|
42
|
-
|
43
|
-
end
|
25
|
+
end
|
data/bin/beaker-gke
CHANGED
data/config/pod.yaml
CHANGED
@@ -1,23 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
---
|
2
|
+
:apiVersion: v1
|
3
|
+
:kind: Pod
|
4
|
+
:metadata:
|
5
|
+
:name: "%{pod_name}"
|
6
|
+
:namespace: gke-puppetagent-ci
|
7
|
+
:labels:
|
8
|
+
:app: "%{pod_name}"
|
9
|
+
:project: puppet-agent-ci
|
10
|
+
:spec:
|
11
|
+
:hostname: "%{pod_name}"
|
12
|
+
:containers:
|
13
|
+
- :image: <%= ENV.fetch("CONTAINER_IMAGE") { "gcr.io/puppetagent-ci/centos-7-master:v4" } %>
|
14
|
+
:name: "centos-7-master"
|
15
|
+
:securityContext:
|
16
|
+
:capabilities:
|
17
|
+
:add:
|
18
|
+
- NET_ADMIN
|
19
|
+
:dnsPolicy: "None"
|
20
|
+
:dnsConfig:
|
15
21
|
nameservers:
|
16
22
|
- 10.240.0.10
|
17
23
|
- 10.240.1.10
|
18
|
-
searches:
|
24
|
+
:searches:
|
19
25
|
- gke-puppetagent-ci.puppet.net
|
20
|
-
hostAliases:
|
21
|
-
|
22
|
-
|
23
|
-
|
26
|
+
:hostAliases:
|
27
|
+
- :ip: "169.254.169.254"
|
28
|
+
:hostnames:
|
29
|
+
- "metadata.google.internal"
|
30
|
+
:affinity:
|
31
|
+
:podAntiAffinity:
|
32
|
+
:preferredDuringSchedulingIgnoredDuringExecution:
|
33
|
+
- :weight: 100
|
34
|
+
:podAffinityTerm:
|
35
|
+
:labelSelector:
|
36
|
+
:matchLabels:
|
37
|
+
:project: puppet-agent-ci
|
38
|
+
:topologyKey: kubernetes.io/hostname
|
data/config/service.yaml
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
---
|
2
|
+
:apiVersion: v1
|
3
|
+
:kind: Service
|
4
|
+
:metadata:
|
5
|
+
:name: "%{pod_name}"
|
6
|
+
:namespace: gke-puppetagent-ci
|
7
|
+
:labels:
|
8
|
+
:app: "%{pod_name}"
|
9
|
+
:spec:
|
10
|
+
:selector:
|
11
|
+
:app: "%{pod_name}"
|
12
|
+
:clusterIP: "None"
|
data/lib/beaker-gke.rb
CHANGED
data/lib/beaker-gke/version.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'kubeclient'
|
2
|
-
require 'jsonpath'
|
3
|
-
require 'beaker'
|
4
4
|
require 'beaker-gke'
|
5
5
|
require 'googleauth'
|
6
|
+
require 'erb'
|
6
7
|
|
7
8
|
module Beaker
|
8
9
|
class Gke < Beaker::Hypervisor
|
9
|
-
SERVICE_NAMESPACE = 'gke-puppetagent-ci'
|
10
|
-
PROXY_IP = '10.236.0.3'
|
10
|
+
SERVICE_NAMESPACE = 'gke-puppetagent-ci'
|
11
|
+
PROXY_IP = '10.236.0.3'
|
11
12
|
PROXY_PORT = 8899
|
12
13
|
MAX_RETRIES = 5
|
13
14
|
# OS environment variable must be set to continue
|
@@ -18,12 +19,16 @@ module Beaker
|
|
18
19
|
begin
|
19
20
|
ENV.fetch('KUBECONFIG')
|
20
21
|
ENV.fetch('GOOGLE_APPLICATION_CREDENTIALS')
|
21
|
-
rescue
|
22
|
-
raise
|
22
|
+
rescue KeyError
|
23
|
+
raise(
|
24
|
+
ArgumentError,
|
25
|
+
'OS environment variable KUBECONFIG and GOOGLE_APPLICATION_CREDENTIALS must be set'
|
26
|
+
)
|
23
27
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
28
|
+
@hosts = hosts
|
29
|
+
@options = options
|
30
|
+
@client = client
|
31
|
+
@logger = options[:logger]
|
27
32
|
end
|
28
33
|
|
29
34
|
def provision
|
@@ -32,39 +37,43 @@ module Beaker
|
|
32
37
|
create_pod(hostname)
|
33
38
|
create_srv(hostname)
|
34
39
|
retries = 0
|
40
|
+
|
35
41
|
begin
|
36
42
|
pod = get_pod(hostname)
|
37
|
-
raise StandardError
|
43
|
+
raise StandardError unless pod.status.podIP
|
38
44
|
rescue StandardError => e
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
45
|
+
raise "Timeout: #{e.message}" unless retries <= MAX_RETRIES
|
46
|
+
|
47
|
+
@logger.info("Retrying , could not get podIP for #{hostname}")
|
48
|
+
|
49
|
+
retries += 1
|
50
|
+
sleep(2**retries)
|
43
51
|
retry
|
44
|
-
else
|
45
|
-
raise "Timeout: #{e.message}"
|
46
|
-
end
|
47
52
|
end
|
53
|
+
|
48
54
|
host[:vmhostname] = "#{hostname}.gke-puppetagent-ci.puppet.net"
|
49
55
|
host[:hostname] = hostname
|
50
56
|
host[:ip] = pod.status.podIP
|
57
|
+
host[:gke_container] = true
|
51
58
|
end
|
52
59
|
nil
|
53
60
|
end
|
54
61
|
|
55
62
|
def cleanup
|
56
63
|
@hosts.each do |host|
|
64
|
+
@logger.info("Deleting POD with ID: #{host[:hostname]}")
|
65
|
+
|
57
66
|
delete_pod(host[:hostname])
|
58
67
|
delete_service(host[:hostname])
|
59
68
|
end
|
60
69
|
end
|
61
70
|
|
62
|
-
def connection_preference(
|
63
|
-
[
|
71
|
+
def connection_preference(_host)
|
72
|
+
%i[ip vmhostname hostname]
|
64
73
|
end
|
65
74
|
|
66
75
|
def create_pod(name)
|
67
|
-
pod_config=read_symbols('pod.yaml',
|
76
|
+
pod_config = read_symbols('pod.yaml', pod_name: name)
|
68
77
|
@client.create_pod(pod_config)
|
69
78
|
end
|
70
79
|
|
@@ -73,24 +82,22 @@ module Beaker
|
|
73
82
|
end
|
74
83
|
|
75
84
|
def create_srv(name)
|
76
|
-
service_config=read_symbols('service.yaml',
|
85
|
+
service_config = read_symbols('service.yaml', pod_name: name)
|
77
86
|
@client.create_service(service_config)
|
78
87
|
end
|
79
88
|
|
80
89
|
def delete_pod(pod_name)
|
81
|
-
@client.delete_pod(
|
90
|
+
@client.delete_pod(
|
91
|
+
pod_name,
|
92
|
+
SERVICE_NAMESPACE,
|
93
|
+
delete_options: { 'force': 1, '--grace-period': 0 }
|
94
|
+
)
|
82
95
|
end
|
83
96
|
|
84
97
|
def delete_service(srv_name)
|
85
|
-
|
86
|
-
if srv_name.instance_of?(String)
|
87
|
-
client.delete_service(srv_name, SERVICE_NAMESPACE)
|
88
|
-
else
|
89
|
-
raise ArgumentError, 'Wrong argument type - #{srv_name.class}'
|
90
|
-
end
|
91
|
-
end
|
98
|
+
@client.delete_service(srv_name, SERVICE_NAMESPACE)
|
92
99
|
rescue Kubeclient::ResourceNotFoundError => e
|
93
|
-
|
100
|
+
@logger.info("Service #{srv_name} could not be deleted #{e}")
|
94
101
|
end
|
95
102
|
|
96
103
|
private
|
@@ -100,21 +107,20 @@ module Beaker
|
|
100
107
|
context = config.context
|
101
108
|
proxy_uri = URI::HTTP.build(host: PROXY_IP, port: PROXY_PORT)
|
102
109
|
Kubeclient::Client.new(
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
110
|
+
context.api_endpoint, 'v1',
|
111
|
+
http_proxy_uri: proxy_uri,
|
112
|
+
ssl_options: context.ssl_options,
|
113
|
+
auth_options: context.auth_options
|
107
114
|
)
|
108
115
|
end
|
109
116
|
|
110
117
|
def read_file(file_name)
|
111
|
-
|
112
|
-
File.read(path)
|
118
|
+
File.read(File.join(ROOT_DIR, 'config', file_name))
|
113
119
|
end
|
114
120
|
|
115
121
|
def read_symbols(file, substitution = {})
|
116
|
-
data = read_file(file)
|
117
|
-
Psych.load(data %substitution
|
122
|
+
data = ERB.new(read_file(file)).result
|
123
|
+
Psych.load(data % substitution, symbolize_names: true)
|
118
124
|
end
|
119
125
|
end
|
120
126
|
end
|
metadata
CHANGED
@@ -1,141 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker-gke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Night's Watch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3.0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '3.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec-its
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: fakefs
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0.6'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0.6'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rake
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '10.1'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '10.1'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: simplecov
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry
|
14
|
+
name: googleauth
|
85
15
|
requirement: !ruby/object:Gem::Requirement
|
86
16
|
requirements:
|
87
17
|
- - "~>"
|
88
18
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
90
|
-
type: :
|
19
|
+
version: '0.9'
|
20
|
+
type: :runtime
|
91
21
|
prerelease: false
|
92
22
|
version_requirements: !ruby/object:Gem::Requirement
|
93
23
|
requirements:
|
94
24
|
- - "~>"
|
95
25
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: yard
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: markdown
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: thin
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
26
|
+
version: '0.9'
|
139
27
|
- !ruby/object:Gem::Dependency
|
140
28
|
name: kubeclient
|
141
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,35 +38,7 @@ dependencies:
|
|
150
38
|
- - "~>"
|
151
39
|
- !ruby/object:Gem::Version
|
152
40
|
version: 4.4.0
|
153
|
-
|
154
|
-
name: jsonpath
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
type: :runtime
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: googleauth
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - ">="
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
174
|
-
type: :runtime
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - ">="
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
181
|
-
description: For use for the Beaker acceptance testing tool
|
41
|
+
description: Add GKE support to Beaker acceptance testing tool
|
182
42
|
email:
|
183
43
|
- team-nw@puppet.com
|
184
44
|
executables:
|
@@ -186,6 +46,7 @@ executables:
|
|
186
46
|
extensions: []
|
187
47
|
extra_rdoc_files: []
|
188
48
|
files:
|
49
|
+
- ".rubcop.yaml"
|
189
50
|
- CODEOWNERS
|
190
51
|
- Gemfile
|
191
52
|
- LICENSE
|
@@ -200,7 +61,7 @@ files:
|
|
200
61
|
- lib/beaker/hypervisor/gke.rb
|
201
62
|
homepage: https://github.com/puppetlabs/beaker-gke
|
202
63
|
licenses:
|
203
|
-
-
|
64
|
+
- Apache-2.0
|
204
65
|
metadata: {}
|
205
66
|
post_install_message:
|
206
67
|
rdoc_options: []
|
@@ -217,7 +78,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
78
|
- !ruby/object:Gem::Version
|
218
79
|
version: '0'
|
219
80
|
requirements: []
|
220
|
-
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.5.1
|
221
83
|
signing_key:
|
222
84
|
specification_version: 4
|
223
85
|
summary: Beaker hypervisor for GKE!
|