Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: guide for multi stage delivery #3080

Merged
merged 25 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 20 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
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
bacherfl marked this conversation as resolved.
Show resolved Hide resolved

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)!
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
Loading