From 79b191d207d7670295781c550847ce7d695cc388 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Wed, 7 Aug 2019 18:47:39 +0200 Subject: Support for Samba/CIFS storage and a sample how to mount LSDF shares --- .gitmodules | 3 ++ anslib/openshift-flexvolume-cifs | 1 + docs/samples/remote_storage/lsdf/lsdf-test.yml | 44 ++++++++++++++++++++++++++ docs/samples/remote_storage/lsdf/lsdf.yml | 38 ++++++++++++++++++++++ opts.sh | 1 + playbooks/openshift-install-cifs.yml | 40 +++++++++++++++++++++++ setup.sh | 3 ++ 7 files changed, 130 insertions(+) create mode 160000 anslib/openshift-flexvolume-cifs create mode 100644 docs/samples/remote_storage/lsdf/lsdf-test.yml create mode 100644 docs/samples/remote_storage/lsdf/lsdf.yml create mode 100644 playbooks/openshift-install-cifs.yml diff --git a/.gitmodules b/.gitmodules index ea94509..877a36b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "anslib/ansible-role-ntp"] path = anslib/ansible-role-ntp url = http://darksoft.org/git/csa/devops/ansible-patches/ntp.git +[submodule "anslib/openshift-flexvolume-cifs"] + path = anslib/openshift-flexvolume-cifs + url = https://github.com/sabre1041/openshift-flexvolume-cifs.git diff --git a/anslib/openshift-flexvolume-cifs b/anslib/openshift-flexvolume-cifs new file mode 160000 index 0000000..62bd24b --- /dev/null +++ b/anslib/openshift-flexvolume-cifs @@ -0,0 +1 @@ +Subproject commit 62bd24be902bee56f818c5e5d96602756390b88e diff --git a/docs/samples/remote_storage/lsdf/lsdf-test.yml b/docs/samples/remote_storage/lsdf/lsdf-test.yml new file mode 100644 index 0000000..c02a888 --- /dev/null +++ b/docs/samples/remote_storage/lsdf/lsdf-test.yml @@ -0,0 +1,44 @@ +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + annotations: + name: lsdf-test +objects: + - apiVersion: v1 + kind: PersistentVolumeClaim + metadata: + name: lsdf-ips + spec: + volumeName: lsdf-ips + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "10Ti" + - apiVersion: v1 + kind: DeploymentConfig + metadata: + name: lsdf-test + spec: + replicas: 1 + selector: + name: lsdf-test + strategy: + type: Recreate + template: + metadata: + labels: + name: lsdf-test + name: lsdf-test + spec: + volumes: + - name: lsdf-ips + persistentVolumeClaim: + claimName: lsdf-ips + containers: + - image: registry.access.redhat.com/rhel7/rhel:7.6 + name: cifs-app + command: ["/bin/bash", "-c", "while true; do sleep 10; done"] + volumeMounts: + - name: lsdf-ips + mountPath: /mnt/lsdf diff --git a/docs/samples/remote_storage/lsdf/lsdf.yml b/docs/samples/remote_storage/lsdf/lsdf.yml new file mode 100644 index 0000000..c091870 --- /dev/null +++ b/docs/samples/remote_storage/lsdf/lsdf.yml @@ -0,0 +1,38 @@ +apiVersion: v1 +kind: Template +metadata: + name: lsdf + annotations: + descriptions: "LSDF volumes" +objects: + - apiVersion: v1 + kind: Secret + metadata: + name: lsdf-csa + type: openshift.io/cifs + stringData: + username: "gf6501" + password: "" + - apiVersion: v1 + kind: PersistentVolume + metadata: + name: lsdf-ips + spec: + persistentVolumeReclaimPolicy: Retain + accessModes: + - ReadWriteMany + capacity: + storage: 100Ti + claimRef: + name: lsdf-ips + namespace: test + flexVolume: + driver: openshift.io/cifs + fsType: cifs + secretRef: + name: lsdf-csa + options: + networkPath: "//os.lsdf.kit.edu/ips-projects" + mountOptions: "vers=2.0,domain=os.lsdf.kit.edu,file_mode=0664,dir_mode=0775" + + \ No newline at end of file diff --git a/opts.sh b/opts.sh index d87b89d..490082b 100644 --- a/opts.sh +++ b/opts.sh @@ -25,6 +25,7 @@ Actions: projects - installs configuration files and OpenShift resources for KaaS and other configured projects Additional services + cifs - install plugin for mounting Samba/CIFS volumes in pods ganesha - provide external nfs access to gluster volumes Maintenance diff --git a/playbooks/openshift-install-cifs.yml b/playbooks/openshift-install-cifs.yml new file mode 100644 index 0000000..92ed09c --- /dev/null +++ b/playbooks/openshift-install-cifs.yml @@ -0,0 +1,40 @@ +--- + +- hosts: nodes + serial: 1 + vars: + vendor_name: openshift.io + driver_name: cifs + driver_location: "{{ playbook_dir }}/../anslib/openshift-flexvolume-cifs/flexvolume-driver/cifs" + volume_plugin_path: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec" + openshift_node_service: origin-node + install_packages: + - cifs-utils + tasks: + - name: Install required packages + package: + name: "{{ install_packages }}" + state: present + - name: Validate driver exists + stat: + path: "{{ driver_location }}" + register: driver_exists + delegate_to: localhost + - name: Fail if driver not found + fail: + msg: Driver file not found! + when: not driver_exists.stat.exists + - name: Create cifs driver directory + file: + state: directory + path: "{{ volume_plugin_path }}/{{ vendor_name }}~{{ driver_name }}" + - name: Copy cifs driver + copy: + src: "{{ driver_location }}" + dest: "{{ volume_plugin_path }}/{{ vendor_name }}~{{ driver_name }}/{{ driver_name }}" + mode: 0755 + register: driver_copy + - name: Restart OpenShift Node Service + service: + name: "{{ openshift_node_service }}" + state: restarted \ No newline at end of file diff --git a/setup.sh b/setup.sh index f4271f8..8b8a6ec 100755 --- a/setup.sh +++ b/setup.sh @@ -40,6 +40,9 @@ case "$action" in apply playbooks/ands-gluster-migrate.yml --extra-vars "gfs_from=$from gfs_to=$to" "$@" || exit 1 # echo "Currently unsupported, use scripts..." ;; + cifs) + apply playbooks/openshift-install-cifs.yml "$@" || exit 1 + ;; ganesha) apply playbooks/ands-gluster-ganesha.yml "$@" || exit 1 ;; -- cgit v1.2.3