From 15ca45191af7c5c2f04f9096922590412e889e17 Mon Sep 17 00:00:00 2001 From: Jason DeTiberus Date: Fri, 6 Nov 2015 10:36:57 -0500 Subject: Remove v1beta3 by default for kube_nfs_volumes --- roles/kube_nfs_volumes/README.md | 3 +++ roles/kube_nfs_volumes/defaults/main.yml | 6 ++++++ roles/kube_nfs_volumes/tasks/main.yml | 13 ++++++------ roles/kube_nfs_volumes/templates/nfs.json.j2 | 23 ---------------------- roles/kube_nfs_volumes/templates/v1/nfs.json.j2 | 1 + .../kube_nfs_volumes/templates/v1beta3/nfs.json.j2 | 23 ++++++++++++++++++++++ 6 files changed, 40 insertions(+), 29 deletions(-) delete mode 100644 roles/kube_nfs_volumes/templates/nfs.json.j2 create mode 120000 roles/kube_nfs_volumes/templates/v1/nfs.json.j2 create mode 100644 roles/kube_nfs_volumes/templates/v1beta3/nfs.json.j2 diff --git a/roles/kube_nfs_volumes/README.md b/roles/kube_nfs_volumes/README.md index 56c69c286..1520f79b2 100644 --- a/roles/kube_nfs_volumes/README.md +++ b/roles/kube_nfs_volumes/README.md @@ -44,6 +44,9 @@ kubernetes_url: https://10.245.1.2:6443 # Token to use for authentication to the API server kubernetes_token: tJdce6Fn3cL1112YoIJ5m2exzAbzcPZX + +# API Version to use for kubernetes +kube_api_version: v1 ``` ## Dependencies diff --git a/roles/kube_nfs_volumes/defaults/main.yml b/roles/kube_nfs_volumes/defaults/main.yml index e296492f9..bdd994d07 100644 --- a/roles/kube_nfs_volumes/defaults/main.yml +++ b/roles/kube_nfs_volumes/defaults/main.yml @@ -1,4 +1,10 @@ --- +kubernetes_url: https://172.30.0.1:443 + +kube_api_version: v1 + +kube_req_template: "../templates/{{ kube_api_version }}/nfs.json.j2" + # Options of NFS exports. nfs_export_options: "*(rw,no_root_squash,insecure,no_subtree_check)" diff --git a/roles/kube_nfs_volumes/tasks/main.yml b/roles/kube_nfs_volumes/tasks/main.yml index f4a506234..d1dcf261a 100644 --- a/roles/kube_nfs_volumes/tasks/main.yml +++ b/roles/kube_nfs_volumes/tasks/main.yml @@ -16,10 +16,11 @@ - include: nfs.yml - name: export physical volumes - uri: url={{ kubernetes_url }}/api/v1beta3/persistentvolumes - method=POST - body='{{ lookup("template", "../templates/nfs.json.j2") }}' - body_format=json - status_code=201 - HEADER_Authorization="Bearer {{ kubernetes_token }}" + uri: + url: "{{ kubernetes_url }}/api/{{ kube_api_version }}/persistentvolumes" + method: POST + body: "{{ lookup('template', kube_req_template) }}" + body_format: json + status_code: 201 + HEADER_Authorization: "Bearer {{ kubernetes_token }}" with_items: partition_pool diff --git a/roles/kube_nfs_volumes/templates/nfs.json.j2 b/roles/kube_nfs_volumes/templates/nfs.json.j2 deleted file mode 100644 index b42886ef1..000000000 --- a/roles/kube_nfs_volumes/templates/nfs.json.j2 +++ /dev/null @@ -1,23 +0,0 @@ -{ - "kind": "PersistentVolume", - "apiVersion": "v1beta3", - "metadata": { - "name": "pv-{{ inventory_hostname | regex_replace("\.", "-") }}-{{ item.name }}", - "labels": { - "type": "nfs" - } - }, - "spec": { - "capacity": { - "storage": "{{ item.size }}" - }, - "accessModes": [ - "ReadWriteOnce" - ], - "NFS": { - "Server": "{{ inventory_hostname }}", - "Path": "{{ mount_dir }}/{{ item.name }}", - "ReadOnly": false - } - } -} diff --git a/roles/kube_nfs_volumes/templates/v1/nfs.json.j2 b/roles/kube_nfs_volumes/templates/v1/nfs.json.j2 new file mode 120000 index 000000000..49c1191bc --- /dev/null +++ b/roles/kube_nfs_volumes/templates/v1/nfs.json.j2 @@ -0,0 +1 @@ +../v1beta3/nfs.json.j2 \ No newline at end of file diff --git a/roles/kube_nfs_volumes/templates/v1beta3/nfs.json.j2 b/roles/kube_nfs_volumes/templates/v1beta3/nfs.json.j2 new file mode 100644 index 000000000..b42886ef1 --- /dev/null +++ b/roles/kube_nfs_volumes/templates/v1beta3/nfs.json.j2 @@ -0,0 +1,23 @@ +{ + "kind": "PersistentVolume", + "apiVersion": "v1beta3", + "metadata": { + "name": "pv-{{ inventory_hostname | regex_replace("\.", "-") }}-{{ item.name }}", + "labels": { + "type": "nfs" + } + }, + "spec": { + "capacity": { + "storage": "{{ item.size }}" + }, + "accessModes": [ + "ReadWriteOnce" + ], + "NFS": { + "Server": "{{ inventory_hostname }}", + "Path": "{{ mount_dir }}/{{ item.name }}", + "ReadOnly": false + } + } +} -- cgit v1.2.3