Argo-cd: Document best practices for preview apps

Created on 24 Jun 2019  路  5Comments  路  Source: argoproj/argo-cd

Enough users want to create preview apps that we should document this.

A preview app is a version of an app that has things tweaked, and are typically ephemeral. For example:

  • Ingress hostname change to include PR number.
  • Replicas (fewer).
  • Service name, so that the deployment routes to the correct ingress.
  • Prefix the namespace (e.g with PR number).

Approaches currently in play:

  1. Create a branch of the repository and patch the files (onerous, requires write permissions)
  2. Use commands such as app patch and app patch-resource.

We should document current approaches.

See also #1157, #1481.

enhancement

Most helpful comment

Current approach (using argocd commands) is a good approach. But I would like to have a more declarative approach. Such as Using Application CRD as Application Template.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: branch-apps
  annotations:
     argoproj.io/argocd/branches/*: Disallow  // disallow to make apps 
     argoproj.io/argocd/branches/test: SyncPolicy=auto // default sync policy is manual?
     argoproj.io/argocd/branches/staging: SyncPolicy=manual
spec:
  source:
    repoURL: https://github.com/argoproj/argocd-example-apps.git
    targetRevision: ${branch}
    path: guestbook
  destination:
    server: https://kubernetes.default.svc
    namespace: guestbook-${branch}
opertation:
   patches:
      - '[{"op": "replace", "path": "/spec/destination/namespace", "value": "gurstbook-${branch}"}]' 

This Application CRD makes other Application CRD with branches. This branch-apps makes applications with current branches. If a branch is deleted, this application deletes a app related to the branch when this application is syncing. But I'm not sure this approach is more declarative or better than working with CI pipelines. Just small idea.^^;

All 5 comments

Current approach (using argocd commands) is a good approach. But I would like to have a more declarative approach. Such as Using Application CRD as Application Template.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: branch-apps
  annotations:
     argoproj.io/argocd/branches/*: Disallow  // disallow to make apps 
     argoproj.io/argocd/branches/test: SyncPolicy=auto // default sync policy is manual?
     argoproj.io/argocd/branches/staging: SyncPolicy=manual
spec:
  source:
    repoURL: https://github.com/argoproj/argocd-example-apps.git
    targetRevision: ${branch}
    path: guestbook
  destination:
    server: https://kubernetes.default.svc
    namespace: guestbook-${branch}
opertation:
   patches:
      - '[{"op": "replace", "path": "/spec/destination/namespace", "value": "gurstbook-${branch}"}]' 

This Application CRD makes other Application CRD with branches. This branch-apps makes applications with current branches. If a branch is deleted, this application deletes a app related to the branch when this application is syncing. But I'm not sure this approach is more declarative or better than working with CI pipelines. Just small idea.^^;

This is much needed. I've been reading and testing out argocd for a few days now. If I give write access to config repo to CI, then it's more of the same like CIOps.

Still can't figure out a nice way to have this.

Hi @alexec, why did you close this? Supporting this feature _without_ relying on CI to do the heavy lifting of templating the preview apps seems like an important feature in support of the GitOps ideal. Is there other ongoing work related to this?

Hi @jshearer

We've decided to eschew this feature.

What we've found is that preview copies of an app are not a straight-forward deployment of the same Git repo into different clusters (see https://github.com/argoproj/argo-cd/issues/1673). Each app needs different configuration, e.g. ALB, ingress, limits, etc etc etc, and therefore customers tend to create version of the app customised onto their specific requirements.

We actually went as far as create a PoC for this before making a decision on this.

What we've not done, and ought to, is document how people currently do preview apps.

Have you asked in the Slack channel please?

Alex

The documentation about "how to do preview apps with argo" would be really very much appreciated. Thanks!

Was this page helpful?
0 / 5 - 0 ratings