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) diff --git a/rally_plugins/services/kube/kube.py b/rally_plugins/services/kube/kube.py index 717c543..4469e48 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() @@ -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, @@ -849,6 +849,11 @@ def create_deployment(self, name, namespace, replicas, image, } }, "spec": { + "selector": { + "matchLabels": { + "app": app + } + }, "replicas": replicas, "template": { "metadata": { @@ -868,7 +873,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 +917,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 +940,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() @@ -1201,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 ) @@ -1231,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, @@ -1246,7 +1256,8 @@ def create_daemonset(self, namespace, image, }, "spec": { "serviceAccountName": namespace, - "containers": [container_spec] + "containers": [container_spec], + "nodeSelector": node_labels } } } @@ -1255,7 +1266,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 ) @@ -1316,7 +1327,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() @@ -1389,7 +1400,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