Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extraObjects (toplevel clustergroup element) and sequenceJob (subscription element) #20

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

mhjacks
Copy link
Contributor

@mhjacks mhjacks commented Nov 1, 2024

This PR adds the ability to add extra objects to the clustergroup-level deployment. This was originally added in order to allow for applying ArgoCD resource hooks to clustergroup-level objects, specifically subscriptions. (This feature is necessary in that case because it allows for the creation of Sync Hook jobs.) Other uses may be discovered for this feature later as well.

This feature adds a new element under clusterGroup, called extraObjects. The elements under extraObjects are objects, which are treated similarly to other top-level clustergroup objects, with the exception that the value of the dictionary is submitted "as-is" as a manifest to the API from ArgocD. Example usage:

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

This also works together with the ODF operator also being assigned to syncwave 5 and the kubevirt/OCP-Virt operator being assigned to syncwave 10.

@mhjacks
Copy link
Contributor Author

mhjacks commented Nov 6, 2024

OK after some further discussion this PR has been edited to add the narrower concept of a sequenceJob to subscriptions. The sequenceJob will create a job like the one above but mostly using boilerplate. This can be activated by adding the following structure:

    openshift-data-foundation:
        name: odf-operator
        namespace: openshift-storage
        sequenceJob:
          resourceType: sc
          resourceName: ocs-storagecluster-ceph-rbd
        annotations:
          argocd.argoproj.io/sync-wave: "5"

The job created will use the resourceType and resourceName (also a resourceNamespace if specified) and will inherit the sync-wave from the subscription object. Users can also specify a command and image if desired. If consensus is for doing it this way, I'll flesh out a sequenceJob definition in the schema

@mhjacks mhjacks closed this Nov 6, 2024
@mhjacks mhjacks deleted the add_extra_objects branch November 6, 2024 18:28
@mhjacks mhjacks reopened this Nov 6, 2024
@mhjacks mhjacks changed the title Add extra objects Add extraObjects (toplevel clustergroup element) and sequenceJob (subscription element) Nov 6, 2024
@beekhof
Copy link
Contributor

beekhof commented Nov 6, 2024

ship it! :-)

@mbaldessari mbaldessari merged commit cdcf691 into validatedpatterns:main Nov 7, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants