diff --git a/templates/core/extraObjects.yaml b/templates/core/extraObjects.yaml new file mode 100644 index 0000000..6988285 --- /dev/null +++ b/templates/core/extraObjects.yaml @@ -0,0 +1,7 @@ +{{- range $objname, $obj := .Values.clusterGroup.extraObjects }} +{{- if not $obj.disabled }} +--- +{{- $obj := unset $obj "disabled" }} +{{ $obj | toYaml }} +{{- end }}{{- /* if not $obj.disabled */}} +{{- end }}{{- /* range $obj */}} diff --git a/templates/core/subscriptions.yaml b/templates/core/subscriptions.yaml index 23aa660..4217713 100644 --- a/templates/core/subscriptions.yaml +++ b/templates/core/subscriptions.yaml @@ -79,4 +79,40 @@ spec: {{- end }}{{/* if $.Values.global.options.useCSV */}} --- {{- end }}{{/* if $subs.namespaces */}} +{{- if and $subs.sequenceJob (not $subs.sequenceJob.disabled) }}{{/* if $subs.sequenceJob */}} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ $subs.name }}-sequencejob + annotations: + argocd.argoproj.io/hook: {{ coalesce $subs.sequenceJob.hookType "Sync" }} + argocd.argoproj.io/sync-wave: {{ coalesce $subs.sequenceJob.syncWave (get $subs.annotations "argocd.argoproj.io/sync-wave") | quote }} +spec: + parallelism: 1 + completions: 1 + template: + spec: + restartPolicy: OnFailure + containers: + - name: {{ $subs.name }}-sequencejob + image: {{ coalesce $subs.sequenceJob.image "quay.io/hybridcloudpatterns/imperative-container:v1" }} + {{- if $subs.sequenceJob.command }} + command: {{ $subs.sequenceJob.command | toJson }} + {{- else }} + command: + - /bin/bash + - -c + - | + while [ 1 ]; + do + oc get {{ $subs.sequenceJob.resourceType }} {{ $subs.sequenceJob.resourceName }} {{- if $subs.sequenceJob.resourceNamespace }} -n {{ $subs.sequenceJob.resourceNamespace }}{{- end }} && break + echo "{{ $subs.sequenceJob.resourceType }} {{ $subs.sequenceJob.resourceName }} {{- if $subs.sequenceJob.resourceNamespace }} in {{ $subs.sequenceJob.resourceNamespace}} {{- end }} not found, waiting..." + sleep 5 + done + echo "{{ $subs.sequenceJob.resourceType }} {{ $subs.sequenceJob.resourceName }} {{- if $subs.sequenceJob.resourceNamespace }} in {{ $subs.sequenceJob.resourceNamespace}} {{- end }} found, exiting..." + exit 0 + {{- end }} +--- +{{- end }}{{/* if $subs.sequenceJob */}} {{- end }}{{/* range .Values.clusterGroup.subscriptions */}} diff --git a/values.schema.json b/values.schema.json index cb3a872..cfbbb89 100644 --- a/values.schema.json +++ b/values.schema.json @@ -394,6 +394,10 @@ "imperative": { "$ref": "#/definitions/Imperative" }, + "extraObjects": { + "type": "object", + "description": "Extra objects to add at the clustergroup level. Expected to be ArgoCD Resource Hooks." + }, "managedClusterGroups": { "anyOf": [ { @@ -1007,6 +1011,11 @@ }, "disabled": { "type": "boolean" + }, + "sequenceJob": { + "type": "object", + "description": "Will create an ArgoCD Resource Hook to help sequence subscription installs if needed", + "$ref": "#/definitions/SequenceJob" } }, "required": [ @@ -1030,6 +1039,38 @@ "value" ], "title": "SubscriptionsConfigEnv" + }, + "SequenceJob": { + "type": "object", + "additionalProperties": false, + "properties": { + "syncWave": { + "type": "string" + }, + "resourceType": { + "type": "string" + }, + "resourceName": { + "type": "string" + }, + "resourceNamespace": { + "type": "string" + }, + "hookType": { + "type": "string" + }, + "image": { + "type": "string" + }, + "command": { + "type": "array" + }, + "disabled": { + "type": "boolean" + } + }, + "required": [], + "title": "SequenceJob" } } } diff --git a/values.yaml b/values.yaml index af58c51..435bfb2 100644 --- a/values.yaml +++ b/values.yaml @@ -20,7 +20,7 @@ clusterGroup: # scheduler: # mastersSchedulable: true # defaultNodeSelector: type=user-node,region=east -# profile: HighNodeUtilization +# profile: HighNodeUtilization argoCD: initContainers: [] @@ -125,11 +125,42 @@ clusterGroup: # project: datacenter # path: applications/acm + extraObjects: {} +# wait-for-virt-storageclass: +# apiVersion: batch/v1 +# kind: Job +# metadata: +# name: wait-for-virt-storageclass +# annotations: +# argocd.argoproj.io/hook: Sync +# argocd.argoproj.io/sync-wave: "5" +# spec: +# parallelism: 1 +# completions: 1 +# template: +# spec: +# restartPolicy: OnFailure +# containers: +# - name: wait-for-storage-class +# image: quay.io/hybridcloudpatterns/imperative-container:v1 +# command: +# - /bin/bash +# - -c +# - | +# while [ 1 ]; +# do +# oc get sc ocs-storagecluster-ceph-rbd && break +# echo "Storage class ocs-storagecluster-ceph-rbd not found, waiting..." +# sleep 5 +# done +# echo "Storage class ocs-storagecluster-ceph-rbd found, exiting" +# exit 0 + secretStore: name: vault-backend kind: ClusterSecretStore -# Depends on the value of 'vault_hub' ansible variable used +# Depends on the value of 'vault_hub' ansible variable used # during the installation #secretsBase: # key: secret/data/hub