Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,23 @@ k8s-gitops/

deployments/
levelbuilder/ # codeai deployment levelbuilder
deployment.yaml # envType=levelbuilder, branch=levelbuilder
values.yaml # values.yaml for this deployment: dashboard_workers=27, RAILS_ENV=levelbuilder, etc
deployment.yaml # envType=levelbuilder, branch=stage/levelbuilder
...

envTypes/
levelbuilder.values.yaml # base values.yaml for all envType=levelbuilder
levelbuilder/ # envType Kustomize Component for levelbuilder
...

kargo/
templates/
deploy/
kustomization.yaml # temp wrapper copied into Kargo work dirs before render

warehouses/
codeai/
freight/ # frozen source snapshots published from code-dot-org staging
legacy-gitflow/ # legacy branch merge metadata used as downstream Kargo gates

kargo/
application.yaml # argocd app for kargo itself
values.yaml # helm values for kargo install
Expand All @@ -53,4 +62,3 @@ k8s-gitops/
## Bootstrap Cluster

kubectl apply -f apps/app-of-apps/applicationset.yaml

16 changes: 4 additions & 12 deletions apps/codeai/applicationset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,10 @@ spec:
kargo.akuity.io/project: kargo-project-codeai
spec:
project: default
sources:
- repoURL: https://github.com/code-dot-org/code-dot-org.git
targetRevision: '{{sourceRevision}}'
path: k8s/helm
helm:
releaseName: '{{path.basename}}'
valueFiles:
- $values/apps/codeai/envTypes/{{envType}}.values.yaml
- $values/apps/codeai/deployments/{{path.basename}}/values.yaml
- repoURL: https://github.com/code-dot-org/k8s-gitops.git
targetRevision: main
ref: values
source:
repoURL: https://github.com/code-dot-org/k8s-gitops.git
targetRevision: '{{branch}}'
path: apps/codeai/deployments/{{path.basename}}/deploy
destination:
server: https://kubernetes.default.svc
namespace: '{{namespace}}'
Expand Down
3 changes: 3 additions & 0 deletions apps/codeai/deployments/levelbuilder/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
envType: levelbuilder
namespace: levelbuilder
branch: stage/levelbuilder
3 changes: 3 additions & 0 deletions apps/codeai/deployments/production/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
envType: production
namespace: production
branch: stage/production
2 changes: 1 addition & 1 deletion apps/codeai/deployments/staging/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
envType: staging
namespace: staging
branch: staging
branch: stage/staging
4 changes: 1 addition & 3 deletions apps/codeai/deployments/test/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
envType: test
namespace: test
# FIXME: for quicker testing, avoid waiting on DTTs and DTPs, let alone DTLs.
# branch: test
branch: staging
branch: stage/test
8 changes: 8 additions & 0 deletions apps/codeai/kargo/templates/deploy/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources: []
components: []
images:
- name: code-dot-org
newName: code-dot-org
newTag: latest
6 changes: 4 additions & 2 deletions apps/kargo-project-codeai/project-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ spec:
autoPromotionEnabled: true
- stage: test
autoPromotionEnabled: false
- stage: production
autoPromotionEnabled: false
- stage: levelbuilder
autoPromotionEnabled: false
- stage: review-infra-changes
autoPromotionEnabled: false
- stage: production
autoPromotionEnabled: false
99 changes: 87 additions & 12 deletions apps/kargo-project-codeai/stages/levelbuilder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,108 @@ spec:
requestedFreight:
- origin:
kind: Warehouse
name: kargo-project-codeai
name: codeai-freight
sources:
stages:
- test
vars:
- name: gitopsRepo
value: https://github.com/code-dot-org/k8s-gitops.git
- name: targetBranch
value: stage/levelbuilder
- name: renderDeployment
value: levelbuilder
- name: renderPath
value: apps/codeai/deployments/levelbuilder/deploy
- name: imageRepo
value: ghcr.io/code-dot-org/code-dot-org
- name: legacyEnv
value: levelbuilder
promotionTemplate:
spec:
vars:
- name: gitopsRepo
value: https://github.com/code-dot-org/k8s-gitops.git
steps:
- uses: git-clone
config:
repoURL: ${{ vars.gitopsRepo }}
checkout:
- commit: ${{ commitFrom(vars.gitopsRepo, warehouse('codeai-freight')).ID }}
path: ./freight
- branch: main
path: ./gitops
path: ./meta
- branch: ${{ vars.targetBranch }}
create: true
path: ./out
- uses: yaml-parse
as: freight
config:
path: ./freight/warehouses/codeai/freight/current/freight.yaml
outputs:
- name: releaseId
fromExpression: tag
- uses: yaml-parse
as: legacy-merge
config:
path: ./meta/warehouses/codeai/legacy-gitflow/${{ vars.legacyEnv }}/merged/${{ outputs.freight.releaseId }}.yaml
outputs:
- name: mergedAt
fromExpression: mergedAt
- uses: yaml-parse
as: deployment-meta
config:
path: ./meta/apps/codeai/deployments/${{ vars.renderDeployment }}/deployment.yaml
outputs:
- name: envType
fromExpression: envType
- name: namespace
fromExpression: namespace
- uses: git-clear
config:
path: ./out
- uses: copy
config:
inPath: ./freight/warehouses/codeai/freight/current/kustomize
outPath: ./work/source
- uses: copy
config:
inPath: ./meta/apps/codeai/envTypes/${{ outputs['deployment-meta'].envType }}
outPath: ./work/envTypes/${{ outputs['deployment-meta'].envType }}
- uses: copy
config:
inPath: ./meta/apps/codeai/envTypes/components
outPath: ./work/envTypes/components
- uses: copy
config:
inPath: ./meta/apps/codeai/kargo/templates/deploy
outPath: ./work/deploy
- uses: yaml-update
config:
path: ./gitops/apps/codeai/deployments/levelbuilder/values.yaml
path: ./work/deploy/kustomization.yaml
updates:
- key: image
value: ghcr.io/code-dot-org/code-dot-org:${{ imageFrom("ghcr.io/code-dot-org/code-dot-org").Tag }}
- key: namespace
value: ${{ outputs['deployment-meta'].namespace }}
- key: resources
value:
- ../source/base
- key: components
value:
- ../envTypes/${{ outputs['deployment-meta'].envType }}
- uses: kustomize-set-image
config:
path: ./work/deploy
images:
- image: code-dot-org
newName: ${{ vars.imageRepo }}
tag: ${{ outputs.freight.releaseId }}
- uses: kustomize-build
config:
path: ./work/deploy
outputFormat: kustomize
outPath: ./out/${{ vars.renderPath }}
- uses: git-commit
config:
path: ./gitops
message: |
Promote levelbuilder to ${{ imageFrom("ghcr.io/code-dot-org/code-dot-org").Tag }} [skip ci]
path: ./out
message: Render ${{ vars.renderDeployment }} from ${{ outputs.freight.releaseId }}
- uses: git-push
config:
path: ./gitops
path: ./out
branch: ${{ vars.targetBranch }}
29 changes: 9 additions & 20 deletions apps/kargo-project-codeai/stages/production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,22 @@ spec:
requestedFreight:
- origin:
kind: Warehouse
name: kargo-project-codeai
name: codeai-freight
sources:
stages:
- test
- review-infra-changes
vars:
- name: gitopsRepo
value: https://github.com/code-dot-org/k8s-gitops.git
promotionTemplate:
spec:
vars:
- name: gitopsRepo
value: https://github.com/code-dot-org/k8s-gitops.git
steps:
- uses: git-clone
config:
repoURL: ${{ vars.gitopsRepo }}
checkout:
- branch: main
path: ./gitops
- uses: yaml-update
- commit: ${{ commitFrom(vars.gitopsRepo, warehouse('codeai-freight')).ID }}
path: ./freight
- uses: yaml-parse
config:
path: ./gitops/apps/codeai/deployments/production/values.yaml
updates:
- key: image
value: ghcr.io/code-dot-org/code-dot-org:${{ imageFrom("ghcr.io/code-dot-org/code-dot-org").Tag }}
- uses: git-commit
config:
path: ./gitops
message: |
Promote production to ${{ imageFrom("ghcr.io/code-dot-org/code-dot-org").Tag }} [skip ci]
- uses: git-push
config:
path: ./gitops
path: ./freight/warehouses/codeai/freight/current/freight.yaml
127 changes: 127 additions & 0 deletions apps/kargo-project-codeai/stages/review-infra-changes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
apiVersion: kargo.akuity.io/v1alpha1
kind: Stage
metadata:
name: review-infra-changes
namespace: kargo-project-codeai
spec:
requestedFreight:
- origin:
kind: Warehouse
name: codeai-freight
sources:
stages:
- levelbuilder
vars:
- name: gitopsRepo
value: https://github.com/code-dot-org/k8s-gitops.git
- name: targetBranch
value: stage/production
- name: renderDeployment
value: production
- name: renderPath
value: apps/codeai/deployments/production/deploy
- name: imageRepo
value: ghcr.io/code-dot-org/code-dot-org
- name: legacyEnv
value: production
promotionTemplate:
spec:
steps:
- uses: git-clone
config:
repoURL: ${{ vars.gitopsRepo }}
checkout:
- commit: ${{ commitFrom(vars.gitopsRepo, warehouse('codeai-freight')).ID }}
path: ./freight
- branch: main
path: ./meta
- branch: ${{ vars.targetBranch }}
create: true
path: ./out
- uses: yaml-parse
as: freight
config:
path: ./freight/warehouses/codeai/freight/current/freight.yaml
outputs:
- name: releaseId
fromExpression: tag
- uses: yaml-parse
as: legacy-merge
config:
path: ./meta/warehouses/codeai/legacy-gitflow/${{ vars.legacyEnv }}/merged/${{ outputs.freight.releaseId }}.yaml
outputs:
- name: mergedAt
fromExpression: mergedAt
- uses: yaml-parse
as: deployment-meta
config:
path: ./meta/apps/codeai/deployments/${{ vars.renderDeployment }}/deployment.yaml
outputs:
- name: envType
fromExpression: envType
- name: namespace
fromExpression: namespace
- uses: git-clear
config:
path: ./out
- uses: copy
config:
inPath: ./freight/warehouses/codeai/freight/current/kustomize
outPath: ./work/source
- uses: copy
config:
inPath: ./meta/apps/codeai/envTypes/${{ outputs['deployment-meta'].envType }}
outPath: ./work/envTypes/${{ outputs['deployment-meta'].envType }}
- uses: copy
config:
inPath: ./meta/apps/codeai/envTypes/components
outPath: ./work/envTypes/components
- uses: copy
config:
inPath: ./meta/apps/codeai/kargo/templates/deploy
outPath: ./work/deploy
- uses: yaml-update
config:
path: ./work/deploy/kustomization.yaml
updates:
- key: namespace
value: ${{ outputs['deployment-meta'].namespace }}
- key: resources
value:
- ../source/base
- key: components
value:
- ../envTypes/${{ outputs['deployment-meta'].envType }}
- uses: kustomize-set-image
config:
path: ./work/deploy
images:
- image: code-dot-org
newName: ${{ vars.imageRepo }}
tag: ${{ outputs.freight.releaseId }}
- uses: kustomize-build
config:
path: ./work/deploy
outputFormat: kustomize
outPath: ./out/${{ vars.renderPath }}
- uses: git-commit
config:
path: ./out
message: Review production render for ${{ outputs.freight.releaseId }}
- uses: git-push
as: push
config:
path: ./out
generateTargetBranch: true
- uses: git-open-pr
as: open-pr
config:
repoURL: ${{ vars.gitopsRepo }}
createTargetBranch: true
sourceBranch: ${{ outputs.push.branch }}
targetBranch: ${{ vars.targetBranch }}
title: Review CodeAI production render for ${{ outputs.freight.releaseId }}
- uses: git-wait-for-pr
config:
repoURL: ${{ vars.gitopsRepo }}
prNumber: ${{ outputs['open-pr'].pr.id }}
Loading