|
| 1 | +--- |
| 2 | +# LVMS-specific tasks for Quay: PVC, QuayRegistry, and deployment patch to mount registry storage. |
| 3 | +# Included from tasks.yaml only when blockStorageBackend == 'lvms'. |
| 4 | + |
| 5 | +- name: Create LVMS PVC for Quay Storage |
| 6 | + kubernetes.core.k8s: |
| 7 | + state: present |
| 8 | + definition: |
| 9 | + apiVersion: v1 |
| 10 | + kind: PersistentVolumeClaim |
| 11 | + metadata: |
| 12 | + name: quay-storage-pvc |
| 13 | + namespace: quay-enterprise |
| 14 | + spec: |
| 15 | + accessModes: |
| 16 | + - ReadWriteOnce |
| 17 | + resources: |
| 18 | + requests: |
| 19 | + storage: 300Gi |
| 20 | + storageClassName: lvms-vg1 |
| 21 | + |
| 22 | +- name: Ensure QuayRegistry is present (LVMS Backend) |
| 23 | + kubernetes.core.k8s: |
| 24 | + state: present |
| 25 | + definition: |
| 26 | + apiVersion: quay.redhat.com/v1 |
| 27 | + kind: QuayRegistry |
| 28 | + metadata: |
| 29 | + name: registry |
| 30 | + namespace: quay-enterprise |
| 31 | + spec: |
| 32 | + configBundleSecret: quay-config |
| 33 | + components: |
| 34 | + - kind: objectstorage |
| 35 | + managed: false |
| 36 | + - kind: quay |
| 37 | + managed: true |
| 38 | + overrides: |
| 39 | + replicas: 1 |
| 40 | + resources: |
| 41 | + limits: |
| 42 | + cpu: "4" |
| 43 | + memory: 12Gi |
| 44 | + requests: |
| 45 | + cpu: "{{ '2' if (disconnected | default(true)) else '1' }}" |
| 46 | + memory: "{{ '6Gi' if (disconnected | default(true)) else '4Gi' }}" |
| 47 | + - kind: horizontalpodautoscaler |
| 48 | + managed: false |
| 49 | + retries: 1 |
| 50 | + delay: 10 |
| 51 | + register: r_quay_lvms |
| 52 | + until: r_quay_lvms is succeeded |
| 53 | + |
| 54 | +- name: Wait for Quay app deployment to exist (LVMS) |
| 55 | + kubernetes.core.k8s_info: |
| 56 | + api_version: apps/v1 |
| 57 | + kind: Deployment |
| 58 | + namespace: quay-enterprise |
| 59 | + name: registry-quay-app |
| 60 | + register: quay_app_deployment |
| 61 | + retries: 30 |
| 62 | + delay: 10 |
| 63 | + until: quay_app_deployment.resources | length > 0 |
| 64 | + |
| 65 | +- name: Set quay container index for LVMS patch (first container is the app) |
| 66 | + ansible.builtin.set_fact: |
| 67 | + quay_container_index: 0 |
| 68 | + when: quay_app_deployment.resources | default([]) | length > 0 |
| 69 | + |
| 70 | +- name: Check if Quay app deployment already has registry-storage volume (LVMS) |
| 71 | + ansible.builtin.set_fact: |
| 72 | + quay_registry_storage_already_patched: "{{ quay_app_deployment.resources[0].spec.template.spec.volumes | selectattr('name', 'equalto', 'registry-storage') | list | length > 0 }}" |
| 73 | + when: quay_app_deployment.resources | default([]) | length > 0 |
| 74 | + |
| 75 | +- name: Patch Quay app deployment to mount registry storage PVC (LVMS) |
| 76 | + environment: |
| 77 | + KUBECONFIG: "{{ workingDir }}/ocp-cluster/auth/kubeconfig" |
| 78 | + ansible.builtin.shell: | |
| 79 | + oc patch deployment registry-quay-app -n quay-enterprise --type=json -p='{{ quay_lvms_patch | to_json }}' |
| 80 | + args: |
| 81 | + executable: /bin/bash |
| 82 | + vars: |
| 83 | + quay_lvms_patch: |
| 84 | + - op: add |
| 85 | + path: /spec/template/spec/volumes/- |
| 86 | + value: |
| 87 | + name: registry-storage |
| 88 | + persistentVolumeClaim: |
| 89 | + claimName: quay-storage-pvc |
| 90 | + - op: add |
| 91 | + path: /spec/template/spec/containers/{{ quay_container_index }}/volumeMounts/- |
| 92 | + value: |
| 93 | + name: registry-storage |
| 94 | + mountPath: /datastorage/registry |
| 95 | + when: |
| 96 | + - quay_app_deployment.resources | default([]) | length > 0 |
| 97 | + - quay_container_index is defined |
| 98 | + - not (quay_registry_storage_already_patched | default(false)) |
| 99 | + register: quay_patch_result |
0 commit comments