Skip to content

Commit

Permalink
docs: guide for multi stage delivery (keptn#3080)
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Bacher <[email protected]>
Co-authored-by: Moritz Wiesinger <[email protected]>
Signed-off-by: vickysomtee <[email protected]>
  • Loading branch information
2 people authored and Vickysomtee committed Apr 22, 2024
1 parent dfe64f8 commit 013c296
Show file tree
Hide file tree
Showing 14 changed files with 603 additions and 0 deletions.
101 changes: 101 additions & 0 deletions docs/docs/guides/assets/multi-stage-delivery/application-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: podtato-head-frontend
namespace: podtato-head-dev
spec:
selector:
matchLabels:
app: podtato-head-frontend
template:
metadata:
labels:
app: podtato-head-frontend
app.kubernetes.io/name: podtato-head-frontend
app.kubernetes.io/part-of: podtato-head
app.kubernetes.io/version: {{.Values.serviceVersion}}
spec:
containers:
- image: ghcr.io/podtato-head/podtato-server:{{.Values.serviceVersion}}
name: podtato-head-service
imagePullPolicy: Always
ports:
- containerPort: 9000
name: http
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/part-of: podtato-head
name: podtato-head-frontend
namespace: podtato-head-dev
spec:
ports:
- name: http
port: 8080
targetPort: 9000
protocol: TCP
selector:
app: podtato-head-frontend
type: ClusterIP
---
apiVersion: lifecycle.keptn.sh/v1beta1
kind: KeptnAppContext
metadata:
name: podtato-head
namespace: podtato-head-dev
spec:
postDeploymentTasks:
- post-deployment
promotionTasks:
- promote
metadata:
commitID: {{.Values.commitID}}
---
apiVersion: lifecycle.keptn.sh/v1beta1
kind: KeptnTaskDefinition
metadata:
name: post-deployment
namespace: podtato-head-dev
spec:
function:
inline:
code: |
console.log("deployment completed");
---
apiVersion: lifecycle.keptn.sh/v1beta1
kind: KeptnTaskDefinition
metadata:
name: promote
namespace: podtato-head-dev
spec:
function:
secureParameters:
secret: github-token
inline:
code: |
let secureDataText = Deno.env.get("SECURE_DATA");
let secureData;
if (secureDataText != "") {
secureData = JSON.parse(secureDataText);
}
let contextText = Deno.env.get("KEPTN_CONTEXT");
let context;
if (contextText != "") {
context = JSON.parse(contextText);
}
let body = `{"ref":"main","inputs":{"traceParent":"${context.metadata.traceparent}"}}`;
let resp = await fetch(
"https://api.github.com/repos/" + secureData.githubRepoOwner + "/" + secureData.githubRepo + "/actions/workflows/promote.yaml/dispatches",
{
method: "POST",
body: body,
headers: {
'Accept': 'application/vnd.github+json',
'Authorization': `Bearer ${secureData.apiToken}`,
'X-GitHub-Api-Version': '2022-11-28'
},
});
console.log(resp);
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: podtato-head-frontend
namespace: podtato-head-production
spec:
selector:
matchLabels:
app: podtato-head-frontend
template:
metadata:
labels:
app: podtato-head-frontend
app.kubernetes.io/name: podtato-head-frontend
app.kubernetes.io/part-of: podtato-head
app.kubernetes.io/version: {{.Values.serviceVersion}}
spec:
containers:
- image: ghcr.io/podtato-head/podtato-server:{{.Values.serviceVersion}}
name: podtato-head-service
imagePullPolicy: Always
ports:
- containerPort: 9000
name: http
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/part-of: podtato-head
name: podtato-head-frontend
namespace: podtato-head-production
spec:
ports:
- name: http
port: 8080
targetPort: 9000
protocol: TCP
selector:
app: podtato-head-frontend
type: ClusterIP
---
apiVersion: lifecycle.keptn.sh/v1beta1
kind: KeptnAppContext
metadata:
name: podtato-head
namespace: podtato-head-production
spec:
metadata:
commitID: {{.Values.commitID}}
24 changes: 24 additions & 0 deletions docs/docs/guides/assets/multi-stage-delivery/argo-app-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: podtato-head-dev
namespace: argocd
spec:
project: default
source:
repoURL: 'https://github.com/<repo-owner>/<repo>'
path: dev
targetRevision: main
helm:
parameters:
- name: "commitID" # (1)!
value: "$ARGOCD_APP_REVISION"
destination:
server: 'https://kubernetes.default.svc'
namespace: podtato-head-dev
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: podtato-head-prod
namespace: argocd
spec:
project: default
source:
repoURL: 'https://github.com/<repo-owner>/<repo>'
path: production
targetRevision: main
helm:
parameters:
- name: "commitID" # (1)!
value: "$ARGOCD_APP_REVISION"
destination:
server: 'https://kubernetes.default.svc'
namespace: podtato-head-production
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
6 changes: 6 additions & 0 deletions docs/docs/guides/assets/multi-stage-delivery/chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: podtato-head
kubeVersion: ">= 1.24.0-0"
type: application
version: 0.1.0
appVersion: "v0.1.0"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions docs/docs/guides/assets/multi-stage-delivery/promote.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: promote

on:
workflow_dispatch:
inputs:
traceParent:
description: 'OTEL parent trace'
required: false
type: string

permissions:
contents: write
pull-requests: write

jobs:
promote:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
# configure git client
git config --global user.email "<email address>"
git config --global user.name "<name>"
# create a new branch
git switch -c production/${{ github.sha }}
# promote the change
cp dev/values.yaml production/values.yaml
echo "traceParent: $TRACE_PARENT" >> production/values.yaml
# push the change to the new branch
git add production/values.yaml
git commit -m "Promote dev to production"
git push -u origin production/${{ github.sha }}
env:
TRACE_PARENT: ${{ inputs.traceParent }}
- run: |
gh pr create \
-B main \
-H production/${{ github.sha }} \
--title "Promote dev to production" \
--body "Automatically created by GHA"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
serviceVersion: v0.3.1
commitID: "" # (1)!
2 changes: 2 additions & 0 deletions docs/docs/guides/assets/multi-stage-delivery/values-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
serviceVersion: v0.3.0
commitID: "" # (1)!
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
serviceVersion: v0.3.0
commitID: "" # (1)!
traceParent: "" # (2)!
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 013c296

Please sign in to comment.