Skip to content

Commit

Permalink
Merge pull request minio#143 from jmontleon/add-rwx-logic
Browse files Browse the repository at this point in the history
Closes minio#140, Make RWX Volume Optional
  • Loading branch information
jortel authored Jan 18, 2023
2 parents 9e01a4f + a62be6f commit 3250eac
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 82 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ hub_bucket_volume_size | 100gi | Size requested for Hub bucket volume
keycloak_database_data_volume_size | 1Gi | Size requested for Keycloak DB volume
pathfinder_database_data_volume_size | 1Gi | Size requested for Pathfinder DB volume
maven_data_volume_size | 100Gi | Size requested for maven m2 repository volume
rwx_storage_class | N/A | Storage class requested for Tackle RWX volumes
rwo_storage_class | N/A | Storage class requested for Tackle RWO volumes
cache_storage_class | N/A | Storage class requested for Tackle Cache volume
hub_bucket_storage_class | N/A | Storage class requested for Tackle Hub Bucket volume

## Tackle CR Customize Settings

Expand Down Expand Up @@ -173,7 +173,7 @@ metadata:
namespace: <your-tackle-namespace>
spec:
hub_bucket_volume_size: "50Gi"
rwx_storage_class: "nfs"
cache_storage_class: "nfs"
```

## Development
Expand Down
14 changes: 0 additions & 14 deletions bundle/manifests/tackle.konveyor.io_addons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,6 @@ spec:
- Always
- Never
type: string
mounts:
description: Mounts optional.
items:
description: Mount specification.
properties:
claim:
type: string
name:
type: string
required:
- claim
- name
type: object
type: array
resources:
description: Resource requirements.
properties:
Expand Down
12 changes: 8 additions & 4 deletions roles/tackle/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ hub_bucket_volume_name: "{{ hub_service_name }}-bucket"
hub_bucket_volume_size: "100Gi"
hub_bucket_volume_path: "/buckets"
hub_bucket_volume_claim_name: "{{ hub_service_name }}-bucket-volume-claim"
hub_bucket_volume_claim_mode: ReadWriteOnce
hub_seed_configmap_name: "{{ hub_service_name }}-seed"
hub_seed_configmap_path: "/seed"
hub_addon_working_path: "/working"
Expand Down Expand Up @@ -167,10 +168,13 @@ windup_service_name: "{{ app_name }}-{{ windup_name }}-{{ windup_component_name
windup_container_requests_cpu: "500m"
windup_container_requests_memory: "2Gi"

maven_name: "maven"
maven_data_volume_size: "100Gi"
maven_data_volume_name: "{{ app_name }}-{{ maven_name }}-data"
maven_data_volume_claim_name: "{{ app_name }}-{{ maven_name }}-volume-claim"
cache_name: "cache"
cache_data_volume_size: "100Gi"
cache_data_volume_name: "{{ app_name }}-{{ cache_name }}-data"
cache_data_volume_claim_name: "{{ app_name }}-{{ cache_name }}-volume-claim"
cache_data_volume_claim_mode: "ReadWriteMany"
cache_mount_path: "/cache"
rwx_supported: true

# RH-SSO specific
rhsso_name: "rhsso"
Expand Down
51 changes: 39 additions & 12 deletions roles/tackle/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
set_fact:
api_groups: "{{ lookup('k8s', cluster_info='api_groups') }}"

- name: Transfer rwx_storage_class setting if hub_bucket_storage_class is not defined
set_fact:
hub_bucket_storage_class: "{{ rwx_storage_class }}"
when: rwx_storage_class is defined and hub_bucket_storage_class is not defined

- name: Transfer rwx_storage_class setting if hub_bucket_storage_class is not defined
set_fact:
cache_storage_class: "{{ rwx_storage_class }}"
when: rwx_storage_class is defined and cache_storage_class is not defined

- name: "Enable OpenShift cluster environment"
set_fact:
openshift_cluster: true
Expand Down Expand Up @@ -213,6 +223,19 @@
state: present
definition: "{{ lookup('template', 'persistentvolumeclaim-hub-database.yml.j2') }}"

- name: "Retrieve the Hub API Bucket if it already exists"
k8s_info:
api_version: v1
kind: PersistentVolumeClaim
name: "{{ hub_bucket_volume_claim_name }}"
namespace: "{{ app_namespace }}"
register: hub_bucket

- name: "Update the Hub Bucket Access Mode to reflect its current state"
when: hub_bucket.resources | length > 0
set_fact:
hub_bucket_volume_claim_mode: "{{ (hub_bucket.resources | first).spec.accessModes | first }}"

- name: "Setup Hub API Bucket PersistentVolumeClaim"
k8s:
state: present
Expand Down Expand Up @@ -263,6 +286,7 @@
k8s:
state: present
definition: "{{ lookup('template', 'deployment-hub.yml.j2') }}"
merge_type: merge

- name: "Setup UI Service"
k8s:
Expand All @@ -286,24 +310,27 @@
definition: "{{ lookup('template', 'route-ui.yml.j2') }}"
when: openshift_cluster|bool

- name: "Setup Maven PersistentVolumeClaim"
- name: "Setup Cache PersistentVolumeClaim"
k8s:
state: present
definition: "{{ lookup('template', 'persistentvolumeclaim-maven.yml.j2') }}"
definition: "{{ lookup('template', 'persistentvolumeclaim-cache.yml.j2') }}"
when: (rwx_supported | bool)

- name: "Check if Admin Addon CR exists already so we don't update it"
k8s_info:
api_version: tackle.konveyor.io/v1alpha1
kind: Addon
name: "{{ admin_name }}"
- name: "Remove Maven PersistentVolumeClaim"
k8s:
state: absent
kind: PersistentVolumeClaim
api_version: v1
name: "{{ app_name }}-maven-volume-claim"
namespace: "{{ app_namespace }}"
register: admin_cr_status

- name: "Create Admin Addon CR"
- name: "Remove Admin Addon CR"
k8s:
state: present
definition: "{{ lookup('template', 'customresource-addon-admin.yml.j2') }}"
when: (admin_cr_status.resources | length) == 0
state: absent
kind: Addon
api_version: tackle.konveyor.io/v1alpha1
name: "{{ admin_name }}"
namespace: "{{ app_namespace }}"

- name: "Check if Windup Addon CR exists already so we don't update it"
k8s_info:
Expand Down
19 changes: 0 additions & 19 deletions roles/tackle/templates/customresource-addon-admin.yml.j2

This file was deleted.

3 changes: 0 additions & 3 deletions roles/tackle/templates/customresource-addon-windup.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ metadata:
app.kubernetes.io/part-of: {{ app_name }}
spec:
image: {{ windup_fqin }}
mounts:
- claim: {{ maven_data_volume_claim_name }}
name: m2
resources:
requests:
cpu: {{ windup_container_requests_cpu }}
Expand Down
17 changes: 17 additions & 0 deletions roles/tackle/templates/deployment-hub.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ spec:
{% if hub_task_retries is defined %}
- name: TASK_RETRIES
value: "{{ hub_task_retries }}"
{% endif %}
- name: RWX_SUPPORTED
value: "{{ rwx_supported | string | lower }}"
{% if rwx_supported|bool %}
- name: CACHE_PVC
value: "{{ cache_data_volume_claim_name }}"
- name: CACHE_PATH
value: "{{ cache_mount_path }}"
{% endif %}
ports:
- containerPort: {{ hub_port }}
Expand All @@ -168,11 +176,20 @@ spec:
- name: {{ hub_seed_configmap_name }}
mountPath: {{ hub_seed_configmap_path }}
readOnly: true
{% if rwx_supported|bool %}
- name: {{ cache_data_volume_name }}
mountPath: {{ cache_mount_path }}
{% endif %}
{% if hub_tls_enabled|bool %}
- name: {{ hub_tls_secret_name }}
mountPath: /var/run/secrets/{{ hub_tls_secret_name }}/tls.crt
{% endif %}
volumes:
{% if rwx_supported|bool %}
- name: {{ cache_data_volume_name }}
persistentVolumeClaim:
claimName: {{ cache_data_volume_claim_name }}
{% endif %}
- name: {{ hub_database_volume_name }}
persistentVolumeClaim:
claimName: {{ hub_database_volume_claim_name }}
Expand Down
2 changes: 2 additions & 0 deletions roles/tackle/templates/deployment-ui.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ spec:
- name: UI_TLS_ENABLED
value: 'false'
{% endif %}
- name: RWX_SUPPORTED
value: "{{ rwx_supported | string | lower }}"
ports:
- containerPort: {{ ui_port }}
protocol: TCP
Expand Down
23 changes: 23 additions & 0 deletions roles/tackle/templates/persistentvolumeclaim-cache.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ cache_data_volume_claim_name }}
namespace: {{ app_namespace }}
labels:
app.kubernetes.io/name: {{ cache_name }}
app.kubernetes.io/part-of: {{ app_name }}
volume: {{ cache_data_volume_name }}
spec:
accessModes:
- "{{ cache_data_volume_claim_mode }}"
resources:
requests:
storage: {{ cache_data_volume_size }}
{% if cache_storage_class is defined %}
{% if cache_storage_class|length %}
storageClassName: {{ cache_storage_class }}
{% else %}
storageClassName: ""
{% endif %}
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ metadata:
volume: {{ hub_bucket_volume_name }}
spec:
accessModes:
- ReadWriteMany
- {{ hub_bucket_volume_claim_mode }}
resources:
requests:
storage: {{ hub_bucket_volume_size }}
{% if rwx_storage_class is defined %}
{% if rwx_storage_class|length %}
storageClassName: {{ rwx_storage_class }}
{% if hub_bucket_storage_class is defined %}
{% if hub_bucket_storage_class|length %}
storageClassName: {{ hub_bucket_storage_class }}
{% else %}
storageClassName: ""
{% endif %}
Expand Down
23 changes: 0 additions & 23 deletions roles/tackle/templates/persistentvolumeclaim-maven.yml.j2

This file was deleted.

0 comments on commit 3250eac

Please sign in to comment.