First commit
This commit is contained in:
commit
70ceb5bdb1
37
README.md
Normal file
37
README.md
Normal file
@ -0,0 +1,37 @@
|
||||
This repo, in conjunction with the [App Code repo](https://gitea.scubbo.org/scubbo/auto-update-test-app-code), demonstrates how to use the Auto-Update Drone Plugin to trigger App deployments in a CI/CD pipeline which uses GitOps to define the App Versions in Git.
|
||||
|
||||
## Demonstration
|
||||
|
||||
While in the App Code repo, at commit `65866e` ([link](https://gitea.scubbo.org/scubbo/auto-update-test-app-code/commit/65866ea3b60906d60c4c7aa22b51333cb906c839)), and having already carried out a "first-pass" sync in my CD application (ArgoCD) to get components deployed:
|
||||
|
||||
```
|
||||
# Make the deployed pod "call itself" - saves us from the hassle of setting up a Service
|
||||
$ kubectl exec -it -n auto-update $(kubectl -n auto-update get pods -o=jsonpath='{.items[*].metadata.name}') -- curl localhost:8000
|
||||
Hello world!%
|
||||
# OK, good - as expected, the Application initially responds with "Hello world!". Now let's make a change and demonstrate that it's deployed.
|
||||
$ git reset --hard cffc43
|
||||
HEAD is now at cffc437 Expand project scope
|
||||
$ git status
|
||||
On branch main
|
||||
Your branch is ahead of 'origin/main' by 1 commit.
|
||||
|
||||
nothing to commit, working tree clean
|
||||
$ git push
|
||||
[...]
|
||||
To https://gitea.scubbo.org/scubbo/auto-update-test-app-code.git
|
||||
65866ea..cffc437 main -> main
|
||||
#
|
||||
# Now observe:
|
||||
# * the Drone pipeline results in a commit to the infra package...
|
||||
# * ...which is visible in Gitea
|
||||
# * Once the Argo application is synced, new Kubernetes resources are created to match the new Infrastructure definition
|
||||
#
|
||||
$ kubectl exec -it -n auto-update $(kubectl -n auto-update get pods -o=jsonpath='{.items[*].metadata.name}') -- curl localhost:8000
|
||||
Hello universe!
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Points to note
|
||||
* `helm/templates/_helpers.tpl` contains the `fullImageName` definition, which in turn depends on `imageTag`, which uses [Files access](https://helm.sh/docs/chart_template_guide/accessing_files) to read the contents of `helm/deployed-images/<targetEnv>`
|
||||
* The value `targetEnv` must be set in the setup for the specific CD application which will "watch" this repo for updates.
|
7
helm/Chart.yaml
Normal file
7
helm/Chart.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
apiVersion: v2
|
||||
name: auto-update-test-infra
|
||||
description: A Helm chart for Kubernetes, demonstrating auto-update functionality
|
||||
|
||||
type: application
|
||||
version: 0.1.0
|
||||
appVersion: "1.1.0"
|
1
helm/deployed-images/prod
Normal file
1
helm/deployed-images/prod
Normal file
@ -0,0 +1 @@
|
||||
9b6b005ca3
|
13
helm/templates/_helpers.tpl
Normal file
13
helm/templates/_helpers.tpl
Normal file
@ -0,0 +1,13 @@
|
||||
{{- define "imageTag" }}
|
||||
{{- $val := "" }}
|
||||
{{- if and (hasKey .Values.image "tag") (.Values.image.tag) }}
|
||||
{{- $val = .Values.image.tag }}
|
||||
{{- else }}
|
||||
{{- $val = (.Files.Get (printf "%s/%s" "deployed-images" (required "You must set targetEnv if image.tag is absent!" .Values.targetEnv))) }}
|
||||
{{- end }}
|
||||
{{- trim $val }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "fullImageName" -}}
|
||||
{{- printf "%s:%s" .Values.image.repository (include "imageTag" .) }}
|
||||
{{- end }}
|
16
helm/templates/infra.yaml
Normal file
16
helm/templates/infra.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: auto-update-test-infra
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: auto-update-test-infra
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: auto-update-test-infra
|
||||
spec:
|
||||
containers:
|
||||
- name: auto-update-test-infra
|
||||
image: {{ include "fullImageName" . }}
|
2
helm/values.yaml
Normal file
2
helm/values.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
image:
|
||||
repository: gitea.scubbo.org/scubbo/auto-update-test-app-code
|
Loading…
x
Reference in New Issue
Block a user