Skip to content

Commit

Permalink
[skip travis] updates to last commit
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Mordant <[email protected]>
  • Loading branch information
Tcharl committed Mar 3, 2024
1 parent 42716c8 commit 55d2e17
Show file tree
Hide file tree
Showing 18 changed files with 241 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Ansible orchestration csi
* Tests: [![Build Status](https://travis-ci.com/OsgiliathEnterprise/orchestration_csi.svg?branch=master)](https://travis-ci.com/OsgiliathEnterprise/orchestration_csi)
* Chat: [![Join the chat at https://gitter.im/OsgiliathEnterprise/platform](https://badges.gitter.im/OsgiliathEnterprise/platform.svg)](https://gitter.im/OsgiliathEnterprise/platform?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Install a container storage interface on top of kubernetes
Install a container storage interface on top of kubernetes ([based on nfs subdir](https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner))

Requirements
------------
Expand Down
6 changes: 4 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---

hostpath_provisioner_operator_version: v0.16.0
hostpath_webhook_url: https://github.com/kubevirt/hostpath-provisioner-operator/releases/download/{{ hostpath_provisioner_operator_version }}/webhook.yaml
# hostpath_provisioner_operator_version: v0.18.0
# hostpath_webhook_url: https://github.com/kubevirt/hostpath-provisioner-operator/releases/download/{{ hostpath_provisioner_operator_version }}/webhook.yaml

nfs_subdir_provisioner_chart_version: 4.0.18
10 changes: 3 additions & 7 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Converge master
hosts:
- kube_masters
- all
vars:
secure_logs: False
# preferred_nic: "eth1"
Expand All @@ -13,14 +13,10 @@
nfs_mountpoints: # Mountpoints should be configured by the tcharl.ansible_volume (nfs mounts) on the server and client side to be mounted on each node before kubernetes comes in
- host: master.osgiliath.test
mountpoints:
- remote: /var/shared/csi
- remote: /var/nfs
local: /net
csi_mount: Yes
- local: /net
remote: /var/shared/volume
kubernetes_volumes:
- subtree: /artefactrepo
mountsize: 1
insecure: True

roles:
- role: tcharl.orchestration_csi
8 changes: 8 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ platforms:
auto_config: true
network_name: private_network
virtualbox__intnet: "internalnetwork"
provider_raw_config_args:
- "customize ['storagectl', :id, '--name', 'IDE', '--hostiocache', 'on']"
provider_override_args:
- "persistent_storage.enabled = true"
- "persistent_storage.location = 'molecule-volumes.vdi'"
- "persistent_storage.size = 10"
- "persistent_storage.mount = false"
- "persistent_storage.diskdevice = '/dev/sdb'"
groups:
- kube_master
- ipaclients
Expand Down
38 changes: 38 additions & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,41 @@
company_ad_password: '123ADmPass'
standalone_role: True
kubernetes_allow_pods_on_master: False
nfs_mountpoints:
- host: master.osgiliath.test
mountpoints:
- remote: /var/shared/csi
local: /net
csi_mount: Yes
insecure: True
nfs_provisioner: Yes
- name: Expose NFS
hosts: master.osgiliath.test
vars:
secure_logs: False
preferred_nic: "eth1"
master_preferred_nic: "eth1"
idm_preferred_nic: "eth1"
company_domain: osgiliath.test
company_realm_password: '123ADMin'
company_ad_password: '123ADmPass'
standalone_role: True
kubernetes_allow_pods_on_master: False
lvm_groups:
- vgname: non-persistent
disks:
- /dev/sdb1
create: true
lvmetanames:
- lvname: nfs_exposed
size: 4M
create: true
filesystem: xfs
expose_nfs: True
# insecure: yes, min_ip_to_share: 192.168.1.128
mntp: /var/nfs
mount: true
manage_lvm: true
configure_nfs: True
roles:
- role: tcharl.nfs_server
20 changes: 7 additions & 13 deletions molecule/default/tests/test_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,18 @@
testinfra_hosts = ["master.osgiliath.test"]


def test_csi_provisioner_hostname_is_created(host):
command = """kubectl get ns | grep -c 'hostpath-provisioner'"""
def test_nfs_provisioner_helm_chart_created(host):
command = """helm list --all-namespaces | \
grep -c 'nfs-subdir'"""
with host.sudo():
cmd = host.run(command)
assert int(cmd.stdout) > 0


def test_csi_pod_is_created(host):
command = """kubectl get po -n hostpath-provisioner | \
grep -c 'hostpath-provisioner-csi'"""
with host.sudo():
cmd = host.run(command)
assert int(cmd.stdout) > 0


def test_csi_operator_pod_is_created(host):
command = """kubectl get po -n hostpath-provisioner | \
grep -c 'hostpath-provisioner-operator'"""
def test_nfs_provisioner_pod_is_running(host):
command = """kubectl get po -n nfs-subdir-provisioner | \
grep nfs-subdir | \
grep -c 'Running'"""
with host.sudo():
cmd = host.run(command)
assert int(cmd.stdout) > 0
10 changes: 3 additions & 7 deletions molecule/kvm/converge.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Converge master
hosts:
- kube_masters
- all
vars:
secure_logs: False
kube_firewall_zone: 'public'
Expand All @@ -12,14 +12,10 @@
nfs_mountpoints: # Mountpoints should be configured by the tcharl.ansible_volume (nfs mounts) on the server and client side to be mounted on each node before kubernetes comes in
- host: master.osgiliath.test
mountpoints:
- remote: /var/shared/csi
- remote: /var/nfs
local: /net
insecure: True
csi_mount: Yes
- local: /net
remote: /var/shared/volume
kubernetes_volumes:
- subtree: /artefactrepo
mountsize: 1

# kube_alt_names:
# - "kubeadm.osgiliath.net"
Expand Down
2 changes: 2 additions & 0 deletions molecule/kvm/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ platforms:
- auto_config: true
network_name: private_network
type: dhcp
provider_raw_config_args:
- "storage :file, :size => '1G', :device => 'vdb'"
groups:
- kube_master
- ipaclients
Expand Down
28 changes: 28 additions & 0 deletions molecule/kvm/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,31 @@
company_realm_password: '123ADMin'
company_ad_password: '123ADmPass'
standalone_role: True
- name: Nfs server
hosts: master.osgiliath.test
roles:
- role: tcharl.nfs_server
vars:
secure_logs: False
preferred_nic: "eth1"
idm_preferred_nic: "eth1"
master_preferred_nic: "eth1"
company_domain: osgiliath.test
company_realm_password: '123ADMin'
company_ad_password: '123ADmPass'
standalone_role: True
lvm_groups:
- vgname: non-persistent
disks:
- /dev/sdb1
create: true
lvmetanames:
- lvname: nfs_exposed
size: 4M
create: true
filesystem: xfs
expose_nfs: True
mntp: /var/nfs
mount: true
manage_lvm: true
configure_nfs: True
5 changes: 3 additions & 2 deletions molecule/parallels/converge.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Converge master
hosts:
- kube_masters
- all
vars:
kube_firewall_zone: 'public'
preferred_nic: "eth1"
Expand All @@ -12,9 +12,10 @@
nfs_mountpoints: # Mountpoints should be configured by the tcharl.ansible_volume (nfs mounts) on the server and client side to be mounted on each node before kubernetes comes in
- host: master.osgiliath.test
mountpoints:
- remote: /var/shared/csi
- remote: /var/nfs
local: /net
csi_mount: Yes
insecure: True
# kube_alt_names:
# - "kubeadm.osgiliath.net"
roles:
Expand Down
2 changes: 2 additions & 0 deletions molecule/parallels/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ platforms:
- type: dhcp
auto_config: true
network_name: private_network
provider_raw_config_args:
- "customize ['set', :id, '--device-add', 'hdd', '--size', '840']"
groups:
- kube_master
- ipaclients
Expand Down
30 changes: 30 additions & 0 deletions molecule/parallels/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---

- name: Prepare
hosts:
- all
Expand All @@ -16,3 +17,32 @@
company_ad_password: '123ADmPass'
standalone_role: True
kubernetes_allow_pods_on_master: False
- name: Nfs
hosts: master.osgiliath.test
roles:
- role: tcharl.nfs_server
vars:
secure_logs: False
preferred_nic: "eth1"
idm_preferred_nic: "eth1"
master_preferred_nic: "eth1"
company_domain: osgiliath.test
company_realm_password: '123ADMin'
company_ad_password: '123ADmPass'
standalone_role: True
kubernetes_allow_pods_on_master: False
lvm_groups:
- vgname: non-persistent
disks:
- /dev/sdb
create: true
lvmetanames:
- lvname: nfs_exposed
size: 4M
create: true
filesystem: xfs
expose_nfs: True
mntp: /var/nfs
mount: true
manage_lvm: true
configure_nfs: True
1 change: 1 addition & 0 deletions tasks/csi-volume.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
namespace: hostpath-provisioner
#- path: deploy/storageclass-wffc.yaml
# namespace: hostpath-provisioner

- name: Csi-volume | create temp directory to host template
changed_when: false
ansible.builtin.tempfile:
Expand Down
21 changes: 14 additions & 7 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
when:
- standalone_role

- name: Install Csi driver
#- name: Install Csi driver
# ansible.builtin.include_tasks:
# file: csi-volume.yml
# apply:
# delegate_to: "{{ groups['kube_master'][0] }}"
# run_once: True
# when:
# - nfs_mountpoints | default([]) | map(attribute='mountpoints') | flatten | selectattr('csi_mount', 'defined') | selectattr('csi_mount', 'equalto', true)

- name: Install Nfs driver
ansible.builtin.include_tasks:
file: csi-volume.yml
apply:
delegate_to: "{{ groups['kube_master'][0] }}"
run_once: True
when:
- nfs_mountpoints | default([]) | map(attribute='mountpoints') | flatten | selectattr('csi_mount', 'defined') | selectattr('csi_mount', 'equalto', true)
file: nfs-mountpoint.yml
loop: "{{ nfs_mountpoints }}"
loop_control:
loop_var: nfs_mountpoint
7 changes: 7 additions & 0 deletions tasks/mountpoint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---

- name: Mountpoint loop | Install Nfs driver
ansible.builtin.include_tasks:
file: nfs-provisioner.yml
run_once: True
when: mountpoint.csi_mount | default(false)
8 changes: 8 additions & 0 deletions tasks/nfs-mountpoint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---

- name: Mountpoint loop | Install Nfs driver
ansible.builtin.include_tasks:
file: mountpoint.yml
loop: "{{ nfs_mountpoint.mountpoints }}"
loop_control:
loop_var: mountpoint
79 changes: 79 additions & 0 deletions tasks/nfs-provisioner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---

- name: Nfs provisioner | check prerequisites
ansible.builtin.assert:
that:
- mountpoint.insecure is defined
- mountpoint.insecure
fail_msg: "'Mountpoint should be defined and insecure should be true'"

- name: Nfs provisioner | Create temporary directory
ansible.builtin.tempfile:
state: directory
suffix: nfs-subdir-provisioner
register: orchestration_csi_subdir_provisioner_tempdir
delegate_to: "{{ groups['kube_master'][0] }}"
become: True

- name: Nfs provisioner | retrieve nfs host
ansible.builtin.debug:
msg: "{{ nfs_mountpoint.host }}"
register: orchestration_csi_nfs_server_ip

- name: Nfs provisioner | retrieve nfs mountpoint
ansible.builtin.debug:
msg: "{{ mountpoint.remote }}"
register: orchestration_csi_nfs_server_path

- name: Nfs provisioner | debug values that are used to create the nfs provisioner
ansible.builtin.debug:
msg: " hostname: {{ orchestration_csi_nfs_server_ip.msg }} path: {{ orchestration_csi_nfs_server_path.msg }}"

- name: Nfs provisioner | Instantiate helm value NFS information
ansible.builtin.template:
src: nfs-subdir-values.yml.j2
dest: "{{ orchestration_csi_subdir_provisioner_tempdir.path }}/nfs-subdir-values.yml"
owner: root
group: root
mode: 0644
delegate_to: "{{ groups['kube_master'][0] }}"
become: true

- name: Nfs Provisioner | Reference nfs-subdir-external-provisioner repository
kubernetes.core.helm_repository:
name: nfs-subdir-external-provisioner
repo_url: https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner
kubeconfig: /root/.kube/config
delegate_to: "{{ groups['kube_master'][0] }}"
become: True

- name: Nfs Provisioner | Create nfs subdir provisioner namespace
kubernetes.core.k8s:
name: nfs-subdir-provisioner
kind: Namespace
state: present
wait_timeout: 200
wait_sleep: 20
register: lsresult
until: "lsresult is not failed"
delegate_to: "{{ groups['kube_master'][0] }}"
retries: 5
delay: 10
become: True

- name: Nfs Provisioner | Deploy latest version of Nfs subdir provisioner
kubernetes.core.helm:
kubeconfig: /root/.kube/config
name: nfs-subdir-external-provisioner
chart_ref: nfs-subdir-external-provisioner/nfs-subdir-external-provisioner
release_namespace: nfs-subdir-provisioner
chart_version: "{{ nfs_subdir_provisioner_chart_version }}"
values_files:
- "{{ orchestration_csi_subdir_provisioner_tempdir.path }}/nfs-subdir-values.yml"
register: lsresult
delegate_to: "{{ groups['kube_master'][0] }}"
until: "lsresult is not failed"
failed_when: False
retries: 5
delay: 5
become: True
Loading

0 comments on commit 55d2e17

Please sign in to comment.