kubernator 1.0.17__py3-none-any.whl → 1.0.18__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of kubernator might be problematic. Click here for more details.

kubernator/__init__.py CHANGED
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- __version__ = "1.0.17"
19
+ __version__ = "1.0.18"
20
20
 
21
21
 
22
22
  def _main():
@@ -53,6 +53,9 @@ class IstioPlugin(KubernatorPlugin, K8SResourcePluginMixin):
53
53
  self.client_version = None
54
54
  self.server_version = None
55
55
  self.provision_operator = False
56
+ self.install = False
57
+ self.upgrade = False
58
+ self.upgrade_from_operator = False
56
59
  self.template_engine = TemplateEngine(logger)
57
60
 
58
61
  self.istioctl_dir = None
@@ -133,25 +136,41 @@ class IstioPlugin(KubernatorPlugin, K8SResourcePluginMixin):
133
136
  context = self.context
134
137
 
135
138
  version, version_out_js = self.test_istioctl()
136
- self.client_version = tuple(version.split("."))
137
- mesh_versions = set(tuple(m.value.split(".")) for m in MESH_PILOT_JP.find(version_out_js))
139
+ self.client_version = tuple(map(int, version.split(".")))
140
+ mesh_versions = set(tuple(map(int, m.value.split("."))) for m in MESH_PILOT_JP.find(version_out_js))
138
141
 
139
142
  if mesh_versions:
140
143
  self.server_version = max(mesh_versions)
141
144
 
142
145
  if not self.server_version:
143
146
  logger.info("No Istio mesh has been found and it'll be created")
147
+ self.install = True
144
148
  self.provision_operator = True
145
- elif self.server_version < self.client_version:
146
- logger.info("Istio client is version %s while server is up to %s - operator will be upgraded",
147
- ".".join(self.client_version),
148
- ".".join(self.server_version))
149
+ elif self.server_version != self.client_version:
150
+ logger.info("Istio client is version %s while server is up to %s - up/downgrade will be performed",
151
+ ".".join(map(str, self.client_version)),
152
+ ".".join(map(str, self.server_version)))
153
+ self.upgrade = True
149
154
  self.provision_operator = True
150
155
 
156
+ if self.client_version >= (1, 24, 0):
157
+ # No more operator in 1.24.0+
158
+ self.provision_operator = False
159
+
160
+ if self.upgrade and (self.client_version >= (1, 24, 0) > self.server_version):
161
+ self.upgrade_from_operator = True
162
+
163
+ if self.upgrade and (self.client_version < (1, 24, 0) <= self.server_version):
164
+ raise ValueError(f"Unable to downgrade Istio from {self.server_version} to {self.client_version}")
165
+
151
166
  # Register Istio-related CRDs with K8S
167
+ if self.client_version >= (1, 24, 0):
168
+ crd_path = "manifests/charts/base/files/crd-all.gen.yaml"
169
+ else:
170
+ crd_path = "manifests/charts/base/crds/crd-all.gen.yaml"
152
171
  self.context.k8s.load_remote_crds(
153
- f"https://raw.githubusercontent.com/istio/istio/{'.'.join(self.client_version)}/"
154
- "manifests/charts/base/crds/crd-all.gen.yaml", "yaml")
172
+ f"https://raw.githubusercontent.com/istio/istio/{'.'.join(map(str, self.client_version))}/{crd_path}",
173
+ "yaml")
155
174
 
156
175
  # This plugin only deals with Istio Operator, so only load that stuff
157
176
  self.resource_definitions_schema = load_remote_file(logger,
@@ -161,8 +180,10 @@ class IstioPlugin(KubernatorPlugin, K8SResourcePluginMixin):
161
180
  FileType.JSON)
162
181
  self._populate_resource_definitions()
163
182
 
164
- self.add_remote_crds(f"https://raw.githubusercontent.com/istio/istio/{'.'.join(self.client_version)}/"
165
- f"manifests/charts/istio-operator/crds/crd-operator.yaml", FileType.YAML)
183
+ crd_operator_version = (1, 23, 4) if self.client_version >= (1, 24, 0) else self.client_version
184
+ self.add_remote_crds(
185
+ f"https://raw.githubusercontent.com/istio/istio/{'.'.join(map(str, crd_operator_version))}/"
186
+ f"manifests/charts/istio-operator/crds/crd-operator.yaml", FileType.YAML)
166
187
 
167
188
  # Exclude Istio YAMLs from K8S resource loading
168
189
  context.k8s.default_excludes.add("*.istio.yaml")
@@ -211,40 +232,117 @@ class IstioPlugin(KubernatorPlugin, K8SResourcePluginMixin):
211
232
  context.app.run(context.istio.stanza() + ["validate", "-f", operators_file.name],
212
233
  stdout_logger, stderr_logger).wait()
213
234
 
214
- self._operator_init(operators_file, True)
215
-
216
- if not context.app.args.dry_run:
217
- self._operator_init(operators_file, False)
218
-
219
- def _operator_init(self, operators_file, dry_run):
235
+ dry_run = context.app.args.dry_run
236
+
237
+ if self.provision_operator:
238
+ self._create_istio_system_ns(True)
239
+ self._operator_init(operators_file, True)
240
+
241
+ if not dry_run:
242
+ self._create_istio_system_ns(False)
243
+ self._operator_init(operators_file, False)
244
+ elif self.install:
245
+ self._install(operators_file, True)
246
+
247
+ if not dry_run:
248
+ self._install(operators_file, False)
249
+ elif self.upgrade:
250
+ def _upgrade(dry_run):
251
+ if self.upgrade_from_operator:
252
+ # delete deployment -n istio-system istio-operator
253
+ self._delete_resource_internal({"apiVersion": "apps/v1",
254
+ "kind": "Deployment",
255
+ "metadata":
256
+ {
257
+ "namespace": "istio-system",
258
+ "name": "istio-operator"
259
+ }
260
+ }, dry_run, True)
261
+ self._upgrade(operators_file, dry_run)
262
+
263
+ _upgrade(True)
264
+ if not dry_run:
265
+ _upgrade(False)
266
+
267
+ def _delete_resource_internal(self, manifest, dry_run=True, missing_ok=False):
220
268
  from kubernetes import client
221
269
  from kubernetes.client.rest import ApiException
222
270
 
223
271
  context = self.context
272
+ k8s_client = context.k8s.client
224
273
 
225
- status_details = " (dry run)" if dry_run else ""
274
+ res = self._create_resource(manifest)
275
+ res.rdef.populate_api(client, k8s_client)
276
+ try:
277
+ res.delete(dry_run=dry_run)
278
+ except ApiException as e:
279
+ skip = False
280
+ if e.status == 404 and missing_ok:
281
+ skip = True
282
+ if not skip:
283
+ raise
284
+ return res
285
+
286
+ def _create_resource_internal(self, manifest, dry_run=True, exists_ok=False):
287
+ from kubernetes import client
288
+ from kubernetes.client.rest import ApiException
226
289
 
290
+ context = self.context
227
291
  k8s_client = context.k8s.client
228
- logger.info("Creating istio-system namespace%s", status_details)
229
- istio_system = self.add_resource({"apiVersion": "v1",
230
- "kind": "Namespace",
231
- "metadata": {
232
- "labels": {
233
- "istio-injection": "disabled"
234
- },
235
- "name": "istio-system"
236
- }})
237
- istio_system.rdef.populate_api(client, k8s_client)
292
+
293
+ res = self._create_resource(manifest)
294
+ res.rdef.populate_api(client, k8s_client)
238
295
  try:
239
- istio_system.create(dry_run=dry_run)
296
+ res.create(dry_run=dry_run)
240
297
  except ApiException as e:
241
298
  skip = False
242
299
  if e.status == 409:
243
300
  status = json.loads(e.body)
244
- if status["reason"] == "AlreadyExists":
301
+ if status["reason"] == "AlreadyExists" and exists_ok:
245
302
  skip = True
246
303
  if not skip:
247
304
  raise
305
+ return res
306
+
307
+ def _install(self, operators_file, dry_run):
308
+ context = self.context
309
+ status_details = " (dry run)" if dry_run else ""
310
+
311
+ logger.info("Running Istio install%s", status_details)
312
+ istio_install_cmd = context.istio.stanza() + ["install", "-f", operators_file.name, "-y", "--verify"]
313
+ context.app.run(istio_install_cmd + (["--dry-run"] if dry_run else []),
314
+ stdout_logger,
315
+ stderr_logger).wait()
316
+
317
+ def _upgrade(self, operators_file, dry_run):
318
+ context = self.context
319
+ status_details = " (dry run)" if dry_run else ""
320
+
321
+ logger.info("Running Istio upgrade%s", status_details)
322
+ istio_upgrade_cmd = context.istio.stanza() + ["upgrade", "-f", operators_file.name, "-y", "--verify"]
323
+ context.app.run(istio_upgrade_cmd + (["--dry-run"] if dry_run else []),
324
+ stdout_logger,
325
+ stderr_logger).wait()
326
+
327
+ def _create_istio_system_ns(self, dry_run):
328
+ status_details = " (dry run)" if dry_run else ""
329
+ logger.info("Creating istio-system namespace%s", status_details)
330
+ self._create_resource_internal({"apiVersion": "v1",
331
+ "kind": "Namespace",
332
+ "metadata": {
333
+ "labels": {
334
+ "istio-injection": "disabled"
335
+ },
336
+ "name": "istio-system"
337
+ }
338
+ },
339
+ dry_run=dry_run,
340
+ exists_ok=True
341
+ )
342
+
343
+ def _operator_init(self, operators_file, dry_run):
344
+ context = self.context
345
+ status_details = " (dry run)" if dry_run else ""
248
346
 
249
347
  logger.info("Running Istio operator init%s", status_details)
250
348
  istio_operator_init = context.istio.stanza() + ["operator", "init", "-f", operators_file.name]
@@ -206,7 +206,12 @@ class MinikubePlugin(KubernatorPlugin):
206
206
  minikube = self.context.minikube
207
207
  if self.minikube_is_running():
208
208
  logger.info("Shutting down minikube profile %r...", minikube.profile)
209
- self.cmd("stop", "-o", "json")
209
+ try:
210
+ self.cmd("stop", "-o", "json")
211
+ except CalledProcessError as e:
212
+ # Workaround for minikube 1.35.0 https://github.com/kubernetes/minikube/issues/20302
213
+ if e.returncode != 82:
214
+ raise
210
215
 
211
216
  def minikube_delete(self):
212
217
  minikube = self.context.minikube
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: kubernator
3
- Version: 1.0.17
3
+ Version: 1.0.18
4
4
  Summary: Kubernator is the a pluggable framework for K8S provisioning
5
5
  Home-page: https://github.com/karellen/kubernator
6
6
  Author: Express Systems USA, Inc.
@@ -17,6 +17,7 @@ Classifier: Programming Language :: Python :: 3.9
17
17
  Classifier: Programming Language :: Python :: 3.10
18
18
  Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
20
21
  Classifier: Operating System :: MacOS :: MacOS X
21
22
  Classifier: Operating System :: POSIX
22
23
  Classifier: Operating System :: POSIX :: Linux
@@ -40,11 +41,24 @@ Requires-Dist: json-log-formatter~=0.3
40
41
  Requires-Dist: jsonpatch~=1.32
41
42
  Requires-Dist: jsonpath-ng~=1.6.1
42
43
  Requires-Dist: jsonschema<4.0
43
- Requires-Dist: kubernetes~=30.0
44
+ Requires-Dist: kubernetes~=31.0
44
45
  Requires-Dist: openapi-schema-validator~=0.1
45
46
  Requires-Dist: openapi-spec-validator~=0.3
46
47
  Requires-Dist: platformdirs~=4.2
47
48
  Requires-Dist: requests<=2.31.0
49
+ Dynamic: author
50
+ Dynamic: classifier
51
+ Dynamic: description
52
+ Dynamic: description-content-type
53
+ Dynamic: home-page
54
+ Dynamic: keywords
55
+ Dynamic: license
56
+ Dynamic: maintainer
57
+ Dynamic: maintainer-email
58
+ Dynamic: project-url
59
+ Dynamic: requires-dist
60
+ Dynamic: requires-python
61
+ Dynamic: summary
48
62
 
49
63
  # Kubernator
50
64
 
@@ -1,5 +1,5 @@
1
1
  kubernator/LICENSE,sha256=wKKdOCMTCPQRV5gDkVLAsXX8qSnRJ5owk7yWPO1KZNo,11387
2
- kubernator/__init__.py,sha256=gAjhdip8fRJb9Pn3h8PXD--afamYsaBOkCNxZTJKDXA,915
2
+ kubernator/__init__.py,sha256=q_EQvqE0BEzKg1O9XRY-Jf9qwqj0hyUWOYmGyiBS6LA,915
3
3
  kubernator/__main__.py,sha256=f0S60wgpLu--1UlOhzfWail-xt8zyIuODodX98_yPN0,707
4
4
  kubernator/_json_path.py,sha256=pjQKXxgbpQWETYBIrIuJZHgugF92IbEAM19AC7JUmAQ,3162
5
5
  kubernator/_k8s_client_patches.py,sha256=PEeWPInnW38NDyK7G24_Dmw-x7xHpN3vJWZeckdqgK0,76892
@@ -11,20 +11,20 @@ kubernator/plugins/__init__.py,sha256=h9TLYK8UFEi53ipZSZsTBjp0ljKhisWsgPpt_PkWrO
11
11
  kubernator/plugins/awscli.py,sha256=S6X7-qFiaZ7NDVDl2Jg0t-ih9KAJ45cUjjzd5Qe93ZM,4252
12
12
  kubernator/plugins/eks.py,sha256=xe7vyPHNwuP8gEYDSzPyBkm-RkAtP64wCOqs9U5I7xI,2273
13
13
  kubernator/plugins/helm.py,sha256=3BYZBPoiMUtNgmhdcbYCVRTPtaQMYzhfnMqXWyZRJZc,10525
14
- kubernator/plugins/istio.py,sha256=hD-VCNVGELt7cGFbE7S7dTiqKE7rfhzE8qA9X5tsllE,10532
14
+ kubernator/plugins/istio.py,sha256=oERwbVtIk9vMJp_miBXK3-XJKF6SDbh6PPe0p3QIekY,14924
15
15
  kubernator/plugins/k8s.py,sha256=Zj3q_bUmbOADfjSHy2X0BhgrbXuH-fM8Vq75sYFy0nE,24496
16
16
  kubernator/plugins/k8s_api.py,sha256=w2aB7CU0rPqRgzhI5mLMJUUSpWlJGCsX_bHl4SjfzM8,27594
17
17
  kubernator/plugins/kops.py,sha256=QsrQJUF6wGJo2QRVqP92pG5vmOTYQIc25PD_DWCzrAA,9635
18
18
  kubernator/plugins/kubeconfig.py,sha256=uwtHmF2I6LiTPrC3M88G5SfYxDWtuh0MqcMfrHHoNRA,2178
19
19
  kubernator/plugins/kubectl.py,sha256=IgNghW1Q6s8V2o08eNY2NWfkkdV9Z6X2A3YFQinFr4g,4028
20
- kubernator/plugins/minikube.py,sha256=kWPDIS4X1JnEoXw_rIOvgvFtjJMch39uL0mD7gQwtjE,10162
20
+ kubernator/plugins/minikube.py,sha256=FFGW8Rkap4CPEydEgxXhIuK3A263khjli0adC5j09MA,10393
21
21
  kubernator/plugins/template.py,sha256=KEiPfI7TbYXmF4a8ATWuFhxxWbcASHttFM_ekYEZ8Ps,8371
22
22
  kubernator/plugins/terraform.py,sha256=a1MPl9G8Rznjd28uMRdYWrjpFDLlFAVmLFH4hFEsMsQ,5285
23
23
  kubernator/plugins/terragrunt.py,sha256=-qN8tTqPUXJ9O7CEiJVUB0GSUQU3DUTkv-aWdIIsm7Q,5051
24
- kubernator-1.0.17.dist-info/METADATA,sha256=mnATlQPIcepM7Xnt81EwQVC10W02martshWA5wxSx20,10521
25
- kubernator-1.0.17.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
26
- kubernator-1.0.17.dist-info/entry_points.txt,sha256=IWDtHzyTleRqDSuVRXEr5GImrI7z_kh21t5DWZ8ldcQ,47
27
- kubernator-1.0.17.dist-info/namespace_packages.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
28
- kubernator-1.0.17.dist-info/top_level.txt,sha256=_z1CxWeKMI55ckf2vC8HqjbCn_E2Y_P5RdrhE_QWcIs,11
29
- kubernator-1.0.17.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
30
- kubernator-1.0.17.dist-info/RECORD,,
24
+ kubernator-1.0.18.dist-info/METADATA,sha256=S08Bo0xGauR48XowvDFNMoX8vCGEJQUfdWqvF-4AYHE,10849
25
+ kubernator-1.0.18.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
26
+ kubernator-1.0.18.dist-info/entry_points.txt,sha256=IWDtHzyTleRqDSuVRXEr5GImrI7z_kh21t5DWZ8ldcQ,47
27
+ kubernator-1.0.18.dist-info/namespace_packages.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
28
+ kubernator-1.0.18.dist-info/top_level.txt,sha256=_z1CxWeKMI55ckf2vC8HqjbCn_E2Y_P5RdrhE_QWcIs,11
29
+ kubernator-1.0.18.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
30
+ kubernator-1.0.18.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (74.1.2)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5