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

[Feature] Ability to set annotations for checker job #20

Closed
aceat64 opened this issue Sep 27, 2023 · 2 comments · Fixed by #37
Closed

[Feature] Ability to set annotations for checker job #20

aceat64 opened this issue Sep 27, 2023 · 2 comments · Fixed by #37
Labels
enhancement New feature or request

Comments

@aceat64
Copy link
Contributor

aceat64 commented Sep 27, 2023

Currently it does not seem possible to set annotations on just the checker job. I need this in order to add some annotations used by ArgoCD.

Without being able to set these annotations, ArgoCD views the job as "missing" once the has completed and the ttlSecondsAfterFinished has expired. It then re-creates the job, resulting in new jobs being run every few minutes.

@gruberdev
Copy link

gruberdev commented Sep 28, 2023

You can use helmCharts with Kustomize in order to do that, while that is not added to the main branch:

  • Removes ttlSecondsAfterFinished from the job resource
  • Adds selective hooks to ensure it will only run once per sync and only after all the remaining application resources report as healthy to ArgoCD
  • It uses Helm resources coupled with Kustomize overlaying to patch resources. This might be incompatible with cmp sidecar plugins, if you use any.
  • It assumes you are using the argocd namespace for ArgoCD and milvus-operator for the operator resources.

app/base/kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
helmCharts:
- name: milvus-operator
  includeCRDs: true
  valuesInline:
    image:
      repository: milvusdb/milvus-operator
      pullPolicy: IfNotPresent
      tag: "v0.8.1"
    # {...}
    # The rest of your values here
  releaseName: milvus-operator
  version: 0.8.1
  repo: https://zilliztech.github.io/milvus-operator/

app/kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./base

patchesJson6902:
  - target:
      group: batch
      version: v1
      kind: Job
      name: milvus-operator-checker
    patch: |-
      - op: add
        path: /metadata/annotations/argocd.argoproj.io~1hook
        value: PostSync
      - op: add
        path: /metadata/annotations/argocd.argoproj.io~1hook-delete-policy
        value: BeforeHookCreation
      - op: remove
        path: /spec/ttlSecondsAfterFinished

app.yaml

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: milvus-operator
  namespace: argocd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  source:
    repoURL: 'https://github.com/{your git}'
    path: {your base kustomize.yaml path}
    targetRevision: main
  destination:
    namespace: milvus-operator
    name: in-cluster
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
      allowEmpty: false
    syncOptions:
    - Validate=false
    - CreateNamespace=true
    - PrunePropagationPolicy=foreground
    - Prune=true
    - ServerSideApply=true
  retry:
    limit: 5
    backoff:
      duration: 20s
      factor: 2
      maxDuration: 15m

I did a similar setup here and here.

How it'd look like at the end:

app/
├── base/
│   └── kustomization.yaml  # Helm chart settings
├── kustomization.yaml     # Merges all the things
└── app.yaml               # ArgoCD app specs

Just make sure you've enabled Helm support in ArgoCD by setting --enable-helm to true. This ensures that ArgoCD understands the Helm-related directives in your Kustomization.

@haorenfsa
Copy link
Collaborator

Or we can add a value in helm chart, would you like to make a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants