Files
kub-web-test/README.md
T
2026-09-10 13:57:05 +02:00

155 lines
2.9 KiB
Markdown

\
# kub-web-test
Two Git branches, three deployed environments.
## Branches
- `dev` — development changes go here
- `prod` — Kargo writes promoted content here
There is deliberately **no staging branch**.
## Sites / Kargo Stages
- DEV — `http://web-dev.max.test.scrumdapp.open-ict.hu`
- STAGING — `http://web-staging.max.test.scrumdapp.open-ict.hu`
- PROD — `http://web-prod.max.test.scrumdapp.open-ict.hu`
```text
push to dev
|
v
Warehouse
|
v (automatic)
DEV
|
v (manual)
STAGING
|
v (manual)
PROD
|
+--> writes promoted content to prod branch
```
Staging is pinned by Kargo to the exact commit selected from `dev`.
Prod permanently tracks the `prod` branch.
## Initial Git setup
```bash
git init
git remote add origin https://git.5vl.nl/5vl/kub-web-test.git
git checkout -b dev
git add .
git commit -m "Initial Helm and Kargo setup"
git push -u origin dev
# Seed prod once so Argo CD has something to deploy initially.
git checkout -b prod
git push -u origin prod
git checkout dev
```
After that, do your normal work on `dev`.
## Bootstrap Kargo project
```bash
kubectl apply -f bootstrap/00-kargo-project.yaml
kubectl get namespace web
```
## Kargo Git credentials
Kargo needs write permission because the prod promotion pushes to `prod`.
Do not commit the real token.
```bash
read -s -p "Git token: " GIT_TOKEN
echo
kubectl create secret generic kub-web-test-git \
-n web \
--from-literal=repoURL=https://git.5vl.nl/5vl/kub-web-test.git \
--from-literal=username=5vl \
--from-literal=password="$GIT_TOKEN"
kubectl label secret kub-web-test-git \
-n web \
kargo.akuity.io/cred-type=git
```
## Argo CD repository credentials
If the repository is private:
```bash
kubectl create secret generic kub-web-test-repository \
-n argocd \
--from-literal=type=git \
--from-literal=url=https://git.5vl.nl/5vl/kub-web-test.git \
--from-literal=username=5vl \
--from-literal=password="$GIT_TOKEN"
kubectl label secret kub-web-test-repository \
-n argocd \
argocd.argoproj.io/secret-type=repository
```
Then:
```bash
unset GIT_TOKEN
```
## Create Argo CD apps and Kargo pipeline
```bash
kubectl apply -f bootstrap/01-argocd-applications.yaml
kubectl apply -f bootstrap/02-kargo-pipeline.yaml
```
Check:
```bash
kubectl get applications -n argocd
kubectl get warehouse -n web
kubectl get stages -n web
kubectl get freight -n web
```
## Test the flow
Make any change on `dev`:
```bash
git checkout dev
# edit something
git add .
git commit -m "Test deployment"
git push
```
Then:
1. Kargo discovers the commit as Freight.
2. `dev` auto-promotes it.
3. Check the DEV site.
4. Manually promote that Freight to `staging`.
5. Check the STAGING site.
6. Manually promote the same Freight to `prod`.
7. Kargo copies that selected revision into the `prod` branch and pushes it.
8. Argo CD syncs the PROD site from `prod`.
The three Kubernetes namespaces are:
- `web-dev`
- `web-staging`
- `web-prod`