Skip to content

Commit

Permalink
Add extraObjects and sequenceJob for Subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Jackson committed Nov 7, 2024
1 parent 5e7c364 commit b4f29b5
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 2 deletions.
7 changes: 7 additions & 0 deletions templates/core/extraObjects.yaml
Original file line number Diff line number Diff line change
@@ -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 */}}
36 changes: 36 additions & 0 deletions templates/core/subscriptions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 */}}
41 changes: 41 additions & 0 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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": [
Expand All @@ -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"
}
}
}
35 changes: 33 additions & 2 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ clusterGroup:
# scheduler:
# mastersSchedulable: true
# defaultNodeSelector: type=user-node,region=east
# profile: HighNodeUtilization
# profile: HighNodeUtilization

argoCD:
initContainers: []
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b4f29b5

Please sign in to comment.