ruby-kubernetes-controller 0.2.4 → 0.3.0

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: 367cf0c821db043996230dbbd4f934616906dd8630874807c8e45000d777c640
4
- data.tar.gz: 40e5fae6ed73fedc968ade455f1a284fff4fff7fcb30cc846ea7781674ee5bc4
3
+ metadata.gz: 2062f2405d0d36ad772ace7721366404fb71507d9abfb27a34ca8b73315ee1e8
4
+ data.tar.gz: f82fbed50886984db3ee1a1ddc89684462cd7382ee4568d6a34b1807bb429e1c
5
5
  SHA512:
6
- metadata.gz: 6f7bada708d34d21ba9a120ab9d58fbce8d68ce40232af815cf38b6d2d6485561680e8e03c2123d087c1436d7d3bf20000d510bea66eef396c51975287a79c7c
7
- data.tar.gz: 31f582542b7a6e7d0a15196c254aca87b69411c740b1f812d3fed3f7d50b1b55ec3ed85e0be4d590eeddd000002b6530c4c177cb65fc1c0a90cd5d8019c1ad76
6
+ metadata.gz: 800feff4f19a022aa143c59b112ed785c3011143488d8f654320f652711504b347e0b7c2e20aae2083af89dfd1e454a71f23d1f5cce8491309d60696cb9a4c64
7
+ data.tar.gz: ab448d9edccdffcc4e78a481a40aeaa711bedac579fa597bdfb4e973b26ea3788759513e020897bca372bbc3f0b07c8e2aec9e4e49b838b21890410464c46350
@@ -2,7 +2,9 @@
2
2
 
3
3
  ## Pre-requisites
4
4
  Before beginning, you must generate a bearer token for the Ruby Kubernetes Controller to use:
5
-
5
+ If you want to read the bearer token that is in the pod instead of generating one to use,
6
+ pass in an empty string to bearer_token when calling
7
+ `::RubyKubernetesController::Client.new(endpoint, bearer_token, ssl)`
6
8
 
7
9
  1. Save the following as `serviceaccount.yaml` (file available [here][SERVICEACCOUNT])
8
10
  <p align="center"><img width=100% src="./serviceaccount.png"></p>
@@ -169,7 +171,7 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr
169
171
  json_config =
170
172
  '{
171
173
  "kind": "Ingress",
172
- "apiVersion": "extensions/v1beta1",
174
+ "apiVersion": "networking.k8s.io/v1beta1",
173
175
  ...
174
176
  }'
175
177
 
@@ -247,7 +249,7 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr
247
249
  json_update =
248
250
  '{
249
251
  "kind": "Ingress",
250
- "apiVersion": "extensions/v1beta1",
252
+ "apiVersion": "networking.k8s.io/v1beta1",
251
253
  ...
252
254
  }'
253
255
 
@@ -303,7 +305,7 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr
303
305
  json_options =
304
306
  '{
305
307
  "kind": "Ingress",
306
- "apiVersion": "extensions/v1beta1",
308
+ "apiVersion": "networking.k8s.io/v1beta1",
307
309
  ...
308
310
  }'
309
311
 
@@ -846,7 +848,7 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr
846
848
  json_config =
847
849
  '{
848
850
  "kind": "Deployment",
849
- "apiVersion": "extensions/v1beta1",
851
+ "apiVersion": "extensions/v1",
850
852
  ...
851
853
  }'
852
854
 
@@ -924,7 +926,7 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr
924
926
  json_update =
925
927
  '{
926
928
  "kind": "Deployment",
927
- "apiVersion": "extensions/v1beta1",
929
+ "apiVersion": "extensions/v1",
928
930
  ...
929
931
  }'
930
932
 
@@ -980,7 +982,7 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr
980
982
  json_options =
981
983
  '{
982
984
  "kind": "Deployment",
983
- "apiVersion": "extensions/v1beta1",
985
+ "apiVersion": "extensions/v1",
984
986
  ...
985
987
  }'
986
988
 
@@ -1011,7 +1013,7 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr
1011
1013
  json_config =
1012
1014
  '{
1013
1015
  "kind": "Replicaset",
1014
- "apiVersion": "extensions/v1beta1",
1016
+ "apiVersion": "apps/v1",
1015
1017
  ...
1016
1018
  }'
1017
1019
 
@@ -1089,7 +1091,7 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr
1089
1091
  json_update =
1090
1092
  '{
1091
1093
  "kind": "Replicaset",
1092
- "apiVersion": "extensions/v1beta1",
1094
+ "apiVersion": "apps/v1",
1093
1095
  ...
1094
1096
  }'
1095
1097
 
@@ -1145,7 +1147,7 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr
1145
1147
  json_options =
1146
1148
  '{
1147
1149
  "kind": "Replicaset",
1148
- "apiVersion": "extensions/v1beta1",
1150
+ "apiVersion": "apps/v1",
1149
1151
  ...
1150
1152
  }'
1151
1153
 
@@ -1651,7 +1653,7 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr
1651
1653
  json_config =
1652
1654
  '{
1653
1655
  "kind": "Job",
1654
- "apiVersion": "extensions/v1beta1",
1656
+ "apiVersion": "batch/v1",
1655
1657
  ...
1656
1658
  }'
1657
1659
 
@@ -1728,7 +1730,7 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr
1728
1730
  json_update =
1729
1731
  '{
1730
1732
  "kind": "Job",
1731
- "apiVersion": "extensions/v1beta1",
1733
+ "apiVersion": "batch/v1",
1732
1734
  ...
1733
1735
  }'
1734
1736
 
@@ -1784,7 +1786,7 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr
1784
1786
  json_options =
1785
1787
  '{
1786
1788
  "kind": "Job",
1787
- "apiVersion": "extensions/v1beta1",
1789
+ "apiVersion": "batch/v1",
1788
1790
  ...
1789
1791
  }'
1790
1792
 
@@ -46,6 +46,7 @@ module RubyKubernetesController
46
46
  # Instantiating client variables
47
47
  @endpoint = endpoint
48
48
  @bearer_token = bearer_token
49
+ @bearer_token = default_serviceaccount_token if bearer_token.empty?
49
50
  @ssl = ssl
50
51
  @yaml = yaml
51
52
  end
@@ -64,5 +65,14 @@ module RubyKubernetesController
64
65
  def getSSL
65
66
  @ssl
66
67
  end
68
+
69
+ # Reads the Bearer Token from the pod
70
+ private
71
+
72
+ def default_serviceaccount_token
73
+ return "" unless File.exist?("/var/run/secrets/kubernetes.io/serviceaccount/token")
74
+
75
+ File.read("/var/run/secrets/kubernetes.io/serviceaccount/token")
76
+ end
67
77
  end
68
- end
78
+ end
@@ -10,7 +10,7 @@ module Deployments
10
10
 
11
11
  # Create new Deployment
12
12
  def create_new_deployment(namespace, config)
13
- extension = "/apis/apps/v1beta1/namespaces/#{namespace}/deployments"
13
+ extension = "/apis/apps/v1/namespaces/#{namespace}/deployments"
14
14
 
15
15
  uri = prepareURI(@endpoint, extension)
16
16
 
@@ -38,7 +38,7 @@ module Deployments
38
38
 
39
39
  # Get all Deployments
40
40
  def get_all_deployments
41
- extension = "/apis/apps/v1beta1/deployments"
41
+ extension = "/apis/apps/v1/deployments"
42
42
 
43
43
  uri = prepareURI(@endpoint, extension)
44
44
 
@@ -59,7 +59,7 @@ module Deployments
59
59
 
60
60
  # Get all existing Deployments in Namespace
61
61
  def get_all_namespaced_deployments(namespace)
62
- extension = "/apis/apps/v1beta1/namespaces/#{namespace}/deployments"
62
+ extension = "/apis/apps/v1/namespaces/#{namespace}/deployments"
63
63
 
64
64
  uri = prepareURI(@endpoint, extension)
65
65
 
@@ -80,7 +80,7 @@ module Deployments
80
80
 
81
81
  # Get single Deployment in Namespace
82
82
  def get_single_namespaced_deployment(namespace, deployment_name)
83
- extension = "/apis/apps/v1beta1/namespaces/#{namespace}/deployments/#{deployment_name}"
83
+ extension = "/apis/apps/v1/namespaces/#{namespace}/deployments/#{deployment_name}"
84
84
 
85
85
  uri = prepareURI(@endpoint, extension)
86
86
 
@@ -100,7 +100,7 @@ module Deployments
100
100
 
101
101
  # Update existing Deployment in Namespace
102
102
  def update_namespaced_deployment(namespace, deployment_name, update)
103
- extension = "/apis/apps/v1beta1/namespaces/#{namespace}/deployments/#{deployment_name}"
103
+ extension = "/apis/apps/v1/namespaces/#{namespace}/deployments/#{deployment_name}"
104
104
 
105
105
  uri = prepareURI(@endpoint, extension)
106
106
 
@@ -129,7 +129,7 @@ module Deployments
129
129
 
130
130
  # Patch existing Deployment in Namespace
131
131
  def patch_deployment(namespace, deployment_name, patch)
132
- extension = "/apis/apps/v1beta1/namespaces/#{namespace}/deployments/#{deployment_name}"
132
+ extension = "/apis/apps/v1/namespaces/#{namespace}/deployments/#{deployment_name}"
133
133
 
134
134
  uri = prepareURI(@endpoint, extension)
135
135
 
@@ -152,7 +152,7 @@ module Deployments
152
152
 
153
153
  # Delete existing Deployment in Namespace
154
154
  def delete_deployment(namespace, deployment_name, options = '')
155
- extension = "/apis/apps/v1beta1/namespaces/#{namespace}/deployments/#{deployment_name}"
155
+ extension = "/apis/apps/v1/namespaces/#{namespace}/deployments/#{deployment_name}"
156
156
 
157
157
  uri = prepareURI(@endpoint, extension)
158
158
 
@@ -10,7 +10,7 @@ module Ingresses
10
10
 
11
11
  # Create new Ingress
12
12
  def create_new_ingress(namespace, config)
13
- extension = "/apis/extensions/v1beta1/namespaces/#{namespace}/ingresses"
13
+ extension = "/apis/networking.k8s.io/v1beta1/namespaces/#{namespace}/ingresses"
14
14
 
15
15
  uri = prepareURI(@endpoint, extension)
16
16
 
@@ -38,7 +38,7 @@ module Ingresses
38
38
 
39
39
  # Get all Ingresses
40
40
  def get_all_ingresses
41
- extension = "/apis/extensions/v1beta1/ingresses"
41
+ extension = "/apis/networking.k8s.io/v1beta1/ingresses"
42
42
 
43
43
  uri = prepareURI(@endpoint, extension)
44
44
 
@@ -59,7 +59,7 @@ module Ingresses
59
59
 
60
60
  # Get all existing Ingresses in Namespace
61
61
  def get_all_namespaced_ingresses(namespace)
62
- extension = "/apis/extensions/v1beta1/namespaces/#{namespace}/ingresses"
62
+ extension = "/apis/networking.k8s.io/v1beta1/namespaces/#{namespace}/ingresses"
63
63
 
64
64
  uri = prepareURI(@endpoint, extension)
65
65
 
@@ -80,7 +80,7 @@ module Ingresses
80
80
 
81
81
  # Get single Ingress in Namespace
82
82
  def get_single_namespaced_ingress(namespace, ingress_name)
83
- extension = "/apis/extensions/v1beta1/namespaces/#{namespace}/ingresses/#{ingress_name}"
83
+ extension = "/apis/networking.k8s.io/v1beta1/namespaces/#{namespace}/ingresses/#{ingress_name}"
84
84
 
85
85
  uri = prepareURI(@endpoint, extension)
86
86
 
@@ -100,7 +100,7 @@ module Ingresses
100
100
 
101
101
  # Update existing Ingress in Namespace
102
102
  def update_namespaced_ingress(namespace, ingress_name, update)
103
- extension = "/apis/extensions/v1beta1/namespaces/#{namespace}/ingresses/#{ingress_name}"
103
+ extension = "/apis/networking.k8s.io/v1beta1/namespaces/#{namespace}/ingresses/#{ingress_name}"
104
104
 
105
105
  uri = prepareURI(@endpoint, extension)
106
106
 
@@ -128,7 +128,7 @@ module Ingresses
128
128
 
129
129
  # Patch existing Ingress
130
130
  def patch_ingress(namespace, ingress_name, patch)
131
- extension = "/apis/extensions/v1beta1/namespaces/#{namespace}/ingresses/#{ingress_name}"
131
+ extension = "/apis/networking.k8s.io/v1beta1/namespaces/#{namespace}/ingresses/#{ingress_name}"
132
132
 
133
133
  uri = prepareURI(@endpoint, extension)
134
134
 
@@ -151,7 +151,7 @@ module Ingresses
151
151
 
152
152
  # Delete existing Namespace
153
153
  def delete_ingress(namespace, ingress_name, options = '')
154
- extension = "/apis/extensions/v1beta1/namespaces/#{namespace}/ingresses/#{ingress_name}"
154
+ extension = "/apis/networking.k8s.io/v1beta1/namespaces/#{namespace}/ingresses/#{ingress_name}"
155
155
 
156
156
  uri = prepareURI(@endpoint, extension)
157
157
 
@@ -11,7 +11,7 @@ module ReplicaSets
11
11
 
12
12
  # Create new ReplicaSet
13
13
  def create_new_replicaset(namespace, config)
14
- extension = "/apis/extensions/v1beta1/namespaces/#{namespace}/replicasets"
14
+ extension = "/apis/apps/v1/namespaces/#{namespace}/replicasets"
15
15
 
16
16
  uri = prepareURI(@endpoint, extension)
17
17
 
@@ -39,7 +39,7 @@ module ReplicaSets
39
39
 
40
40
  # Get all ReplicaSets
41
41
  def get_all_replicasets
42
- extension = "/apis/extensions/v1beta1/replicasets"
42
+ extension = "/apis/apps/v1/replicasets"
43
43
 
44
44
  uri = prepareURI(@endpoint, extension)
45
45
 
@@ -60,7 +60,7 @@ module ReplicaSets
60
60
 
61
61
  # Get all existing ReplicaSets in Namespace
62
62
  def get_all_namespaced_replicasets(namespace)
63
- extension = "/apis/extensions/v1beta1/namespaces/#{namespace}/replicasets"
63
+ extension = "/apis/apps/v1/namespaces/#{namespace}/replicasets"
64
64
 
65
65
  uri = prepareURI(@endpoint, extension)
66
66
 
@@ -81,7 +81,7 @@ module ReplicaSets
81
81
 
82
82
  # Get single ReplicaSet in Namespace
83
83
  def get_single_namespaced_replicaset(namespace, replicaset_name)
84
- extension = "/apis/extensions/v1beta1/namespaces/#{namespace}/replicasets/#{replicaset_name}"
84
+ extension = "/apis/apps/v1/namespaces/#{namespace}/replicasets/#{replicaset_name}"
85
85
 
86
86
  uri = prepareURI(@endpoint, extension)
87
87
 
@@ -101,7 +101,7 @@ module ReplicaSets
101
101
 
102
102
  # Update existing ReplicaSet in Namespace
103
103
  def update_namespaced_replicaset(namespace, replicaset_name, update)
104
- extension = "/apis/extensions/v1beta1/namespaces/#{namespace}/replicasets/#{replicaset_name}"
104
+ extension = "/apis/apps/v1/namespaces/#{namespace}/replicasets/#{replicaset_name}"
105
105
 
106
106
  uri = prepareURI(@endpoint, extension)
107
107
 
@@ -129,7 +129,7 @@ module ReplicaSets
129
129
 
130
130
  # Patch existing ReplicaSet
131
131
  def patch_replicaset(namespace, replicaset_name, patch)
132
- extension = "/apis/extensions/v1beta1/namespaces/#{namespace}/replicasets/#{replicaset_name}"
132
+ extension = "/apis/apps/v1/namespaces/#{namespace}/replicasets/#{replicaset_name}"
133
133
 
134
134
  uri = prepareURI(@endpoint, extension)
135
135
 
@@ -152,7 +152,7 @@ module ReplicaSets
152
152
 
153
153
  # Delete existing Namespace
154
154
  def delete_replicaset(namespace, replicaset_name, options = '')
155
- extension = "/apis/extensions/v1beta1/namespaces/#{namespace}/replicasets/#{replicaset_name}"
155
+ extension = "/apis/apps/v1/namespaces/#{namespace}/replicasets/#{replicaset_name}"
156
156
 
157
157
  uri = prepareURI(@endpoint, extension)
158
158
 
@@ -1,4 +1,4 @@
1
1
  # Part of the RubyKubernetesController module
2
2
  module RubyKubernetesController
3
- VERSION = "0.2.4"
3
+ VERSION = "0.3.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-kubernetes-controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shivansh Vij (ShivanshVij)
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2020-07-30 00:00:00.000000000 Z
13
+ date: 2020-10-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler