Skip to content

Commit

Permalink
Add support to change default storage class for Portworx
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfgang Kulhanek authored and Wolfgang Kulhanek committed Nov 20, 2024
1 parent ce6655c commit e920b98
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ ocp4_workload_portworx_storagecluster_name: portworx-storage-cluster
ocp4_workload_portworx_storagecluster_storage_class: gp3
ocp4_workload_portworx_storagecluster_storage_size: 50

# Update the default storage class with a Portworx provided one
ocp4_workload_portworx_update_default_storageclass: false

# Define StorageCluster metadata (default when empty)
ocp4_workload_portworx_image: ""
# ocp4_workload_portworx_image: portworx/oci-monitor:3.1.3

# Define AWS polcy metadata
ocp4_workload_portworx_policy_name: portworx-ebbs

# AWS creds placeHolder value for testing
AWS_KEY: ABC123
AWS_SECRET: abc123
aws_region: us-east-2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: px-csi-vm
annotations:
storageclass.kubernetes.io/is-default-class: "true"
parameters:
repl: "3"
sharedv4: "true"
sharedv4_svc_type: "ClusterIP"
sharedv4_mount_options: vers=3.0,nolock
provisioner: pxd.portworx.com
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,35 @@
spec:
plugins:
- portworx

- name: Update default storage class with a Portworx provided one
when: ocp4_workload_portworx_update_default_storageclass | bool
block:
- name: Get all current storage classes
kubernetes.core.k8s_info:
api_version: storage.k8s.io/v1
kind: StorageClass
register: r_sc

- name: Remove default from previous default storage class
when: storage_class.metadata.annotations['storageclass.kubernetes.io/is-default-class'] is defined
kubernetes.core.k8s:
api_version: storage.k8s.io/v1
kind: StorageClass
name: "{{ storage_class.metadata.name }}"
definition:
kind: StorageClass
apiVersion: v1
name: "{{ storage_class }}"
metadata:
annotations:
storageclass.kubernetes.io/is-default-class: "false"
loop: "{{ r_sc.resources }}"
loop_control:
loop_var: storage_class
label: "{{ storage_class.metadata.name }}"

- name: Create new Portworx VM default storage class
kubernetes.core.k8s:
state: present
definition: "{{ lookup('file', 'portworx_storageclass.yaml') | from_yaml }}"

0 comments on commit e920b98

Please sign in to comment.