kubeclient 0.3.0 → 4.9.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of kubeclient might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.github/workflows/actions.yml +35 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +29 -0
- data/CHANGELOG.md +208 -0
- data/Gemfile +3 -0
- data/README.md +706 -57
- data/RELEASING.md +69 -0
- data/Rakefile +3 -5
- data/kubeclient.gemspec +19 -11
- data/lib/kubeclient/aws_eks_credentials.rb +46 -0
- data/lib/kubeclient/common.rb +597 -161
- data/lib/kubeclient/config.rb +195 -0
- data/lib/kubeclient/entity_list.rb +7 -2
- data/lib/kubeclient/exec_credentials.rb +89 -0
- data/lib/kubeclient/gcp_auth_provider.rb +19 -0
- data/lib/kubeclient/gcp_command_credentials.rb +31 -0
- data/lib/kubeclient/google_application_default_credentials.rb +31 -0
- data/lib/kubeclient/http_error.rb +25 -0
- data/lib/kubeclient/missing_kind_compatibility.rb +68 -0
- data/lib/kubeclient/oidc_auth_provider.rb +52 -0
- data/lib/kubeclient/resource.rb +11 -0
- data/lib/kubeclient/resource_not_found_error.rb +4 -0
- data/lib/kubeclient/version.rb +1 -1
- data/lib/kubeclient/watch_stream.rb +71 -28
- data/lib/kubeclient.rb +25 -82
- metadata +140 -114
- data/.travis.yml +0 -6
- data/lib/kubeclient/kube_exception.rb +0 -13
- data/lib/kubeclient/watch_notice.rb +0 -7
- data/test/json/created_namespace_b3.json +0 -20
- data/test/json/created_secret.json +0 -16
- data/test/json/created_service_b3.json +0 -31
- data/test/json/empty_pod_list_b3.json +0 -9
- data/test/json/endpoint_list_b3.json +0 -48
- data/test/json/entity_list_b3.json +0 -56
- data/test/json/event_list_b3.json +0 -35
- data/test/json/namespace_b3.json +0 -13
- data/test/json/namespace_exception_b3.json +0 -8
- data/test/json/namespace_list_b3.json +0 -32
- data/test/json/node_b3.json +0 -29
- data/test/json/node_list_b3.json +0 -37
- data/test/json/pod_b3.json +0 -92
- data/test/json/pod_list_b3.json +0 -75
- data/test/json/replication_controller_b3.json +0 -57
- data/test/json/replication_controller_list_b3.json +0 -64
- data/test/json/secret_list_b3.json +0 -44
- data/test/json/service_b3.json +0 -33
- data/test/json/service_illegal_json_404.json +0 -1
- data/test/json/service_list_b3.json +0 -97
- data/test/json/service_update_b3.json +0 -22
- data/test/json/versions_list.json +0 -6
- data/test/json/watch_stream_b3.json +0 -3
- data/test/test_helper.rb +0 -4
- data/test/test_kubeclient.rb +0 -407
- data/test/test_namespace.rb +0 -53
- data/test/test_node.rb +0 -25
- data/test/test_pod.rb +0 -21
- data/test/test_replication_controller.rb +0 -24
- data/test/test_secret.rb +0 -58
- data/test/test_service.rb +0 -136
- data/test/test_watch.rb +0 -37
- data/test/valid_token_file +0 -1
data/RELEASING.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Releasing Kubeclient
|
2
|
+
|
3
|
+
## Versioning
|
4
|
+
Kubeclient release versioning follows [SemVer](https://semver.org/).
|
5
|
+
At some point in time it is decided to release version x.y.z.
|
6
|
+
|
7
|
+
```bash
|
8
|
+
RELEASE_BRANCH="master"
|
9
|
+
```
|
10
|
+
|
11
|
+
## 0. (once) Install gem-release, needed for several commands here:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
gem install gem-release
|
15
|
+
```
|
16
|
+
|
17
|
+
## 1. PR(s) for changelog & bump
|
18
|
+
|
19
|
+
Edit `CHANGELOG.md` as necessary. Even if all included changes remembered to update it, you should replace "Unreleased" section header with appropriate "x.y.z — 20yy-mm-dd" header.
|
20
|
+
|
21
|
+
Bump `lib/kubeclient/version.rb` manually, or by using:
|
22
|
+
```bash
|
23
|
+
RELEASE_VERSION=x.y.z
|
24
|
+
|
25
|
+
git checkout -b "release-$RELEASE_VERSION" $RELEASE_BRANCH
|
26
|
+
# Won't work with uncommitted changes, you have to commit the changelog first.
|
27
|
+
gem bump --version $RELEASE_VERSION
|
28
|
+
git show # View version bump change.
|
29
|
+
```
|
30
|
+
|
31
|
+
Open a PR with target branch $RELEASE_BRANCH and get it reviewed & merged (if open for long, remember to update date in CHANGELOG to actual day of release).
|
32
|
+
|
33
|
+
## 2. (once) Grabbing an authentication token for rubygems.org api
|
34
|
+
```bash
|
35
|
+
RUBYGEMS_USERNAME=bob
|
36
|
+
curl -u $RUBYGEMS_USERNAME https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials; chmod 0600 ~/.gem/credentials
|
37
|
+
|
38
|
+
cat ~/.gem/credentials
|
39
|
+
# Should look like this:
|
40
|
+
:rubygems_api_key: ****
|
41
|
+
```
|
42
|
+
|
43
|
+
## 3. Actual release
|
44
|
+
|
45
|
+
Make sure we're locally after the bump PR *merge commit*:
|
46
|
+
```bash
|
47
|
+
git checkout $RELEASE_BRANCH
|
48
|
+
git status # Make sure there are no local changes
|
49
|
+
git pull --ff-only https://github.com/abonas/kubeclient $RELEASE_BRANCH
|
50
|
+
git log -n1
|
51
|
+
```
|
52
|
+
|
53
|
+
Last sanity check:
|
54
|
+
```bash
|
55
|
+
bundle install
|
56
|
+
bundle exec rake test rubocop
|
57
|
+
```
|
58
|
+
|
59
|
+
Create and push the tag:
|
60
|
+
```bash
|
61
|
+
gem tag --no-push
|
62
|
+
git push --tags --dry-run https://github.com/abonas/kubeclient # Check for unexpected tags
|
63
|
+
git push --tags https://github.com/abonas/kubeclient
|
64
|
+
```
|
65
|
+
|
66
|
+
Release onto rubygems.org:
|
67
|
+
```bash
|
68
|
+
gem release
|
69
|
+
```
|
data/Rakefile
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'rubocop/rake_task'
|
4
|
+
require 'yaml'
|
4
5
|
|
5
|
-
task default: [
|
6
|
-
|
7
|
-
Rake::TestTask.new do |t|
|
8
|
-
t.libs << 'test'
|
9
|
-
end
|
6
|
+
task default: %i[test rubocop] # same as .travis.yml
|
10
7
|
|
8
|
+
Rake::TestTask.new
|
11
9
|
RuboCop::RakeTask.new
|
data/kubeclient.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'kubeclient/version'
|
@@ -13,19 +14,26 @@ Gem::Specification.new do |spec|
|
|
13
14
|
spec.homepage = 'https://github.com/abonas/kubeclient'
|
14
15
|
spec.license = 'MIT'
|
15
16
|
|
16
|
-
|
17
|
+
git_files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.files = git_files.grep_v(%r{^(test|spec|features)/})
|
17
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files =
|
20
|
+
spec.test_files = []
|
19
21
|
spec.require_paths = ['lib']
|
20
|
-
spec.required_ruby_version = '>= 2.
|
22
|
+
spec.required_ruby_version = '>= 2.2.0'
|
21
23
|
|
22
|
-
spec.add_development_dependency 'bundler', '
|
23
|
-
spec.add_development_dependency 'rake', '~>
|
24
|
+
spec.add_development_dependency 'bundler', '>= 1.6'
|
25
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
24
26
|
spec.add_development_dependency 'minitest'
|
25
|
-
spec.add_development_dependency '
|
26
|
-
spec.add_development_dependency '
|
27
|
-
spec.
|
28
|
-
spec.
|
29
|
-
spec.
|
30
|
-
spec.
|
27
|
+
spec.add_development_dependency 'minitest-rg'
|
28
|
+
spec.add_development_dependency 'webmock', '~> 3.0'
|
29
|
+
spec.add_development_dependency 'vcr'
|
30
|
+
spec.add_development_dependency 'rubocop', '= 0.49.1'
|
31
|
+
spec.add_development_dependency 'googleauth', '~> 0.5.1'
|
32
|
+
spec.add_development_dependency('mocha', '~> 1.5')
|
33
|
+
spec.add_development_dependency 'openid_connect', '~> 1.1'
|
34
|
+
|
35
|
+
spec.add_dependency 'jsonpath', '~> 1.0'
|
36
|
+
spec.add_dependency 'rest-client', '~> 2.0'
|
37
|
+
spec.add_dependency 'recursive-open-struct', '~> 1.1', '>= 1.1.1'
|
38
|
+
spec.add_dependency 'http', '>= 3.0', '< 5.0'
|
31
39
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kubeclient
|
4
|
+
# Get a bearer token to authenticate against aws eks.
|
5
|
+
class AmazonEksCredentials
|
6
|
+
class AmazonEksDependencyError < LoadError # rubocop:disable Lint/InheritException
|
7
|
+
end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def token(credentials, eks_cluster)
|
11
|
+
begin
|
12
|
+
require 'aws-sigv4'
|
13
|
+
require 'base64'
|
14
|
+
require 'cgi'
|
15
|
+
rescue LoadError => e
|
16
|
+
raise AmazonEksDependencyError,
|
17
|
+
'Error requiring aws gems. Kubeclient itself does not include the following ' \
|
18
|
+
'gems: [aws-sigv4]. To support auth-provider eks, you must ' \
|
19
|
+
"include it in your calling application. Failed with: #{e.message}"
|
20
|
+
end
|
21
|
+
# https://github.com/aws/aws-sdk-ruby/pull/1848
|
22
|
+
# Get a signer
|
23
|
+
# Note - sts only has ONE endpoint (not regional) so 'us-east-1' hardcoding should be OK
|
24
|
+
signer = Aws::Sigv4::Signer.new(
|
25
|
+
service: 'sts',
|
26
|
+
region: 'us-east-1',
|
27
|
+
credentials: credentials
|
28
|
+
)
|
29
|
+
|
30
|
+
# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Sigv4/Signer.html#presign_url-instance_method
|
31
|
+
presigned_url_string = signer.presign_url(
|
32
|
+
http_method: 'GET',
|
33
|
+
url: 'https://sts.amazonaws.com/?Action=GetCallerIdentity&Version=2011-06-15',
|
34
|
+
body: '',
|
35
|
+
credentials: credentials,
|
36
|
+
expires_in: 60,
|
37
|
+
headers: {
|
38
|
+
'X-K8s-Aws-Id' => eks_cluster
|
39
|
+
}
|
40
|
+
)
|
41
|
+
kube_token = 'k8s-aws-v1.' + Base64.urlsafe_encode64(presigned_url_string.to_s).sub(/=*$/, '') # rubocop:disable Metrics/LineLength
|
42
|
+
kube_token
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|