From 8294957d144cbf346770bad00f6de98fcb641f6c Mon Sep 17 00:00:00 2001 From: Kirill Zhdanov Date: Fri, 11 Jun 2021 12:27:54 +0400 Subject: [PATCH 1/9] change deployment apiVersion --- rally_plugins/services/kube/kube.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rally_plugins/services/kube/kube.py b/rally_plugins/services/kube/kube.py index 717c543..39923f2 100644 --- a/rally_plugins/services/kube/kube.py +++ b/rally_plugins/services/kube/kube.py @@ -804,7 +804,7 @@ def delete_replicaset(self, name, namespace, status_wait=True): @atomic.action_timer("kubernetes.get_deployment") def get_deployment(self, name, namespace, **kwargs): - return self.v1beta1_ext.read_namespaced_deployment_status( + return self.v1_apps.read_namespaced_deployment_status( name=name, namespace=namespace ) @@ -840,7 +840,7 @@ def create_deployment(self, name, namespace, replicas, image, container_spec["resources"] = resources manifest = { - "apiVersion": "extensions/v1beta1", + "apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": name, @@ -868,7 +868,7 @@ def create_deployment(self, name, namespace, replicas, image, if not self._spec.get("serviceaccounts"): del manifest["spec"]["template"]["spec"]["serviceAccountName"] - self.v1beta1_ext.create_namespaced_deployment( + self.v1_apps.create_namespaced_deployment( namespace=namespace, body=manifest ) @@ -912,7 +912,7 @@ def rollout_deployment(self, name, namespace, changes, replicas, "exclusive keys: image, env, resources." ) - self.v1beta1_ext.patch_namespaced_deployment( + self.v1_apps.patch_namespaced_deployment( name=name, namespace=namespace, body=deployment @@ -935,7 +935,7 @@ def delete_deployment(self, name, namespace, status_wait=True): :param namespace: deployment namespace :param status_wait: wait for termination if True """ - self.v1beta1_ext.delete_namespaced_deployment( + self.v1_apps.delete_namespaced_deployment( name=name, namespace=namespace, body=k8s_config.V1DeleteOptions() From 5d4d8201c7cc7159ae7a1ed3113ce446f650c27b Mon Sep 17 00:00:00 2001 From: Kirill Zhdanov Date: Fri, 11 Jun 2021 12:40:41 +0400 Subject: [PATCH 2/9] add deployment selector --- rally_plugins/services/kube/kube.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rally_plugins/services/kube/kube.py b/rally_plugins/services/kube/kube.py index 39923f2..506aa01 100644 --- a/rally_plugins/services/kube/kube.py +++ b/rally_plugins/services/kube/kube.py @@ -849,6 +849,11 @@ def create_deployment(self, name, namespace, replicas, image, } }, "spec": { + "selector": { + "matchLabels": { + "app": app + } + }, "replicas": replicas, "template": { "metadata": { From ece15aba5970157681d8104a157750b7dbedeeb2 Mon Sep 17 00:00:00 2001 From: Kirill Zhdanov Date: Fri, 11 Jun 2021 12:56:06 +0400 Subject: [PATCH 3/9] fix replicaset and daemonset --- rally_plugins/services/kube/kube.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/rally_plugins/services/kube/kube.py b/rally_plugins/services/kube/kube.py index 506aa01..9b3d77c 100644 --- a/rally_plugins/services/kube/kube.py +++ b/rally_plugins/services/kube/kube.py @@ -686,7 +686,7 @@ def delete_rc(self, name, namespace, status_wait=True): @atomic.action_timer("kubernetes.get_replicaset") def get_replicaset(self, name, namespace, **kwargs): - return self.v1beta1_ext.read_namespaced_replica_set( + return self.v1_apps.read_namespaced_replica_set( name=name, namespace=namespace ) @@ -715,7 +715,7 @@ def create_replicaset(self, name, namespace, replicas, image, container_spec["command"] = list(command) manifest = { - "apiVersion": "extensions/v1beta1", + "apiVersion": "apps/v1", "kind": "ReplicaSet", "metadata": { "name": name, @@ -748,7 +748,7 @@ def create_replicaset(self, name, namespace, replicas, image, if not self._spec.get("serviceaccounts"): del manifest["spec"]["template"]["spec"]["serviceAccountName"] - self.v1beta1_ext.create_namespaced_replica_set( + self.v1_apps.create_namespaced_replica_set( namespace=namespace, body=manifest ) @@ -766,7 +766,7 @@ def create_replicaset(self, name, namespace, replicas, image, @atomic.action_timer("kubernetes.scale_replicaset") def scale_replicaset(self, name, namespace, replicas, status_wait=True): - self.v1beta1_ext.patch_namespaced_replica_set( + self.v1_apps.patch_namespaced_replica_set( name=name, namespace=namespace, body={"spec": {"replicas": replicas}} @@ -789,7 +789,7 @@ def delete_replicaset(self, name, namespace, status_wait=True): :param namespace: replicaset namespace :param status_wait: wait for termination if True """ - self.v1beta1_ext.delete_namespaced_replica_set( + self.v1_apps.delete_namespaced_replica_set( name=name, namespace=namespace, body=k8s_config.V1DeleteOptions() @@ -1206,7 +1206,7 @@ def list_filtered_nodes(self, node_labels=None): @atomic.action_timer("kubernetes.get_daemonset") def get_daemonset(self, name, namespace, **kwargs): - return self.v1beta1_ext.read_namespaced_daemon_set( + return self.v1_apps.read_namespaced_daemon_set( name, namespace=namespace ) @@ -1236,12 +1236,17 @@ def create_daemonset(self, namespace, image, container_spec["command"] = list(command) manifest = { - "apiVersion": "extensions/v1beta1", + "apiVersion": "apps/v1", "kind": "DaemonSet", "metadata": { "name": name }, "spec": { + "selector": { + "matchLabels": { + "app": app + } + }, "template": { "metadata": { "name": name, @@ -1260,7 +1265,7 @@ def create_daemonset(self, namespace, image, if not self._spec.get("serviceaccounts"): del manifest["spec"]["template"]["spec"]["serviceAccountName"] - self.v1beta1_ext.create_namespaced_daemon_set( + self.v1_apps.create_namespaced_daemon_set( namespace=namespace, body=manifest ) @@ -1321,7 +1326,7 @@ def delete_daemonset(self, name, namespace, status_wait=True): :param namespace: daemon set namespace :param status_wait: wait for termination if True """ - self.v1beta1_ext.delete_namespaced_daemon_set( + self.v1_apps.delete_namespaced_daemon_set( name, namespace=namespace, body=k8s_config.V1DeleteOptions() From 279a6bad91e80ee8b8f6720e3cd78773c62ee5a5 Mon Sep 17 00:00:00 2001 From: Kirill Zhdanov Date: Sun, 13 Jun 2021 15:11:19 +0400 Subject: [PATCH 4/9] volumes fix --- rally_plugins/services/kube/kube.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rally_plugins/services/kube/kube.py b/rally_plugins/services/kube/kube.py index 9b3d77c..772dd56 100644 --- a/rally_plugins/services/kube/kube.py +++ b/rally_plugins/services/kube/kube.py @@ -1399,7 +1399,7 @@ def create_local_pv(self, name, storage_class, size, volume_mode, "accessModes": access_modes, "persistentVolumeReclaimPolicy": "Retain", "storageClassName": storage_class, - "local": { + "hostPath": { "path": local_path }, "nodeAffinity": node_affinity From 8572c24565a95fee32762e27160190b9b9f953ef Mon Sep 17 00:00:00 2001 From: Kirill Zhdanov Date: Sun, 13 Jun 2021 16:22:22 +0400 Subject: [PATCH 5/9] set claimRef --- rally_plugins/services/kube/kube.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rally_plugins/services/kube/kube.py b/rally_plugins/services/kube/kube.py index 772dd56..a74bf38 100644 --- a/rally_plugins/services/kube/kube.py +++ b/rally_plugins/services/kube/kube.py @@ -1402,7 +1402,10 @@ def create_local_pv(self, name, storage_class, size, volume_mode, "hostPath": { "path": local_path }, - "nodeAffinity": node_affinity + "nodeAffinity": node_affinity, + "claimRef": { + "name": name + } } } From b541d8b2800aa26d4b321df196b664437ac50284 Mon Sep 17 00:00:00 2001 From: Kirill Zhdanov <38215255+zhdkirill@users.noreply.github.com> Date: Sun, 13 Jun 2021 16:45:27 +0400 Subject: [PATCH 6/9] Merge recent fixes From 4458791cce5eeaaf1b0f1110992446f8f714d520 Mon Sep 17 00:00:00 2001 From: Kirill Zhdanov Date: Sun, 13 Jun 2021 16:58:22 +0400 Subject: [PATCH 7/9] remove claimRef --- rally_plugins/services/kube/kube.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rally_plugins/services/kube/kube.py b/rally_plugins/services/kube/kube.py index a74bf38..772dd56 100644 --- a/rally_plugins/services/kube/kube.py +++ b/rally_plugins/services/kube/kube.py @@ -1402,10 +1402,7 @@ def create_local_pv(self, name, storage_class, size, volume_mode, "hostPath": { "path": local_path }, - "nodeAffinity": node_affinity, - "claimRef": { - "name": name - } + "nodeAffinity": node_affinity } } From 2720b8ef5b5d0b873dde31e0d72e5d65370fb3b4 Mon Sep 17 00:00:00 2001 From: Kirill Zhdanov Date: Sun, 13 Jun 2021 17:39:28 +0400 Subject: [PATCH 8/9] add nodeSelector to daemonset --- rally_plugins/services/kube/kube.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rally_plugins/services/kube/kube.py b/rally_plugins/services/kube/kube.py index 772dd56..4469e48 100644 --- a/rally_plugins/services/kube/kube.py +++ b/rally_plugins/services/kube/kube.py @@ -1256,7 +1256,8 @@ def create_daemonset(self, namespace, image, }, "spec": { "serviceAccountName": namespace, - "containers": [container_spec] + "containers": [container_spec], + "nodeSelector": node_labels } } } From 4cfd47c0719bf4696d7473c64d2408156af31b2a Mon Sep 17 00:00:00 2001 From: Kirill Zhdanov <38215255+zhdkirill@users.noreply.github.com> Date: Thu, 12 Aug 2021 16:32:35 +0200 Subject: [PATCH 9/9] Create local PV with unique storageClass (#2) PRODX-15438 --- .../kubernetes/volumes/local_persistent_volume.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rally_plugins/scenarios/kubernetes/volumes/local_persistent_volume.py b/rally_plugins/scenarios/kubernetes/volumes/local_persistent_volume.py index ef1d1d4..8c0325f 100644 --- a/rally_plugins/scenarios/kubernetes/volumes/local_persistent_volume.py +++ b/rally_plugins/scenarios/kubernetes/volumes/local_persistent_volume.py @@ -53,9 +53,11 @@ def run(self, image, mount_path, persistent_volume, """ name = self.generate_random_name() + storage_class = self.client.create_local_storageclass() + self.client.create_local_pv( name, - storage_class=self.context["kubernetes"]["storageclass"], + storage_class=storage_class, size=persistent_volume["size"], volume_mode=persistent_volume["volume_mode"], local_path=persistent_volume["local_path"], @@ -67,7 +69,7 @@ def run(self, image, mount_path, persistent_volume, self.client.create_local_pvc( name, namespace=self.namespace, - storage_class=self.context["kubernetes"]["storageclass"], + storage_class=storage_class, access_modes=persistent_volume_claim["access_modes"], size=persistent_volume_claim["size"] ) @@ -120,3 +122,5 @@ def run(self, image, mount_path, persistent_volume, name, status_wait=status_wait ) + + self.client.delete_local_storageclass(storage_class)