diff --git a/examples/starter-manual-sync/versions/0.0.1/workflowTemplate.yaml b/examples/starter-manual-sync/versions/0.0.1/workflowTemplate.yaml index 5c4bd418..833b1e93 100644 --- a/examples/starter-manual-sync/versions/0.0.1/workflowTemplate.yaml +++ b/examples/starter-manual-sync/versions/0.0.1/workflowTemplate.yaml @@ -33,7 +33,7 @@ spec: tasks: - name: sync templateRef: - name: argo-hub.argocd.0.0.1 + name: argo-hub.argocd.0.0.2 template: sync arguments: parameters: @@ -52,7 +52,7 @@ spec: value: 'token' - name: wait templateRef: - name: argo-hub.argocd.0.0.1 + name: argo-hub.argocd.0.0.2 template: wait arguments: parameters: diff --git a/workflows/argocd/versions/0.0.2/README.md b/workflows/argocd/versions/0.0.2/README.md new file mode 100644 index 00000000..5f696af1 --- /dev/null +++ b/workflows/argocd/versions/0.0.2/README.md @@ -0,0 +1,33 @@ +# ArgoCD + +## Summary + +Multiple templates that enable operations that can be used to execute against ArgoCD applications. + +## Templates + +1. [action-abort](https://github.com/codefresh-io/argo-hub/blob/main/workflows/argocd/versions/0.0.2/docs/action-abort.md) + +1. [action-promote-full](https://github.com/codefresh-io/argo-hub/blob/main/workflows/argocd/versions/0.0.2/docs/action-promote-full.md) + +1. [action-restart](https://github.com/codefresh-io/argo-hub/blob/main/workflows/argocd/versions/0.0.2/docs/action-restart.md) + +1. [action-resume](https://github.com/codefresh-io/argo-hub/blob/main/workflows/argocd/versions/0.0.2/docs/action-resume.md) + +1. [action-retry](https://github.com/codefresh-io/argo-hub/blob/main/workflows/argocd/versions/0.0.2/docs/action-retry.md) + +1. [history](https://github.com/codefresh-io/argo-hub/blob/main/workflows/argocd/versions/0.0.2/docs/history.md) + +1. [list](https://github.com/codefresh-io/argo-hub/blob/main/workflows/argocd/versions/0.0.2/docs/list.md) + +1. [rollback](https://github.com/codefresh-io/argo-hub/blob/main/workflows/argocd/versions/0.0.2/docs/rollback.md) + +1. [sync](https://github.com/codefresh-io/argo-hub/blob/main/workflows/argocd/versions/0.0.2/docs/sync.md) + +1. [wait](https://github.com/codefresh-io/argo-hub/blob/main/workflows/argocd/versions/0.0.2/docs/wait.md) + +## Security + +Minimal required permissions + +[Full rbac permissions list](https://github.com/codefresh-io/argo-hub/blob/main/workflows/argocd/versions/0.0.2/rbac.yaml) diff --git a/workflows/argocd/versions/0.0.2/docs/action-abort.md b/workflows/argocd/versions/0.0.2/docs/action-abort.md new file mode 100644 index 00000000..f544dc55 --- /dev/null +++ b/workflows/argocd/versions/0.0.2/docs/action-abort.md @@ -0,0 +1,56 @@ +# action-abort + +## Summary +Run the abort action for an application in ArgoCD. See `argocd app action run --help` with the ArgoCD CLI for flags + +## Inputs/Outputs + +### Inputs +* app (required) - The app to abort +* appKind - The kind of the application to run this action on (Default is `Rollback`) +* flags - Any abort flags to set for the ArgoCD CLI +* serverUrl (required) - The address to reach ArgoCD (if in cluster, something like `argocd-server..svc.cluster.local`) +* opts - Global options for ArgoCd (ex. `--grpc-web`) +* tokenSecret - The Kubernetes secret holding the token for communicating with ArgoCD. Default is `argocd-token` +* tokenSecretKey - The key in the Kubernetes secret with the ArgoCD token. Default is `token` +* xtraceOption - Whether to enabled xtrace (echoing the command before running it) or not (`-o` and `+o` respectively). Default is "on" (`-o`) + + +### Outputs +No outputs + +## Examples + +### task Example +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argocd-action-abort- +spec: + entrypoint: main + templates: + - name: main + dag: + tasks: + - name: action-abort + templateRef: + name: argo-hub.argocd.0.0.2 + template: action-abort + arguments: + parameters: + - name: app + value: 'demo-app' + - name: appKind + value: 'Rollback' + - name: flags + value: '--all' + - name: serverUrl + value: 'argocd-server.argocd.svc.cluster.local' + - name: opts + value: '--grpc-web' + - name: tokenSecret + value: 'my-k8s-secret' + - name: tokenSecretKey + value: 'argocd-token' +``` \ No newline at end of file diff --git a/workflows/argocd/versions/0.0.2/docs/action-promote-full.md b/workflows/argocd/versions/0.0.2/docs/action-promote-full.md new file mode 100644 index 00000000..82f97ab0 --- /dev/null +++ b/workflows/argocd/versions/0.0.2/docs/action-promote-full.md @@ -0,0 +1,56 @@ +# action-promote-full + +## Summary +Run the promote-full action for an application in ArgoCD. See `argocd app action run --help` with the ArgoCD CLI for flags + +## Inputs/Outputs + +### Inputs +* app (required) - The app to promote-full +* appKind - The kind of the application to run this action on (Default is `Rollback`) +* flags - Any promote-full flags to set for the ArgoCD CLI +* serverUrl (required) - The address to reach ArgoCD (if in cluster, something like `argocd-server..svc.cluster.local`) +* opts - Global options for ArgoCd (ex. `--grpc-web`) +* tokenSecret - The Kubernetes secret holding the token for communicating with ArgoCD. Default is `argocd-token` +* tokenSecretKey - The key in the Kubernetes secret with the ArgoCD token. Default is `token` +* xtraceOption - Whether to enabled xtrace (echoing the command before running it) or not (`-o` and `+o` respectively). Default is "on" (`-o`) + + +### Outputs +No outputs + +## Examples + +### task Example +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argocd-action-promote-full- +spec: + entrypoint: main + templates: + - name: main + dag: + tasks: + - name: action-promote-full + templateRef: + name: argo-hub.argocd.0.0.2 + template: action-promote-full + arguments: + parameters: + - name: app + value: 'demo-app' + - name: appKind + value: 'Rollback' + - name: flags + value: '--all' + - name: serverUrl + value: 'argocd-server.argocd.svc.cluster.local' + - name: opts + value: '--grpc-web' + - name: tokenSecret + value: 'my-k8s-secret' + - name: tokenSecretKey + value: 'argocd-token' +``` \ No newline at end of file diff --git a/workflows/argocd/versions/0.0.2/docs/action-restart.md b/workflows/argocd/versions/0.0.2/docs/action-restart.md new file mode 100644 index 00000000..4ae0824c --- /dev/null +++ b/workflows/argocd/versions/0.0.2/docs/action-restart.md @@ -0,0 +1,56 @@ +# action-restart + +## Summary +Run the restart action for an application in ArgoCD. See `argocd app action run --help` with the ArgoCD CLI for flags + +## Inputs/Outputs + +### Inputs +* app (required) - The app to restart +* appKind - The kind of the application to run this action on (Default is `Rollback`) +* flags - Any restart flags to set for the ArgoCD CLI +* serverUrl (required) - The address to reach ArgoCD (if in cluster, something like `argocd-server..svc.cluster.local`) +* opts - Global options for ArgoCd (ex. `--grpc-web`) +* tokenSecret - The Kubernetes secret holding the token for communicating with ArgoCD. Default is `argocd-token` +* tokenSecretKey - The key in the Kubernetes secret with the ArgoCD token. Default is `token` +* xtraceOption - Whether to enabled xtrace (echoing the command before running it) or not (`-o` and `+o` respectively). Default is "on" (`-o`) + + +### Outputs +No outputs + +## Examples + +### task Example +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argocd-action-restart- +spec: + entrypoint: main + templates: + - name: main + dag: + tasks: + - name: action-restart + templateRef: + name: argo-hub.argocd.0.0.2 + template: action-restart + arguments: + parameters: + - name: app + value: 'demo-app' + - name: appKind + value: 'Rollback' + - name: flags + value: '--all' + - name: serverUrl + value: 'argocd-server.argocd.svc.cluster.local' + - name: opts + value: '--grpc-web' + - name: tokenSecret + value: 'my-k8s-secret' + - name: tokenSecretKey + value: 'argocd-token' +``` \ No newline at end of file diff --git a/workflows/argocd/versions/0.0.2/docs/action-resume.md b/workflows/argocd/versions/0.0.2/docs/action-resume.md new file mode 100644 index 00000000..96a40ae4 --- /dev/null +++ b/workflows/argocd/versions/0.0.2/docs/action-resume.md @@ -0,0 +1,56 @@ +# action-resume + +## Summary +Run the resume action for an application in ArgoCD. See `argocd app action run --help` with the ArgoCD CLI for flags + +## Inputs/Outputs + +### Inputs +* app (required) - The app to resume +* appKind - The kind of the application to run this action on (Default is `Rollback`) +* flags - Any resume flags to set for the ArgoCD CLI +* serverUrl (required) - The address to reach ArgoCD (if in cluster, something like `argocd-server..svc.cluster.local`) +* opts - Global options for ArgoCd (ex. `--grpc-web`) +* tokenSecret - The Kubernetes secret holding the token for communicating with ArgoCD. Default is `argocd-token` +* tokenSecretKey - The key in the Kubernetes secret with the ArgoCD token. Default is `token` +* xtraceOption - Whether to enabled xtrace (echoing the command before running it) or not (`-o` and `+o` respectively). Default is "on" (`-o`) + + +### Outputs +No outputs + +## Examples + +### task Example +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argocd-action-resume- +spec: + entrypoint: main + templates: + - name: main + dag: + tasks: + - name: action-resume + templateRef: + name: argo-hub.argocd.0.0.2 + template: action-resume + arguments: + parameters: + - name: app + value: 'demo-app' + - name: appKind + value: 'Rollback' + - name: flags + value: '--all' + - name: serverUrl + value: 'argocd-server.argocd.svc.cluster.local' + - name: opts + value: '--grpc-web' + - name: tokenSecret + value: 'my-k8s-secret' + - name: tokenSecretKey + value: 'argocd-token' +``` \ No newline at end of file diff --git a/workflows/argocd/versions/0.0.2/docs/action-retry.md b/workflows/argocd/versions/0.0.2/docs/action-retry.md new file mode 100644 index 00000000..024b1efc --- /dev/null +++ b/workflows/argocd/versions/0.0.2/docs/action-retry.md @@ -0,0 +1,56 @@ +# action-retry + +## Summary +Run the retry action for an application in ArgoCD. See `argocd app action run --help` with the ArgoCD CLI for flags + +## Inputs/Outputs + +### Inputs +* app (required) - The app to retry +* appKind - The kind of the application to run this action on (Default is `Rollback`) +* flags - Any retry flags to set for the ArgoCD CLI +* serverUrl (required) - The address to reach ArgoCD (if in cluster, something like `argocd-server..svc.cluster.local`) +* opts - Global options for ArgoCd (ex. `--grpc-web`) +* tokenSecret - The Kubernetes secret holding the token for communicating with ArgoCD. Default is `argocd-token` +* tokenSecretKey - The key in the Kubernetes secret with the ArgoCD token. Default is `token` +* xtraceOption - Whether to enabled xtrace (echoing the command before running it) or not (`-o` and `+o` respectively). Default is "on" (`-o`) + + +### Outputs +No outputs + +## Examples + +### task Example +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argocd-action-retry- +spec: + entrypoint: main + templates: + - name: main + dag: + tasks: + - name: action-retry + templateRef: + name: argo-hub.argocd.0.0.2 + template: action-retry + arguments: + parameters: + - name: app + value: 'demo-app' + - name: appKind + value: 'Rollback' + - name: flags + value: '--all' + - name: serverUrl + value: 'argocd-server.argocd.svc.cluster.local' + - name: opts + value: '--grpc-web' + - name: tokenSecret + value: 'my-k8s-secret' + - name: tokenSecretKey + value: 'argocd-token' +``` \ No newline at end of file diff --git a/workflows/argocd/versions/0.0.2/docs/history.md b/workflows/argocd/versions/0.0.2/docs/history.md new file mode 100644 index 00000000..3bf2a456 --- /dev/null +++ b/workflows/argocd/versions/0.0.2/docs/history.md @@ -0,0 +1,57 @@ +# history + +## Summary +Get an applications history in ArgoCD and store the output as a workflow output. See `argocd app history --help` with the ArgoCD CLI for flags + +## Inputs/Outputs + +### Inputs +* app - The app to get history from +* flags - Any history flags to set for the ArgoCD CLI (i.e. output format) +* serverUrl (required) - The address to reach ArgoCD (if in cluster, something like `argocd-server..svc.cluster.local`) +* opts - Global options for ArgoCd (ex. `--grpc-web`) +* historyId (required) - The ID to roll back to +* tokenSecret - The Kubernetes secret holding the token for communicating with ArgoCD. Default is `argocd-token` +* tokenSecretKey - The key in the Kubernetes secret with the ArgoCD token. Default is `token` +* xtraceOption - Whether to enabled xtrace (echoing the command before running it) or not (`-o` and `+o` respectively). Default is "on" (`-o`) + + + +### Outputs +* history - A file with the results of the `argocd app history` command run + +## Examples + +### task Example +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argocd-history- +spec: + entrypoint: main + templates: + - name: main + dag: + tasks: + - name: history + templateRef: + name: argo-hub.argocd.0.0.2 + template: history + arguments: + parameters: + - name: app + value: 'demo-app' + - name: flags + value: '--output id' + - name: serverUrl + value: 'argocd-server.argocd.svc.cluster.local' + - name: opts + value: '--grpc-web' + - name: historyId + value: 1 + - name: tokenSecret + value: 'my-k8s-secret' + - name: tokenSecretKey + value: 'argocd-token' +``` \ No newline at end of file diff --git a/workflows/argocd/versions/0.0.2/docs/list.md b/workflows/argocd/versions/0.0.2/docs/list.md new file mode 100644 index 00000000..471e6f95 --- /dev/null +++ b/workflows/argocd/versions/0.0.2/docs/list.md @@ -0,0 +1,56 @@ +# list + +## Summary +List applications in ArgoCD and store the output as a workflow output. See `argocd app list --help` with the ArgoCD CLI for flags + +## Inputs/Outputs + +### Inputs +* flags - Any list flags to set for the ArgoCD CLI +* serverUrl (required) - The address to reach ArgoCD (if in cluster, something like `argocd-server..svc.cluster.local`) +* opts - Global options for ArgoCd (ex. `--grpc-web`) +* listId (required) - The ID to roll back to +* tokenSecret - The Kubernetes secret holding the token for communicating with ArgoCD. Default is `argocd-token` +* tokenSecretKey - The key in the Kubernetes secret with the ArgoCD token. Default is `token` +* xtraceOption - Whether to enabled xtrace (echoing the command before running it) or not (`-o` and `+o` respectively). Default is "on" (`-o`) + + + +### Outputs +* apps - A file with the results of the `argocd app list` command run + +## Examples + +### task Example +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argocd-list- +spec: + entrypoint: main + templates: + - name: main + dag: + tasks: + - name: list + templateRef: + name: argo-hub.argocd.0.0.2 + template: list + arguments: + parameters: + - name: app + value: 'demo-app' + - name: flags + value: '--output name' + - name: serverUrl + value: 'argocd-server.argocd.svc.cluster.local' + - name: opts + value: '--grpc-web' + - name: listId + value: 1 + - name: tokenSecret + value: 'my-k8s-secret' + - name: tokenSecretKey + value: 'argocd-token' +``` \ No newline at end of file diff --git a/workflows/argocd/versions/0.0.2/docs/rollback.md b/workflows/argocd/versions/0.0.2/docs/rollback.md new file mode 100644 index 00000000..fe884e1f --- /dev/null +++ b/workflows/argocd/versions/0.0.2/docs/rollback.md @@ -0,0 +1,57 @@ +# rollback + +## Summary +Rollback an application in ArgoCD. See `argocd app rollback --help` with the ArgoCD CLI for flags + +## Inputs/Outputs + +### Inputs +* app - The app to rollback +* flags - Any rollback flags to set for the ArgoCD CLI +* serverUrl (required) - The address to reach ArgoCD (if in cluster, something like `argocd-server..svc.cluster.local`) +* opts - Global options for ArgoCd (ex. `--grpc-web`) +* rollbackId (required) - The ID to roll back to +* tokenSecret - The Kubernetes secret holding the token for communicating with ArgoCD. Default is `argocd-token` +* tokenSecretKey - The key in the Kubernetes secret with the ArgoCD token. Default is `token` +* xtraceOption - Whether to enabled xtrace (echoing the command before running it) or not (`-o` and `+o` respectively). Default is "on" (`-o`) + + + +### Outputs +No outputs + +## Examples + +### task Example +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argocd-rollback- +spec: + entrypoint: main + templates: + - name: main + dag: + tasks: + - name: rollback + templateRef: + name: argo-hub.argocd.0.0.2 + template: rollback + arguments: + parameters: + - name: app + value: 'demo-app' + - name: flags + value: '--prune --timeout 30' + - name: serverUrl + value: 'argocd-server.argocd.svc.cluster.local' + - name: opts + value: '--grpc-web' + - name: rollbackId + value: 1 + - name: tokenSecret + value: 'my-k8s-secret' + - name: tokenSecretKey + value: 'argocd-token' +``` \ No newline at end of file diff --git a/workflows/argocd/versions/0.0.2/docs/sync.md b/workflows/argocd/versions/0.0.2/docs/sync.md new file mode 100644 index 00000000..8a140fb7 --- /dev/null +++ b/workflows/argocd/versions/0.0.2/docs/sync.md @@ -0,0 +1,108 @@ +# sync + +## Summary +Sync an application in ArgoCD. See `argocd app sync --help` with the ArgoCD CLI for flags + +## Inputs/Outputs + +### Inputs +* app - The app to sync (if syncing by label, use flags) +* flags - Any sync flags to set for the ArgoCD CLI +* serverUrl (required) - The address to reach ArgoCD (if in cluster, something like `argocd-server..svc.cluster.local`) +* opts - Global options for ArgoCd (ex. `--grpc-web`) +* tokenSecret - The Kubernetes secret holding the token for communicating with ArgoCD. Default is `argocd-token` +* tokenSecretKey - The key in the Kubernetes secret with the ArgoCD token. Default is `token` +* xtraceOption - Whether to enabled xtrace (echoing the command before running it) or not (`-o` and `+o` respectively). Default is "on" (`-o`) + + +### Outputs +No outputs + +## Examples + +### task Example +Minimal: +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argocd-sync- +spec: + entrypoint: main + templates: + - name: main + dag: + tasks: + - name: sync + templateRef: + name: argo-hub.argocd.0.0.2 + template: sync + arguments: + parameters: + - name: app + value: 'demo-app' + - name: serverUrl + value: 'argocd-server.argocd.svc.cluster.local' +``` + +With additional options +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argocd-sync- +spec: + entrypoint: main + templates: + - name: main + dag: + tasks: + - name: sync + templateRef: + name: argo-hub.argocd.0.0.2 + template: sync + arguments: + parameters: + - name: app + value: 'demo-app' + - name: flags + value: '--prune --timeout 30' + - name: serverUrl + value: 'argocd-server.argocd.svc.cluster.local' + - name: opts + value: '--grpc-web' + - name: tokenSecret + value: 'my-k8s-secret' + - name: tokenSecretKey + value: 'argocd-token' +``` + +Syncing via label instead of app name +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argocd-sync- +spec: + entrypoint: main + templates: + - name: main + dag: + tasks: + - name: sync + templateRef: + name: argo-hub.argocd.0.0.2 + template: sync + arguments: + parameters: + - name: flags + value: '-l app.kubernetes.io/instance=my-app' + - name: serverUrl + value: 'argocd-server.argocd.svc.cluster.local' + - name: opts + value: '--grpc-web' + - name: tokenSecret + value: 'my-k8s-secret' + - name: tokenSecretKey + value: 'argocd-token' +``` \ No newline at end of file diff --git a/workflows/argocd/versions/0.0.2/docs/wait.md b/workflows/argocd/versions/0.0.2/docs/wait.md new file mode 100644 index 00000000..e7f1e563 --- /dev/null +++ b/workflows/argocd/versions/0.0.2/docs/wait.md @@ -0,0 +1,53 @@ +# wait + +## Summary +Wait for an application in ArgoCD. See `argocd app wait --help` with the ArgoCD CLI for flags + +## Inputs/Outputs + +### Inputs +* app - The app to wait for (if waiting by label, use flags) +* flags - Any wait flags to set for the ArgoCD CLI +* serverUrl (required) - The address to reach ArgoCD (if in cluster, something like `argocd-server..svc.cluster.local`) +* opts - Global options for ArgoCd (ex. `--grpc-web`) +* tokenSecret - The Kubernetes secret holding the token for communicating with ArgoCD. Default is `argocd-token` +* tokenSecretKey - The key in the Kubernetes secret with the ArgoCD token. Default is `token` +* xtraceOption - Whether to enabled xtrace (echoing the command before running it) or not (`-o` and `+o` respectively). Default is "on" (`-o`) + + +### Outputs +No outputs + +## Examples + +### task Example +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: argocd-wait- +spec: + entrypoint: main + templates: + - name: main + dag: + tasks: + - name: wait + templateRef: + name: argo-hub.argocd.0.0.2 + template: wait + arguments: + parameters: + - name: app + value: 'demo-app' + - name: flags + value: '--health' + - name: serverUrl + value: 'argocd-server.argocd.svc.cluster.local' + - name: opts + value: '--grpc-web' + - name: tokenSecret + value: 'my-k8s-secret' + - name: tokenSecretKey + value: 'argocd-token' +``` \ No newline at end of file diff --git a/workflows/argocd/versions/0.0.2/images/argocd-cli/Dockerfile b/workflows/argocd/versions/0.0.2/images/argocd-cli/Dockerfile new file mode 100644 index 00000000..c6f95717 --- /dev/null +++ b/workflows/argocd/versions/0.0.2/images/argocd-cli/Dockerfile @@ -0,0 +1,6 @@ +FROM alpine:3.22.0 + +ARG ARGOCD_CLI_VERSION=v3.0.6 + +RUN wget -O /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/download/$ARGOCD_CLI_VERSION/argocd-linux-amd64 \ + && chmod +x /usr/local/bin/argocd diff --git a/workflows/argocd/versions/0.0.2/rbac.yaml b/workflows/argocd/versions/0.0.2/rbac.yaml new file mode 100644 index 00000000..ec20f3f4 --- /dev/null +++ b/workflows/argocd/versions/0.0.2/rbac.yaml @@ -0,0 +1,49 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: argo-hub.argocd.0.0.2 + annotations: + argo-hub/version: '0.0.2' +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: argo-hub.argocd.0.0.2 + annotations: + argo-hub/version: '0.0.2' +rules: + - apiGroups: + - "" + resources: + - pods + verbs: + - get + - watch + - patch + - apiGroups: + - "" + resources: + - pods/log + verbs: + - get + - watch + - apiGroups: + - "" + resources: + - secrets + verbs: + - get +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: argo-hub.argocd.0.0.2 + annotations: + argo-hub/version: '0.0.2' +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: argo-hub.argocd.0.0.2 +subjects: + - kind: ServiceAccount + name: argo-hub.argocd.0.0.2 diff --git a/workflows/argocd/versions/0.0.2/workflowTemplate.yaml b/workflows/argocd/versions/0.0.2/workflowTemplate.yaml new file mode 100644 index 00000000..42d684ed --- /dev/null +++ b/workflows/argocd/versions/0.0.2/workflowTemplate.yaml @@ -0,0 +1,261 @@ +apiVersion: argoproj.io/v1alpha1 +kind: WorkflowTemplate +metadata: + name: argo-hub.argocd.0.0.2 + annotations: + argo-hub/version: '0.0.2' + argo-hub/description: 'Templates that execute operations against an ArgoCD application' + argo-hub/license: 'MIT' + argo-hub/owner_name: 'Jesse Antoszyk' + argo-hub/owner_email: 'Jesse.Antoszyk@codefresh.io' + argo-hub/owner_avatar: 'https://avatars.githubusercontent.com/u/22500761?v=4' + argo-hub/owner_url: 'https://github.com/jcantosz' + argo-hub/categories: 'argocd,deploy' + argo-hub/icon_url: "https://cdn.jsdelivr.net/gh/codefresh-io/argo-hub@main/workflows/argocd/assets/icon.svg" + argo-hub/icon_background: "#f4f4f4" + +spec: + # default arguments + arguments: + parameters: + # The app to run the argo command against + - name: app + value: "" + # Flags specific to the command you are running (i.e. -l "my-label") + - name: flags + value: "" + # The url for communicating with the ArgoCD server + # i.e. argocd-server..svc.cluster.local + - name: serverUrl + value: "" + # Global command line options to pass to the ArgoCD CLI + - name: opts + value: "" + # The Kubernetes secret with the token to communicate with ArgoCD + - name: tokenSecret + value: "argocd-token" + # The key name in the Kubernetes secret with the token to communicate with ArgoCD + - name: tokenSecretKey + value: "token" + # The Kubernetes 'Kind' to use with argo app actions command + - name: appKind + value: "Rollout" + # The ID to roll back to if performing a rollback + - name: rollbackId + value: "" + # Set xtrace or not (echo the command before running it). Valid options are -o (xtrace on) and +o (xtrace off). default is -o + - name: xtraceOption + value: '-o' + + templates: + # ArgoCD app sync + # Cannot just anchor the whole list item because overrides will not function properlc + - name: sync + serviceAccountName: &serviceAccountName argo-hub.argocd.0.0.2 + metadata: + annotations: &annotations + argo-hub-template/description: 'Sync an application in ArgoCD' + argo-hub-template/icon_url: "https://cdn.jsdelivr.net/gh/codefresh-io/argo-hub@main/workflows/argocd/assets/icon.svg" + argo-hub-template/icon_background: "#f4f4f4" + # Container info + container: &container + # Image, command and arguments to use + image: quay.io/codefreshplugins/argo-hub-workflows-argocd-versions-0.0.2-images-argocd-cli:main + # xtrace + command: ['sh', '{{inputs.parameters.xtraceOption}}', 'xtrace', '-c'] + args: + - 'argocd app sync {{inputs.parameters.app}} {{inputs.parameters.flags}}' + env: + # URL to communicate with ArgoCD + - name: ARGOCD_SERVER + value: '{{inputs.parameters.serverUrl}}' + # Token to use to communicate with ArgoCD + - name: ARGOCD_AUTH_TOKEN + valueFrom: + secretKeyRef: + name: '{{inputs.parameters.tokenSecret}}' + key: '{{inputs.parameters.tokenSecretKey}}' + # CLI falgs to use + - name: ARGOCD_OPTS + value: '{{inputs.parameters.opts}}' + # Parameters users can set/override + inputs: &inputs + parameters: + # The app to run the argo command against + - name: app + default: "" + # Flags specific to the command you are running (i.e. -l "my-label") + - name: flags + default: "" + # The url for communicating with the ArgoCD server + # i.e. argocd-server..svc.cluster.local + - name: serverUrl + # Global command line options to pass to the ArgoCD CLI + - name: opts + default: "" + # The Kubernetes secret with the token to communicate with ArgoCD + - name: tokenSecret + default: "argocd-token" + # The key name in the Kubernetes secret with the token to communicate with ArgoCD + - name: tokenSecretKey + default: "token" + # The Kubernetes 'Kind' to use with argo app actions command + - name: appKind + default: "Rollout" + # The ID to roll back to if performing a rollback + - name: rollbackId + default: "" + # Set xtrace or not (echo the command before running it). Valid options are -o (xtrace on) and +o (xtrace off). default is -o + - name: xtraceOption + default: "-o" + + # Wait for an app status + - name: wait + serviceAccountName: *serviceAccountName + metadata: + annotations: + argo-hub-template/description: 'Wait for an application to get into a desired state in ArgoCD' + <<: *annotations + container: + <<: *container + args: + - 'argocd app wait {{inputs.parameters.app}} {{inputs.parameters.flags}}' + inputs: + <<: *inputs + + - name: rollback + serviceAccountName: *serviceAccountName + metadata: + annotations: + argo-hub-template/description: 'Rollback an application to a given ID in ArgoCD' + <<: *annotations + container: + <<: *container + args: + - 'argocd app rollback {{inputs.parameters.app}} {{inputs.parameters.rollbackId}} {{inputs.parameters.flags}}' + inputs: + <<: *inputs + + # Actions + # ============================================================================================================================== + # https://argoproj.github.io/argo-rollouts/FAQ/#can-we-run-the-argo-rollouts-kubectl-plugin-commands-via-argo-cd + # https://argoproj.github.io/argo-rollouts/features/restart/ + # + # Actions available to rollout: + # $ argocd app actions list demo + # argoproj.io Rollout simple-rollout abort true + # argoproj.io Rollout simple-rollout promote-full true + # argoproj.io Rollout simple-rollout restart false + # argoproj.io Rollout simple-rollout resume true + # argoproj.io Rollout simple-rollout retry true + + # Abort a rollout + - name: action-abort + serviceAccountName: *serviceAccountName + metadata: + annotations: + argo-hub-template/description: 'Run the abort action against an application (rollout) in ArgoCD' + <<: *annotations + container: + <<: *container + args: + - 'argocd app actions run {{inputs.parameters.app}} abort --kind {{inputs.parameters.appKind}} {{inputs.parameters.flags}}' + inputs: + <<: *inputs + + # Promote-full a rollout + - name: action-promote-full + serviceAccountName: *serviceAccountName + metadata: + annotations: + argo-hub-template/description: 'Run the promote-full action against an application (rollout) in ArgoCD' + <<: *annotations + container: + <<: *container + args: + - 'argocd app actions run {{inputs.parameters.app}} promote-full --kind {{inputs.parameters.appKind}} {{inputs.parameters.flags}}' + inputs: + <<: *inputs + + # Restart a rollout + - name: action-restart + serviceAccountName: *serviceAccountName + metadata: + annotations: + argo-hub-template/description: 'Run the restart action against an application in ArgoCD' + <<: *annotations + container: + <<: *container + args: + - 'argocd app actions run {{inputs.parameters.app}} restart --kind {{inputs.parameters.appKind}} {{inputs.parameters.flags}}' + inputs: + <<: *inputs + + # Resume a rollout + - name: action-resume + serviceAccountName: *serviceAccountName + metadata: + annotations: + argo-hub-template/description: 'Run the resume action against an application (rollout) in ArgoCD' + <<: *annotations + container: + <<: *container + args: + - 'argocd app actions run {{inputs.parameters.app}} resume --kind {{inputs.parameters.appKind}} {{inputs.parameters.flags}}' + inputs: + <<: *inputs + + # Retry a rollout + - name: action-retry + serviceAccountName: *serviceAccountName + metadata: + annotations: + argo-hub-template/description: 'Run the retry action against an application (rollout) in ArgoCD' + <<: *annotations + container: + <<: *container + args: + - 'argocd app actions run {{inputs.parameters.app}} retry --kind {{inputs.parameters.appKind}} {{inputs.parameters.flags}}' + inputs: + <<: *inputs + + # List applications + - name: list + serviceAccountName: *serviceAccountName + metadata: + annotations: + argo-hub-template/description: 'List applications in ArgoCD' + <<: *annotations + container: + <<: *container + args: + - 'argocd app list {{inputs.parameters.flags}} | tee /tmp/app.list' + inputs: + <<: *inputs + outputs: + parameters: + - name: apps + valueFrom: + path: /tmp/app.list + # ============================================================================================================================== + + # Get application history + - name: history + serviceAccountName: *serviceAccountName + metadata: + annotations: + argo-hub-template/description: "Show an application's history in ArgoCD" + <<: *annotations + container: + <<: *container + args: + - 'argocd app history {{inputs.parameters.app}} {{inputs.parameters.flags}} | tee /tmp/app.history' + inputs: + <<: *inputs + outputs: + parameters: + - name: history + valueFrom: + path: /tmp/app.history + +