Browse Source

GlusterFS: Allow configuration of heketi port

Signed-off-by: Jose A. Rivera <jarrpa@redhat.com>
Jose A. Rivera 7 years ago
parent
commit
3b3c6a33f5

+ 2 - 1
roles/openshift_storage_glusterfs/README.md

@@ -90,7 +90,8 @@ GlusterFS cluster into a new or existing OpenShift cluster:
 | openshift_storage_glusterfs_heketi_admin_key     | auto-generated          | String to use as secret key for performing heketi commands as admin
 | openshift_storage_glusterfs_heketi_user_key      | auto-generated          | String to use as secret key for performing heketi commands as user that can only view or modify volumes
 | openshift_storage_glusterfs_heketi_topology_load | True                    | Load the GlusterFS topology information into heketi
-| openshift_storage_glusterfs_heketi_url           | Undefined               | URL for the heketi REST API, dynamically determined in native mode
+| openshift_storage_glusterfs_heketi_url           | Undefined               | When heketi is native, this sets the hostname portion of the final heketi route URL. When heketi is external, this is the full URL to the heketi service.
+| openshift_storage_glusterfs_heketi_port          | 8080                    | TCP port for external heketi service **NOTE:** This has no effect in native mode
 | openshift_storage_glusterfs_heketi_wipe          | False                   | Destroy any existing heketi resources, defaults to the value of `openshift_storage_glusterfs_wipe`
 
 Each role variable also has a corresponding variable to optionally configure a

+ 2 - 0
roles/openshift_storage_glusterfs/defaults/main.yml

@@ -18,6 +18,7 @@ openshift_storage_glusterfs_heketi_user_key: "{{ 32 | oo_generate_secret }}"
 openshift_storage_glusterfs_heketi_topology_load: True
 openshift_storage_glusterfs_heketi_wipe: "{{ openshift_storage_glusterfs_wipe }}"
 openshift_storage_glusterfs_heketi_url: "{{ omit }}"
+openshift_storage_glusterfs_heketi_port: 8080
 
 openshift_storage_glusterfs_registry_timeout: "{{ openshift_storage_glusterfs_timeout }}"
 openshift_storage_glusterfs_registry_namespace: "{{ openshift.hosted.registry.namespace | default('default') }}"
@@ -38,3 +39,4 @@ openshift_storage_glusterfs_registry_heketi_user_key: "{{ 32 | oo_generate_secre
 openshift_storage_glusterfs_registry_heketi_topology_load: "{{ openshift_storage_glusterfs_heketi_topology_load }}"
 openshift_storage_glusterfs_registry_heketi_wipe: "{{ openshift_storage_glusterfs_heketi_wipe }}"
 openshift_storage_glusterfs_registry_heketi_url: "{{ openshift_storage_glusterfs_heketi_url | default(omit) }}"
+openshift_storage_glusterfs_registry_heketi_port: 8080

+ 5 - 1
roles/openshift_storage_glusterfs/files/v3.6/deploy-heketi-template.yml

@@ -29,7 +29,7 @@ objects:
 - kind: Route
   apiVersion: v1
   metadata:
-    name: deploy-heketi-${CLUSTER_NAME}
+    name: ${HEKETI_ROUTE}
     labels:
       glusterfs: deploy-heketi-${CLUSTER_NAME}-route
       deploy-heketi: support
@@ -115,6 +115,10 @@ parameters:
   displayName: Namespace
   description: Set the namespace where the GlusterFS pods reside
   value: default
+- name: HEKETI_ROUTE
+  displayName: heketi route name
+  description: Set the hostname for the route URL
+  value: "heketi-glusterfs"
 - name: IMAGE_NAME
   displayName: heketi container image name
   required: True

+ 5 - 1
roles/openshift_storage_glusterfs/files/v3.6/heketi-template.yml

@@ -27,7 +27,7 @@ objects:
 - kind: Route
   apiVersion: v1
   metadata:
-    name: heketi-${CLUSTER_NAME}
+    name: ${HEKETI_ROUTE}
     labels:
       glusterfs: heketi-${CLUSTER_NAME}-route
   spec:
@@ -109,6 +109,10 @@ parameters:
   displayName: Namespace
   description: Set the namespace where the GlusterFS pods reside
   value: default
+- name: HEKETI_ROUTE
+  displayName: heketi route name
+  description: Set the hostname for the route URL
+  value: "heketi-glusterfs"
 - name: IMAGE_NAME
   displayName: heketi container image name
   required: True

+ 21 - 7
roles/openshift_storage_glusterfs/tasks/glusterfs_common.yml

@@ -129,15 +129,9 @@
   - glusterfs_heketi_deploy_is_missing
   - glusterfs_heketi_is_missing
 
-- name: Set heketi URL
-  set_fact:
-    glusterfs_heketi_url: "localhost:8080"
-  when:
-  - glusterfs_heketi_is_native
-
 - name: Set heketi-cli command
   set_fact:
-    glusterfs_heketi_client: "{% if glusterfs_heketi_is_native %}oc rsh {{ heketi_pod.results.results[0]['items'][0]['metadata']['name'] }} {% endif %}heketi-cli -s http://{{ glusterfs_heketi_url }} --user admin --secret '{{ glusterfs_heketi_admin_key }}'"
+    glusterfs_heketi_client: "{% if glusterfs_heketi_is_native %}oc rsh {{ heketi_pod.results.results[0]['items'][0]['metadata']['name'] }} {% endif %}heketi-cli -s http://{% if glusterfs_heketi_is_native %}localhost:8080{% else %}{{ glusterfs_heketi_url }}:{{ glusterfs_heketi_port }}{% endif %} --user admin --secret '{{ glusterfs_heketi_admin_key }}'"
 
 - name: Verify heketi service
   command: "{{ glusterfs_heketi_client }} cluster list"
@@ -166,10 +160,30 @@
     - path: key
       data: "{{ glusterfs_heketi_user_key }}"
 
+- name: Get heketi route
+  oc_obj:
+    namespace: "{{ glusterfs_namespace }}"
+    kind: route
+    state: list
+    name: "heketi-{{ glusterfs_name }}"
+  register: heketi_route
+  when:
+  - glusterfs_storageclass
+  - glusterfs_heketi_is_native
+
+- name: Determine StorageClass heketi URL
+  set_fact:
+    glusterfs_heketi_route: "{{ heketi_route.results.results[0]['spec']['host'] }}"
+  when:
+  - glusterfs_storageclass
+  - glusterfs_heketi_is_native
+
 - name: Generate GlusterFS StorageClass file
   template:
     src: "{{ openshift.common.examples_content_version }}/glusterfs-storageclass.yml.j2"
     dest: "{{ mktemp.stdout }}/glusterfs-storageclass.yml"
+  when:
+  - glusterfs_storageclass
 
 - name: Create GlusterFS StorageClass
   oc_obj:

+ 1 - 0
roles/openshift_storage_glusterfs/tasks/glusterfs_config.yml

@@ -19,6 +19,7 @@
     glusterfs_heketi_topology_load: "{{ openshift_storage_glusterfs_heketi_topology_load }}"
     glusterfs_heketi_wipe: "{{ openshift_storage_glusterfs_heketi_wipe }}"
     glusterfs_heketi_url: "{{ openshift_storage_glusterfs_heketi_url }}"
+    glusterfs_heketi_port: "{{ openshift_storage_glusterfs_heketi_port }}"
     glusterfs_nodes: "{{ groups.glusterfs }}"
 
 - include: glusterfs_common.yml

+ 1 - 0
roles/openshift_storage_glusterfs/tasks/glusterfs_registry.yml

@@ -19,6 +19,7 @@
     glusterfs_heketi_topology_load: "{{ openshift_storage_glusterfs_registry_heketi_topology_load }}"
     glusterfs_heketi_wipe: "{{ openshift_storage_glusterfs_registry_heketi_wipe }}"
     glusterfs_heketi_url: "{{ openshift_storage_glusterfs_registry_heketi_url }}"
+    glusterfs_heketi_port: "{{ openshift_storage_glusterfs_registry_heketi_port }}"
     glusterfs_nodes: "{{ groups.glusterfs_registry }}"
 
 - include: glusterfs_common.yml

+ 1 - 0
roles/openshift_storage_glusterfs/tasks/heketi_deploy_part1.yml

@@ -33,6 +33,7 @@
     params:
       IMAGE_NAME: "{{ glusterfs_heketi_image }}"
       IMAGE_VERSION: "{{ glusterfs_heketi_version }}"
+      HEKETI_ROUTE: "{{ glusterfs_heketi_url | default(['heketi-',glusterfs_name]|join) }}"
       HEKETI_USER_KEY: "{{ glusterfs_heketi_user_key }}"
       HEKETI_ADMIN_KEY: "{{ glusterfs_heketi_admin_key }}"
       HEKETI_KUBE_NAMESPACE: "{{ glusterfs_namespace }}"

+ 2 - 1
roles/openshift_storage_glusterfs/tasks/heketi_deploy_part2.yml

@@ -103,6 +103,7 @@
     params:
       IMAGE_NAME: "{{ glusterfs_heketi_image }}"
       IMAGE_VERSION: "{{ glusterfs_heketi_version }}"
+      HEKETI_ROUTE: "{{ glusterfs_heketi_url | default(['heketi-',glusterfs_name]|join) }}"
       HEKETI_USER_KEY: "{{ glusterfs_heketi_user_key }}"
       HEKETI_ADMIN_KEY: "{{ glusterfs_heketi_admin_key }}"
       HEKETI_KUBE_NAMESPACE: "{{ glusterfs_namespace }}"
@@ -124,7 +125,7 @@
 
 - name: Set heketi-cli command
   set_fact:
-    glusterfs_heketi_client: "{% if glusterfs_heketi_is_native %}oc rsh {{ heketi_pod.results.results[0]['items'][0]['metadata']['name'] }} {% endif %}heketi-cli -s http://localhost:8080 --user admin --secret '{{ glusterfs_heketi_admin_key }}'"
+    glusterfs_heketi_client: "oc rsh {{ heketi_pod.results.results[0]['items'][0]['metadata']['name'] }} heketi-cli -s http://localhost:8080 --user admin --secret '{{ glusterfs_heketi_admin_key }}'"
 
 - name: Verify heketi service
   command: "{{ glusterfs_heketi_client }} cluster list"

+ 2 - 1
roles/openshift_storage_glusterfs/templates/v3.6/glusterfs-storageclass.yml.j2

@@ -5,6 +5,7 @@ metadata:
   name: glusterfs-{{ glusterfs_name }}
 provisioner: kubernetes.io/glusterfs
 parameters:
-  resturl: "http://{{ glusterfs_heketi_url }}:8081"
+  resturl: "http://{% if glusterfs_heketi_is_native %}{{ glusterfs_heketi_route }}{% else %}{{ glusterfs_heketi_url }}:{{ glusterfs_heketi_port }}{% endif %}"
+  restuser: "user"
   secretNamespace: "{{ glusterfs_namespace }}"
   secretName: "heketi-{{ glusterfs_name }}-user-secret"