Skip to content

Commit

Permalink
Fix storageclass install logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mvalsecc committed Apr 16, 2024
1 parent 7052e23 commit 2a51541
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 52 deletions.
14 changes: 14 additions & 0 deletions main-minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,17 @@
- include_tasks: tasks/kvm_host/install-master.yml
# - include_tasks: tasks/kvm_host/install-worker.yml
- include_tasks: tasks/kvm_host/wait-for-complete.yml

- hosts: kvm_host
gather_facts: yes
vars_files:
- vars/config.yml
- vars/vm_setting.yml
- vars/download.yml

tasks:
- include_tasks: tasks/kvm_host/install-storage.yml
- include_tasks: tasks/kvm_host/setup-openshift-install-nfs-subdir-external-provisioner.yaml
when:
- ff_provision_storage is defined
- ff_provision_storage == true
33 changes: 0 additions & 33 deletions main-nfs-node-only.yaml

This file was deleted.

14 changes: 14 additions & 0 deletions main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,17 @@
- include_tasks: tasks/kvm_host/install-master.yml
- include_tasks: tasks/kvm_host/install-worker.yml
- include_tasks: tasks/kvm_host/wait-for-complete.yml

- hosts: kvm_host
gather_facts: yes
vars_files:
- vars/config.yml
- vars/vm_setting.yml
- vars/download.yml

tasks:
- include_tasks: tasks/kvm_host/install-storage.yml
- include_tasks: setup-openshift-install-nfs-subdir-external-provisioner.yaml
when:
- ff_provision_storage is defined
- ff_provision_storage == true
15 changes: 11 additions & 4 deletions tasks/base/get_materials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,20 @@

- name: download helm client
get_url:
url: "{{ url.openshift_client_url }}"
dest: "{{ files.base }}/clients/helm"
checksum: "sha256:{{ url.sha256_client_url }}"
url: "{{ url.helm_client }}"
dest: "{{ files.base }}/clients/helm.tar.gz"
checksum: "sha256:{{ url.sha256_helm_url }}"
register: downloaded_helm_client
until: downloaded_helm_client is succeeded
retries: 3
tags: nfs
- name: send helm client
unarchive:
src: "{{ files.base }}/clients/helm.tar.gz"
dest: /root/bin
exclude:
- README.md
- LICENSE
extra_opts: ['--strip-components=1', '--show-stored-names']

- name: download rocky image
get_url:
Expand Down
21 changes: 21 additions & 0 deletions tasks/kvm_host/cleanup-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
when: 'item.name in all_vms.list_vms'
with_items: "{{ worker }}"

- name: destroy old storage
shell: |
virsh destroy {{ item.name }}
virsh undefine --remove-all-storage {{ item.name }}
when: 'item.name in all_vms.list_vms'
with_items: "{{ storage }}"

- name: stop libvirt daemon
service:
name: libvirtd
Expand Down Expand Up @@ -75,6 +82,19 @@
- chk_file.stat.exists == true
- cleanup.conf == true

- name: check rocky files dir
file:
path: "{{ files.rocky }}"
register: chk_rocky

- name: remove rocky dir # TODO: fix me
file:
path: "{{ files.rocky }}"
state: absent
when:
- chk_rocky.stat.exists == true
- cleanup.conf == true

- name: check old hosts.openshift for dnsmasq
stat:
path: "/etc/hosts.openshift"
Expand Down Expand Up @@ -122,6 +142,7 @@
- kubectl
- oc
- openshift-install
- helm # TODO: actually move helm to /root/bin inside get_materials.yaml
when:
- cleanup.bin == true
ignore_errors: yes
1 change: 1 addition & 0 deletions tasks/kvm_host/install-pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- libvirt
- qemu-kvm
- virt-install
- guestfs-tools
- dnsmasq
- nginx
- python3-lxml
Expand Down
5 changes: 5 additions & 0 deletions tasks/kvm_host/install-storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
- "'hypervisor' in group_names"
with_list: "{{expanded_disks.results}}"

- name: make working dir for nfs cloud-init
file:
path: "/tmp/reg"
state: directory

- name: make meta-data and user-data file
template:
src: "templates/{{ item }}.j2"
Expand Down
10 changes: 3 additions & 7 deletions tasks/kvm_host/mk_files-dir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
path: "{{ files.kvm }}"
state: directory
become: true
tags: fedora

- name: make fedora files dir
- name: make working dir for nfs cloud-init
file:
path: "{{ files.fedora }}"
state: directory
become: true
become_user: root
tags: fedora
path: "/tmp/reg"
state: directory
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
---
# References: https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/issues/31#issuecomment-756823499
# https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner#without-helm
- name: Install nfs-subdir-external-provisioner
shell: >-
{{ files.base }}/clients/helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
/root/bin/helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
{{ files.base }}/clients/{{ config.openshift_client }} create namespace nfs-subdir-external-provisioner 2>/dev/null
/root/bin/oc create namespace nfs-subdir-external-provisioner 2>/dev/null
{{ files.base }}/clients/helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \
/root/bin/helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \
--set nfs.server=172.16.0.106 --set nfs.path=/export --set storageClass.reclaimPolicy=Retain -n nfs-subdir-external-provisioner
/root/bin/oc adm policy add-scc-to-user privileged -z nfs-subdir-external-provisioner --namespace nfs-subdir-external-provisioner
/root/bin/oc adm policy add-scc-to-user hostmount-anyuid -z nfs-subdir-external-provisioner --namespace nfs-subdir-external-provisioner
/root/bin/oc rollout restart deployment nfs-subdir-external-provisioner -n nfs-subdir-external-provisioner
environment:
KUBECONFIG: "{{ files.kvm }}/bare-metal/auth/kubeconfig"
KUBECONFIG: "{{ files.kvm }}/bare-metal/auth/kubeconfig"
5 changes: 2 additions & 3 deletions vars/download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ url:
coreos_rootfs_url: "{{ static.coreos_base_url }}/{{ config.coreos_rootfs }}"
openshift_installer_url: "{{ static.clients_base_url }}/{{ config.openshift_installer }}"
openshift_client_url: "{{ static.clients_base_url }}/{{ config.openshift_client }}"
# Hardcoded for now
helm_client: "https://get.helm.sh/helm-v3.14.3-linux-386.tar.gz"
sha256_kernel_url: >-
{%- if openshift.dist == 'okd' -%} {{ openshift.okd_kenrel_sha256 }}
{%- elif openshift.dist == 'ocp' -%} {{ static.coreos_base_url }}/sha256sum.txt
Expand All @@ -116,7 +114,8 @@ url:
sha256_client_url: "{{ static.clients_base_url }}/sha256sum.txt"

# Hardcoded for now
helm_cluent_sha: "https://get.helm.sh/helm-v3.14.3-linux-386.tar.gz.sha256sum"
helm_client: "https://get.helm.sh/helm-v3.14.3-linux-amd64.tar.gz" # TODO: figure out how to get the correct arch
sha256_helm_url: "https://get.helm.sh/helm-v3.14.3-linux-amd64.tar.gz.sha256sum" # TODO: figure out how to get the correct arch
rocky_url: "https://download.rockylinux.org/pub/rocky/8/images/x86_64/Rocky-8-GenericCloud-Base-8.9-20231119.0.x86_64.qcow2"
sha256_rocky_url: "https://download.rockylinux.org/pub/rocky/8/images/x86_64/Rocky-8-GenericCloud-LVM-8.9-20231119.0.x86_64.qcow2.CHECKSUM"

Expand Down
4 changes: 3 additions & 1 deletion vars/vm_setting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ spec_storage:
num_storage: 0
cpu: 2
ram: 4096
disk: 50
disk: 50 # Size of the disk that includes the NFS export
disk_cache: unsafe

# Remove the bootstrap node after the OCP installation is complete.
# If this value is "true", the bootstrap node will be preserved.
keep_bootstrap: false

# Actually deploy the storage node(s), download helm binary and install the plugin to use the NFS export as backend for PVs
ff_provision_storage: true

0 comments on commit 2a51541

Please sign in to comment.