From 0be3b1b7d195d38b7c0c45169a6229c0afcb37aa Mon Sep 17 00:00:00 2001 From: Prajyot-Parab Date: Wed, 23 Mar 2022 20:26:41 +0530 Subject: [PATCH] csi-driver installation Signed-off-by: Prajyot-Parab --- ...vars.yaml => csi_driver_install_vars.yaml} | 8 ++- playbooks/csi_driver_config.yaml | 5 -- playbooks/csi_driver_install.yaml | 13 +++++ playbooks/roles/csi-driver-config/README.md | 45 --------------- playbooks/roles/csi-driver-install/README.md | 57 +++++++++++++++++++ .../csi-driver-install/defaults/main.yaml | 5 ++ .../tasks/config.yaml} | 0 .../csi-driver-install/tasks/install.yaml | 18 ++++++ .../roles/csi-driver-install/tasks/main.yaml | 8 +++ 9 files changed, 107 insertions(+), 52 deletions(-) rename examples/{csi_driver_config_vars.yaml => csi_driver_install_vars.yaml} (51%) delete mode 100644 playbooks/csi_driver_config.yaml create mode 100644 playbooks/csi_driver_install.yaml delete mode 100644 playbooks/roles/csi-driver-config/README.md create mode 100644 playbooks/roles/csi-driver-install/README.md create mode 100644 playbooks/roles/csi-driver-install/defaults/main.yaml rename playbooks/roles/{csi-driver-config/tasks/main.yaml => csi-driver-install/tasks/config.yaml} (100%) create mode 100644 playbooks/roles/csi-driver-install/tasks/install.yaml create mode 100644 playbooks/roles/csi-driver-install/tasks/main.yaml diff --git a/examples/csi_driver_config_vars.yaml b/examples/csi_driver_install_vars.yaml similarity index 51% rename from examples/csi_driver_config_vars.yaml rename to examples/csi_driver_install_vars.yaml index 1f8a51b0..a42896c5 100644 --- a/examples/csi_driver_config_vars.yaml +++ b/examples/csi_driver_install_vars.yaml @@ -3,8 +3,12 @@ service_instance_id: "bc895dc9-f626-41c0-bfd3-94a0d8942a5f" #IBM Cloud PowerVS region: "mon" #IBM Cloud PowerVS service instance region zone: "mon01" #IBM Cloud PowerVS service instance zone + #Upstream ibm-powervs-block-csi-driver url - https://github.com/kubernetes-sigs/ibm-powervs-block-csi-driver/deploy/kubernetes/overlays/{csi_driver_type}/?ref={csi_driver_version} +csi_driver_type: "stable" #CSI driver type. Refers to the stable state of upstream ibm-powervs-block-csi-driver deployment code. +csi_driver_version: "v0.1.0" #CSI driver version. Refers to the version of the stable upstream ibm-powervs-block-csi-driver deployment code. + masters: - - name: "mon01-master-0.rdr-pd-410.redhat.com" #OCP Nodes Master name + - name: "mon01-master-0.rdr-pd-410.redhat.com" #OCP Nodes Master name id: "03c203dc-814f-4e61-88c1-6af4cb6d2e3d" #OCP Nodes Master instance id - name: "mon01-master-1.rdr-pd-410.redhat.com" id: "0b67d0c2-339f-45ee-95b3-9b6d7c7524ef" @@ -12,7 +16,7 @@ masters: id: "38d98bb1-fb58-4ca8-a1c0-a7fb60625716" workers: - - name: "mon01-worker-0.rdr-pd-410.redhat.com" #OCP Nodes Worker name + - name: "mon01-worker-0.rdr-pd-410.redhat.com" #OCP Nodes Worker name id: "e24feb20-a962-49a9-9a24-1fe19861f81e" #OCP Nodes Worker instance id - name: "mon01-worker-1.rdr-pd-410.redhat.com" id: "e24feb20-a962-49a9-9a24-1fe19861f81e" diff --git a/playbooks/csi_driver_config.yaml b/playbooks/csi_driver_config.yaml deleted file mode 100644 index 8bab6683..00000000 --- a/playbooks/csi_driver_config.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- name: CSI Driver configuration - hosts: bastion[0] - roles: - - csi-driver-config diff --git a/playbooks/csi_driver_install.yaml b/playbooks/csi_driver_install.yaml new file mode 100644 index 00000000..40f73f12 --- /dev/null +++ b/playbooks/csi_driver_install.yaml @@ -0,0 +1,13 @@ +--- +- name: CSI Driver installation + hosts: bastion[0] + tasks: + - name: Fail csi-driver installation incase 'IBMCLOUD_API_KEY' environment variable is an empty string + fail: + msg: IBMCLOUD_API_KEY environment variable must be a non-empty string. + when: (lookup('env', 'IBMCLOUD_API_KEY') == "") + + - include_role: + name: csi-driver-install + vars: + IBMCLOUD_API_KEY: "{{ lookup('env', 'IBMCLOUD_API_KEY') }}" diff --git a/playbooks/roles/csi-driver-config/README.md b/playbooks/roles/csi-driver-config/README.md deleted file mode 100644 index 09a190cd..00000000 --- a/playbooks/roles/csi-driver-config/README.md +++ /dev/null @@ -1,45 +0,0 @@ -csi-driver-config: PowerVS Block CSI Driver Configuration -========= - -This module will perform necessary configuration on OCP nodes required for CSI Driver installation. - -Requirements ------------- - - - A working OCP 4.X cluster - -Role Variables --------------- - -| Variable | Required | Default | Comments | -|--------------------------------|----------|---------|---------------------------------------------------------------| -| service_instance_id | yes | | IBM Cloud PowerVS service instance id. | -| region | yes | | IBM Cloud PowerVS service instance region. eg. mon | -| zone | yes | | IBM Cloud PowerVS service instance zone. eg. mon01 | -| masters.name | yes | | OCP Nodes Master name. | -| masters.id | yes | | OCP Nodes Master instance id. | -| workers.name | yes | | OCP Nodes Worker name. | -| workers.id | yes | | OCP Nodes Worker instance id. | - -Dependencies ------------- - - - None - -Example Playbook ----------------- - - - name: CSI Driver configuration - hosts: bastion - roles: - - csi-driver-config - -License -------- - -See LICENCE.txt - -Author Information ------------------- - -Prajyot Parab (prajyot.parab2@ibm.com) diff --git a/playbooks/roles/csi-driver-install/README.md b/playbooks/roles/csi-driver-install/README.md new file mode 100644 index 00000000..44a3bc5c --- /dev/null +++ b/playbooks/roles/csi-driver-install/README.md @@ -0,0 +1,57 @@ +csi-driver-install: PowerVS Block CSI Driver Installation +========= + +This module will perform necessary configuration on OCP nodes required for CSI Driver installation. + +Requirements +------------ + + - A working OCP 4.X cluster + +Role Variables +-------------- + +| Variable | Required | Default | Comments | +|--------------------------------|----------|----------|---------------------------------------------------------------| +| csi_driver_type | no | `stable` | Set to csi-driver type. Refers to the stable state of upstream ibm-powervs-block-csi-driver deployment code. Upstream ibm-powervs-block-csi-driver url - `https://github.com/kubernetes-sigs/ibm-powervs-block-csi-driver/deploy/kubernetes/overlays/{csi_driver_type}/?ref={csi_driver_version}` | +| csi_driver_version | no | `v0.1.0` | Set to csi-driver version. Refers to the version of the stable upstream ibm-powervs-block-csi-driver deployment code. Upstream ibm-powervs-block-csi-driver url - `https://github.com/kubernetes-sigs/ibm-powervs-block-csi-driver/deploy/kubernetes/overlays/{csi_driver_type}/?ref={csi_driver_version}` | +| service_instance_id | yes | | IBM Cloud PowerVS service instance id. | +| region | yes | | IBM Cloud PowerVS service instance region. eg. mon | +| zone | yes | | IBM Cloud PowerVS service instance zone. eg. mon01 | +| masters.name | yes | | OCP Nodes Master name. | +| masters.id | yes | | OCP Nodes Master instance id. | +| workers.name | yes | | OCP Nodes Worker name. | +| workers.id | yes | | OCP Nodes Worker instance id. | + +Dependencies +------------ + +- Export the IBM Cloud API Key + +``` +$ set +o history +$ export IBMCLOUD_API_KEY='' +$ set -o history +``` + +Example Playbook +---------------- + +- name: CSI Driver installation + hosts: bastion[0] + tasks: + - include_role: + name: csi-driver-install + vars: + IBMCLOUD_API_KEY: (lookup('env', 'IBMCLOUD_API_KEY') + when: (lookup('env', 'IBMCLOUD_API_KEY') != "") + +License +------- + +See LICENCE.txt + +Author Information +------------------ + +Prajyot Parab (prajyot.parab2@ibm.com) diff --git a/playbooks/roles/csi-driver-install/defaults/main.yaml b/playbooks/roles/csi-driver-install/defaults/main.yaml new file mode 100644 index 00000000..5b57cfbf --- /dev/null +++ b/playbooks/roles/csi-driver-install/defaults/main.yaml @@ -0,0 +1,5 @@ +--- +# defaults file + +csi_driver_type: "stable" +csi_driver_version: "v0.1.0" diff --git a/playbooks/roles/csi-driver-config/tasks/main.yaml b/playbooks/roles/csi-driver-install/tasks/config.yaml similarity index 100% rename from playbooks/roles/csi-driver-config/tasks/main.yaml rename to playbooks/roles/csi-driver-install/tasks/config.yaml diff --git a/playbooks/roles/csi-driver-install/tasks/install.yaml b/playbooks/roles/csi-driver-install/tasks/install.yaml new file mode 100644 index 00000000..783db472 --- /dev/null +++ b/playbooks/roles/csi-driver-install/tasks/install.yaml @@ -0,0 +1,18 @@ +--- +# tasks file for csi driver installation + +- name: Create a Secret resource + k8s: + state: present + definition: + apiVersion: v1 + kind: Secret + metadata: + name: ibm-secret + namespace: kube-system + labels: + stringData: + IBMCLOUD_API_KEY: "{{ IBMCLOUD_API_KEY }}" + +- name: Create csi driver resource + shell: kubectl apply -k "https://github.com/kubernetes-sigs/ibm-powervs-block-csi-driver/deploy/kubernetes/overlays/{{ csi_driver_type }}?ref={{ csi_driver_version }}" diff --git a/playbooks/roles/csi-driver-install/tasks/main.yaml b/playbooks/roles/csi-driver-install/tasks/main.yaml new file mode 100644 index 00000000..d6af851e --- /dev/null +++ b/playbooks/roles/csi-driver-install/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +# tasks file for csi driver config and install + +- name: Run csi driver configuration tasks + import_tasks: config.yaml + +- name: Run csi driver installation tasks + import_tasks: install.yaml