-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to enable Persistent Local Storage using Ansible
- Loading branch information
Showing
14 changed files
with
249 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
OpenShift Persistent Local Volumes | ||
================================== | ||
|
||
OpenShift Persistent Local Volumes | ||
|
||
Requirements | ||
------------ | ||
|
||
Role Variables | ||
-------------- | ||
|
||
| Name | Default value | | | ||
|--------------------------------|---------------|---------------------------------------------------------------------------| | ||
| persistentlocalstorage_project | local-storage | The namespace where the Persistent Local Volume Provider will be deployed | | ||
| persistentlocalstorage_classes | [] | Storage classes that will be created | | ||
|
||
Dependencies | ||
------------ | ||
|
||
|
||
Example Playbook | ||
---------------- | ||
|
||
``` | ||
- name: Create persistent Local Storage Provider | ||
hosts: oo_first_master | ||
vars: | ||
persistentlocalstorage_project: local-storage | ||
persistentlocalstorage_classes: | ||
- ssd | ||
- hdd | ||
roles: | ||
- role: openshift_persistentlocalstorage | ||
``` | ||
|
||
License | ||
------- | ||
|
||
Apache License, Version 2.0 | ||
|
||
Author Information | ||
------------------ | ||
|
||
Diego Abelenda ([email protected]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
persistentlocalstorage_project: local-storage | ||
persistentlocalstorage_classes: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
galaxy_info: | ||
author: Diego Abelenda | ||
description: OpenShift Persistent Local Volumes | ||
company: Camptocamp | ||
license: Apache License, Version 2.0 | ||
min_ansible_version: 1.9 | ||
platforms: | ||
- name: EL | ||
versions: | ||
- 7 | ||
dependencies: | ||
- role: lib_openshift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
--- | ||
- name: Create Namespace for Persistent Local Storage | ||
oc_project: | ||
name: "{{ persistentlocalstorage_project }}" | ||
|
||
- name: Create temp directory for template | ||
command: mktemp -d /tmp/openshift-ansible-XXXXXXX | ||
register: g_persistentstorage_mktemp | ||
changed_when: false | ||
|
||
- template: | ||
src: local-persistent-volume-config.j2 | ||
dest: "{{g_persistentstorage_mktemp.stdout}}/local-persistent-volume-config" | ||
changed_when: no | ||
|
||
- slurp: | ||
src: "{{g_persistentstorage_mktemp.stdout}}/local-persistent-volume-config" | ||
register: local_persistent_volume_config | ||
|
||
- name: Create ConfigMap for Persistent Local Storage Provisioner | ||
oc_obj: | ||
name: "local-volume-provisioner-config" | ||
namespace: "{{ persistentlocalstorage_project }}" | ||
kind: ConfigMap | ||
content: | ||
path: /tmp/cmplspout | ||
data: "{{ local_persistent_volume_config.content | b64decode | from_yaml }}" | ||
|
||
- name: Create ServiceAccount for Persistent Local Storage Provisioner | ||
oc_serviceaccount: | ||
name: "local-volume-provisioner" | ||
namespace: "{{ persistentlocalstorage_project }}" | ||
|
||
- name: Add SecurityContextContraint for Local Storage Provisioner | ||
oc_adm_policy_user: | ||
user: "system:serviceaccount:{{ persistentlocalstorage_project }}:local-volume-provisioner" | ||
namespace: "{{ persistentlocalstorage_project }}" | ||
resource_kind: scc | ||
resource_name: hostmount-anyuid | ||
state: present | ||
|
||
- name: Give rights to local-volume-provisioner to manage volumes | ||
oc_obj: | ||
state: present | ||
kind: ClusterRoleBinding | ||
name: local-storage:provisioner-pv-binding | ||
content: | ||
path: /tmp/crblvpout | ||
data: | ||
apiVersion: v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: local-storage:provisioner-pv-binding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: system:persistent-volume-provisioner | ||
subjects: | ||
- kind: ServiceAccount | ||
name: local-volume-provisioner | ||
namespace: "{{ persistentlocalstorage_project }}" | ||
|
||
- name: Give rights to local-volume-provisioner to list nodes | ||
oc_obj: | ||
state: present | ||
kind: ClusterRoleBinding | ||
name: local-storage:provisioner-node-binding | ||
content: | ||
path: /tmp/ls-provnode | ||
data: | ||
apiVersion: v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: local-storage:provisioner-node-binding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: system:node | ||
subjects: | ||
- kind: ServiceAccount | ||
name: local-volume-provisioner | ||
namespace: "{{ persistentlocalstorage_project }}" | ||
|
||
- name: Create Application Persistent Local Storage Provisioner | ||
oc_obj: | ||
kind: DaemonSet | ||
namespace: "{{ persistentlocalstorage_project }}" | ||
state: present | ||
name: local-volume-provisioner | ||
content: | ||
path: /tmp/plsprovout | ||
data: | ||
apiVersion: extensions/v1beta1 | ||
kind: DaemonSet | ||
metadata: | ||
name: local-volume-provisioner | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
app: local-volume-provisioner | ||
spec: | ||
containers: | ||
- env: | ||
- name: MY_NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: spec.nodeName | ||
- name: MY_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: metadata.namespace | ||
- name: VOLUME_CONFIG_NAME | ||
value: local-volume-provisioner-config | ||
image: quay.io/external_storage/local-volume-provisioner:v1.0.1 | ||
name: provisioner | ||
securityContext: | ||
runAsUser: 0 | ||
volumeMounts: | ||
- mountPath: /mnt/local-storage | ||
name: local-storage | ||
serviceAccountName: local-volume-provisioner | ||
volumes: | ||
- hostPath: | ||
path: /mnt/local-storage | ||
name: local-storage |
10 changes: 10 additions & 0 deletions
10
roles/openshift_persistentlocalstorage/templates/local-persistent-volume-config.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
apiVersion: v1 | ||
data: | ||
{% for class in persistentlocalstorage_classes %} | ||
{{class}}: '{ "hostDir": "/mnt/local-storage/{{ class }}", "mountDir" : "/mnt/local-storage/{{ class }}" }' | ||
{% endfor %} | ||
kind: ConfigMap | ||
metadata: | ||
creationTimestamp: null | ||
name: local-volume-provisioner-config |