Skip to content

Commit

Permalink
Add first test of configuration local volume provisionner
Browse files Browse the repository at this point in the history
  • Loading branch information
dabelenda committed Nov 24, 2017
1 parent 3db002a commit 09f0291
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
2 changes: 2 additions & 0 deletions roles/openshift_persistent_volumes/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
openshift_persistentlocalstorage_project: local-storage
openshift_persistentlocalstorage_classes: []
107 changes: 107 additions & 0 deletions roles/openshift_persistent_volumes/persistent_local_storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
- name: Create Namespace for Persistent Local Storage
oc_project:
name: "{{ openshift_persistentlocalstorage_project }}"

- template:
src: local-persistent-volume-config.yml.j2
dest: "{{ tempdir }}/local-persistent-volume-config.yml"
changed_when: no


- name: Create ConfigMap for Persistent Local Storage Provisionner
oc_configmap:
name: "local-volume-provisionner-config"
namespace: "{{ openshift_persistentlocalstorage_project }}"
from_file: "{{ tempdir }}/local-persistent-volume-config.yml"

- name: Create ServiceAccount for Persistent Local Storage Provisionner
oc_serviceaccount:
name: "local-volume-provisionner"
namespace: "{{ openshift_persistentlocalstorage_project }}"

- name: Give rights to local-volume-provisionner to manage volumes
oc_obj:
state: present
kind: ClusterRoleBinding
name: local-storage:provisioner-pv-binding
data:
path: /tmp/crblvpout
content:
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-provider
namespace: "{{ openshift_persistentlocalstorage_project }}"

- name: Give rights to local-volume-provisionner to list nodes
oc_obj:
state: present
kind: ClusterRoleBinding
name: local-storage:provisioner-node-binding
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-provider
namespace: "{{ openshift_persistentlocalstorage_project }}"

- name: Create Application Persistent Local Storage Provisionner
oc_obj:
kind: DaemonSet
namespace: "{{ openshift_persistentlocalstorage_project }}"
state: present
name: local-volume-provisionner
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-provisionner-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-provisionner
volumes:
- hostPath:
path: /mnt/local-storage
name: local-storage
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% for class in openshift_persistentlocalstorage_classes %}
{{class}}: '{ "hostDir": "/mnt/local-storage/{{ class }}", "mountDir" : "/mnt/local-storage/{{ class }}" }'
{% endfor %}

0 comments on commit 09f0291

Please sign in to comment.