Skip to content

Instantly share code, notes, and snippets.

@mumoshu
Last active February 25, 2020 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mumoshu/3078a9fcec03df90c2c0a7ef80debc10 to your computer and use it in GitHub Desktop.
Save mumoshu/3078a9fcec03df90c2c0a7ef80debc10 to your computer and use it in GitHub Desktop.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: apps
namespace: kube-system
spec:
project: default
source:
repoURL: https://github.com/mumoshu/configrepo.git
targetRevision: HEAD
path: argocd
destination:
server: https://kubernetes.default.svc
namespace: kube-system
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: guestbook
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/mumoshu/configrepo.git
targetRevision: {{.commit}}
path: apps/guestbook
destination:
server: https://kubernetes.default.svc
namespace: guestbook
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: api
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/mumoshu/configrepo.git
targetRevision: {{.commit}}
path: apps/api
destination:
server: https://kubernetes.default.svc
namespace: api
module "myapp" {
  dependency "exec" "helmfile" {
    command = "go"
    args = ["run", "main.go"]
    version = "> 0.94.0"
  }
  
  dependency "timestamp_git" "configrepo" {
    # dep.configrepo.version looks like "20200225.1230.40-<commit id>"
    # and it is updated only when the directory `./apps` is updated after "2020.2.25 12:30:40 UTC"
    source = "github.com/mumoshu/configrepo/master/apps"
  }
  
  dependency "dockerimage" "guestbook" {
    source = "mumoshu/guestbook"
  }
  
  dependency "dockerimage" "api" {
    source = "mumoshu/api"
  }

  file "argocd/apps.yaml" {
    source = "apps.yaml.tpl"
    args = {
      commit = split(dep.configrepo.version, "-")[1]
    }
  }
  
  directory "helmfiles/guestbook" {
    source = "./helmfile-base"
    
    # some additional files and helmfile snippets...
  }

  directory "apps/guestbook" {
    source = "./helmfiles/guestbook"
    
    exec {
      command = "bash"
      args = list("-c", "helmfile -f ${source} template --state-values-set image.tag=${dep.guestbook.version} > ${dir}/all.yaml")
    }
  }
  
  directory "helmfiles/api" {
    source = "./helmfile-base"
    
    # some additional files and helmfile snippets...
  }

  directory "apps/api" {
    source = "./helmfiles/api"
    
    exec {
      command = "bash"
      args = list("-c", "helmfile -f ${source} template --state-values-set image.tag=${dep.api.version} > ${dir}/all.yaml")
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment