From ff460d88bd4db946331bb84846c2794aeff92820 Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Sun, 13 Nov 2016 03:28:29 +0000 Subject: [PATCH] Adds glusterfs tasks for kubernetes app role --- roles/kubernetes-apps/ansible/tasks/main.yaml | 8 +++++++ .../glusterfs-kubernetes-endpoint.json.j2 | 24 +++++++++++++++++++ .../templates/glusterfs-kubernetes-pv.yml | 12 ++++++++++ 3 files changed, 44 insertions(+) create mode 100644 roles/kubernetes-apps/ansible/templates/glusterfs-kubernetes-endpoint.json.j2 create mode 100644 roles/kubernetes-apps/ansible/templates/glusterfs-kubernetes-pv.yml diff --git a/roles/kubernetes-apps/ansible/tasks/main.yaml b/roles/kubernetes-apps/ansible/tasks/main.yaml index a65b6b527..2bb56679c 100644 --- a/roles/kubernetes-apps/ansible/tasks/main.yaml +++ b/roles/kubernetes-apps/ansible/tasks/main.yaml @@ -7,6 +7,14 @@ register: manifests when: inventory_hostname == groups['kube-master'][0] +- name: Kubernetes Apps | Lay Down k8s GlusterFS Endpoint and PV + template: src={{item.file}} dest=/etc/kubernetes/{{item.dest}} + with_items: + - {file: glusterfs-kubernetes-endpoint.json.j2, type: ep, dest: glusterfs-kubernetes-endpoint.json} + - {file: glusterfs-kubernetes-pv.yml, type: pv, dest: glusterfs-kubernetes-pv.yml} + register: manifests + when: inventory_hostname == groups['kube-master'][0] and groups[gfs-cluster] is defined + - name: Kubernetes Apps | Start Resources kube: name: kubedns diff --git a/roles/kubernetes-apps/ansible/templates/glusterfs-kubernetes-endpoint.json.j2 b/roles/kubernetes-apps/ansible/templates/glusterfs-kubernetes-endpoint.json.j2 new file mode 100644 index 000000000..93610dcff --- /dev/null +++ b/roles/kubernetes-apps/ansible/templates/glusterfs-kubernetes-endpoint.json.j2 @@ -0,0 +1,24 @@ +{ + "kind": "Endpoints", + "apiVersion": "v1", + "metadata": { + "name": "glusterfs-cluster" + }, + "subsets": [ + { + "addresses": [ + { + {% for host in groups['gfs-cluster'] %} + "ip": "{{hostvars[host]['ansible_eth0']['ipv4']['address']}}"{%- if not loop.last %}, {% endif -%} + {% endfor %} + } + ], + "ports": [ + { + "port": 1 + } + ] + } + ] +} + diff --git a/roles/kubernetes-apps/ansible/templates/glusterfs-kubernetes-pv.yml b/roles/kubernetes-apps/ansible/templates/glusterfs-kubernetes-pv.yml new file mode 100644 index 000000000..091e9bd75 --- /dev/null +++ b/roles/kubernetes-apps/ansible/templates/glusterfs-kubernetes-pv.yml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: gluster-default-volume +spec: + accessModes: + - ReadWriteMany + glusterfs: + endpoints: glusterfs-cluster + path: gluster + readOnly: false + persistentVolumeReclaimPolicy: Retain