Skip to content

Commit a09e0bc

Browse files
committed
docs: gitops doc using apps
Signed-off-by: Tiexin Guo <[email protected]>
1 parent 457a8d7 commit a09e0bc

File tree

3 files changed

+164
-1
lines changed

3 files changed

+164
-1
lines changed

docs/best-practices/apps.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# GitOps with "Apps"
2+
3+
## 0 Goal
4+
5+
In this tutorial, we will try to use DevStream's new feature "Apps" to achieve similar result to the [GitOps](./gitops.md), but using much less configuration, to show the power of "Apps" in the config. If you haven't read the original GitOps best practice, click the above link first.
6+
7+
Two applications will be created (one Python, one Golang), CI/CD pipelines will be set up for both, and both apps will be deployed via Argo CD, just like the GitOps best practice.
8+
9+
---
10+
11+
## 1 Overview
12+
13+
DevStream will use the "Apps" concept to create repositories with scaffolding code, GitHub Actions CI pipelines, install Argo CD, and deploy the apps via Argo CD.
14+
15+
---
16+
17+
## 2 Create the Config File
18+
19+
Create a temporary working directory for this tutorial:
20+
21+
```bash
22+
mkdir test
23+
cd test/
24+
```
25+
26+
Download dtm (see the [GitOps](./gitops.md) best practice if you haven't).
27+
28+
Then generate the config file by running:
29+
30+
```bash
31+
./dtm show config --template=apps > config.yaml
32+
```
33+
34+
Then set the following environment variables by running (replace values within the double quotes):
35+
36+
```shell
37+
export GITHUB_USER="<YOUR_GITHUB_PERSONAL_ACCESS_TOKEN_HERE>"
38+
export DOCKERHUB_USERNAME="<YOUR_DOCKER_HUB_USER_NAME_HERE>"
39+
```
40+
41+
Then we run the following commands to update our config file with those env vars:
42+
43+
=== "**macOS** or **FreeBSD** based systems"
44+
45+
```shell
46+
sed -i.bak "s@YOUR_GITHUB_USER@${GITHUB_USER}@g" config.yaml
47+
sed -i.bak "s@YOUR_DOCKERHUB_USER@${DOCKERHUB_USERNAME}@g" config.yaml
48+
```
49+
50+
=== "**GNU** Linux users"
51+
52+
```shell
53+
sed -i "s@YOUR_GITHUB_USERNAME_CASE_SENSITIVE@${GITHUB_USER}@g" config.yaml
54+
sed -i "s@YOUR_DOCKER_USERNAME@${DOCKERHUB_USERNAME}@g" config.yaml
55+
```
56+
57+
---
58+
59+
## 3 Init and Apply
60+
61+
Run:
62+
63+
```bash
64+
./dtm init -f config.yaml
65+
```
66+
67+
This downloads the required plugins, according to the config file, automatically.
68+
69+
Then we apply it by running:
70+
71+
```bash
72+
./dtm apply -f config.yaml -y
73+
```
74+
75+
You will see similar outputs as the following:
76+
77+
```bash
78+
tiexin@mbp ~/work/devstream-io/test $ ./dtm apply -f config.yaml -y
79+
2022-12-16 14:30:27 ℹ [INFO] Apply started.
80+
2022-12-16 14:30:28 ℹ [INFO] Using local backend. State file: devstream.state.
81+
2022-12-16 14:30:28 ℹ [INFO] Tool (helm-installer/argocd) found in config but doesn't exist in the state, will be created.
82+
2022-12-16 14:30:28 ℹ [INFO] Tool (repo-scaffolding/myapp1) found in config but doesn't exist in the state, will be created.
83+
2022-12-16 14:30:28 ℹ [INFO] Tool (repo-scaffolding/myapp2) found in config but doesn't exist in the state, will be created.
84+
2022-12-16 14:30:28 ℹ [INFO] Tool (github-actions/myapp1) found in config but doesn't exist in the state, will be created.
85+
2022-12-16 14:30:28 ℹ [INFO] Tool (argocdapp/myapp1) found in config but doesn't exist in the state, will be created.
86+
2022-12-16 14:30:28 ℹ [INFO] Tool (github-actions/myapp2) found in config but doesn't exist in the state, will be created.
87+
2022-12-16 14:30:28 ℹ [INFO] Tool (argocdapp/myapp2) found in config but doesn't exist in the state, will be created.
88+
2022-12-16 14:30:28 ℹ [INFO] Start executing the plan.
89+
2022-12-16 14:30:28 ℹ [INFO] Changes count: 7.
90+
2022-12-16 14:30:28 ℹ [INFO] -------------------- [ Processing progress: 1/7. ] --------------------
91+
2022-12-16 14:30:28 ℹ [INFO] Processing: (helm-installer/argocd) -> Create ...
92+
2022-12-16 14:30:29 ℹ [INFO] Filling default config with instance: argocd.
93+
2022-12-16 14:30:29 ℹ [INFO] Creating or updating helm chart ...
94+
... (omitted)
95+
... (omitted)
96+
2022-12-16 14:32:09 ℹ [INFO] -------------------- [ Processing progress: 7/7. ] --------------------
97+
2022-12-16 14:32:09 ℹ [INFO] Processing: (argocdapp/myapp2) -> Create ...
98+
2022-12-16 14:32:19 ℹ [INFO] application.argoproj.io/myapp2 created
99+
2022-12-16 14:32:19 ✔ [SUCCESS] Tool (argocdapp/myapp2) Create done.
100+
2022-12-16 14:32:19 ℹ [INFO] -------------------- [ Processing done. ] --------------------
101+
2022-12-16 14:32:19 ✔ [SUCCESS] All plugins applied successfully.
102+
2022-12-16 14:32:19 ✔ [SUCCESS] Apply finished.
103+
```
104+
105+
---
106+
107+
## 4 Check the Results
108+
109+
Let's continue to look at the results of the `apply` command.
110+
111+
Similar to what we did in the [GitOps](./gitops.md) best practice, we can check that repositories for two applications are created, CI pipelins are created for both apps too, Argo CD is installed, and both apps are deployed by Argo CD into our Kubernetes cluster.
112+
113+
---
114+
115+
## 5 Clean Up
116+
117+
Run:
118+
119+
```bash
120+
./dtm delete -f config.yaml -y
121+
```
122+
123+
And you will get similar outputs to the following:
124+
125+
```bash
126+
2022-12-16 14:34:30 ℹ [INFO] Delete started.
127+
2022-12-16 14:34:31 ℹ [INFO] Using local backend. State file: devstream.state.
128+
2022-12-16 14:34:31 ℹ [INFO] Tool (github-actions/myapp1) will be deleted.
129+
2022-12-16 14:34:31 ℹ [INFO] Tool (argocdapp/myapp1) will be deleted.
130+
2022-12-16 14:34:31 ℹ [INFO] Tool (github-actions/myapp2) will be deleted.
131+
2022-12-16 14:34:31 ℹ [INFO] Tool (argocdapp/myapp2) will be deleted.
132+
2022-12-16 14:34:31 ℹ [INFO] Tool (repo-scaffolding/myapp1) will be deleted.
133+
2022-12-16 14:34:31 ℹ [INFO] Tool (repo-scaffolding/myapp2) will be deleted.
134+
2022-12-16 14:34:31 ℹ [INFO] Tool (helm-installer/argocd) will be deleted.
135+
2022-12-16 14:34:31 ℹ [INFO] Start executing the plan.
136+
2022-12-16 14:34:31 ℹ [INFO] Changes count: 7.
137+
2022-12-16 14:34:31 ℹ [INFO] -------------------- [ Processing progress: 1/7. ] --------------------
138+
2022-12-16 14:34:31 ℹ [INFO] Processing: (github-actions/myapp1) -> Delete ...
139+
2022-12-16 14:34:33 ℹ [INFO] Prepare to delete 'github-actions_myapp1' from States.
140+
2022-12-16 14:34:33 ✔ [SUCCESS] Tool (github-actions/myapp1) delete done.
141+
... (omitted)
142+
... (omitted)
143+
2022-12-16 14:34:40 ✔ [SUCCESS] Tool (helm-installer/argocd) delete done.
144+
2022-12-16 14:34:40 ℹ [INFO] -------------------- [ Processing done. ] --------------------
145+
2022-12-16 14:34:40 ✔ [SUCCESS] All plugins deleted successfully.
146+
2022-12-16 14:34:40 ✔ [SUCCESS] Delete finished.
147+
```
148+
149+
Then you can delete what we created:
150+
151+
```bash
152+
cd ../
153+
rm -rf test/
154+
rm -rf ~/.devstream/
155+
```

docs/best-practices/apps.zh.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 使用DevStream的新功能Apps来进行GitOps
2+
3+
TODO

mkdocs.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,12 @@ nav:
121121
- plugins/helm-installer/helm-installer*.md
122122
- plugins/helm-installer/*.md
123123
- plugins/*.md
124-
- Best Practices: best-practices/
124+
- Best Practices:
125+
- best-practices/gitops*.md
126+
- best-practices/apps*.md
127+
- best-practices/gitlab-jenkins-harbor-java-springboot*.md
128+
- best-practices/gjh-java-springboot-air-gapped-deployment*.md
129+
- best-practices/image-registry*.md
125130
- contributing_guide*.md
126131
- contributor_ladder*.md
127132
- Governance ⧉: https://github.com/devstream-io/devstream/blob/main/GOVERNANCE.md

0 commit comments

Comments
 (0)