generated from eficode-academy/argocd-katas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ace1cac
Showing
62 changed files
with
1,921 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Eficode Academy | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# argocd-katas | ||
|
||
Exercise list in order: | ||
|
||
* [Setup of your ArgoCD root application](setup.md) | ||
* [Introduction to ArgoCD](intro.md) | ||
* [ArgoCD And Helm](argocd-and-helm.md) | ||
* [App of Apps](app-of-apps.md) | ||
* [ApplicationSets](applicationsets.md) | ||
* [Projects](projects.md) | ||
* [Sealed Secrets](sealed-secrets.md) (Not done yet) | ||
|
||
## Using this outside of the workshop | ||
|
||
You need to have ArgoCD installed and running. | ||
All exercises should work on minikube, or kind. | ||
You can refer to the [installation link](https://argo-cd.readthedocs.io/en/stable/operator-manual/installation/) for how to install ArgoCD. | ||
You do not need the HA setup for the exercises. | ||
|
||
## Repository Structure | ||
|
||
The repository is structured as follows: | ||
|
||
```text | ||
. | ||
├── applicationsets # Values for applicationsets.md | ||
├── applicationsets.md | ||
├── app-of-apps.md | ||
├── argocd-and-helm.md | ||
├── img | ||
├── intro.md | ||
├── jenkins # Values for the Jenkins Helm Chart | ||
├── LICENSE | ||
├── quotes-flask # Example application | ||
├── README.md | ||
├── sealed-secrets.md | ||
├── setup.md | ||
└── trainer # Trainer folder | ||
``` | ||
|
||
|
||
Links: | ||
|
||
* https://codefresh.io/blog/argo-cd-best-practices/ | ||
* https://github.com/akuity/awesome-argo/blob/main/CONTRIBUTING.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
# Organizing and Managing Argo CD Apps through app-of-apps | ||
|
||
## Learning Goals | ||
|
||
- Create a bootstrap app manifest | ||
- Arrange Argo CD app manifests in a folder structure | ||
|
||
## Introduction | ||
|
||
In this exercise, we will work on organizing and managing Argo CD applications more effectively. We will create a bootstrap app manifest to serve as a starting point, structure our repository to accommodate multiple apps, and work with a new app manifest for a Helm chart. | ||
|
||
## Exercise | ||
|
||
### Overview | ||
|
||
- Create Bootstrap App Manifest | ||
- Create Folder for All Apps | ||
- Move Jenkins App Manifest | ||
- Create the App Manifest for the Quotes Helm Chart | ||
|
||
### Step by step instructions | ||
|
||
<details> | ||
<summary>More Details</summary> | ||
|
||
* Create bootsrap app manifest | ||
* Create folder for all apps in the repo | ||
* Move Jenkins app manifest to the folder | ||
* Create the app manifest for the quotes helm chart located in the same repo. (OR IN THE OTHER REPO TODO) | ||
* Enable sync policy, prune and self-heal | ||
* kubectl delete parent app, make sure nothing is there. kubectl apply parent app again. | ||
|
||
|
||
## Step 1: Create Bootstrap App Manifest | ||
|
||
1. Navigate to the root of your local clone of the exercise repository. | ||
2. Create a file named `bootstrap-app.yaml` with the following content: | ||
|
||
:bulb: NB! Make sure to replace the placeholders with your own values. | ||
|
||
```yaml | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: bootstrap-student-<YOURNUMBER> | ||
namespace: argocd | ||
spec: | ||
destination: | ||
server: https://kubernetes.default.svc | ||
namespace: student-<YOURNUMBER> | ||
project: default | ||
source: | ||
repoURL: <YOUR GITHUB REPO> | ||
targetRevision: HEAD | ||
path: apps | ||
syncPolicy: | ||
automated: | ||
prune: true | ||
selfHeal: true | ||
``` | ||
1. Apply the bootstrap app manifest to your cluster: | ||
```bash | ||
kubectl apply -f bootstrap-app.yaml | ||
``` | ||
|
||
1. Go to the Argo CD UI and verify that the bootstrap app is present. It should have an error saying that it cannot find the `apps` folder. This is expected. | ||
|
||
## Step 2: Create Folder for All Apps, and add Jenkins App Manifest to it. | ||
|
||
Save the current application manifest to your repository in a new folder named `apps`. | ||
|
||
- Get the Jenkins application manifest from the Argo CD UI: | ||
- click `App details` and then `Manifest`. | ||
- It does not have the entire manifest, but it has the spec part. | ||
- It should be saved in the `apps` directory in your repository. | ||
- Name it `jenkins-app.yaml`. | ||
|
||
<details> | ||
<summary>:bulb: Help me out</summary> | ||
|
||
The file that you will be saving looks like this, with the `<NUMBER>` being your student number and `<YOUR GIT REPO>` being your repository URL: | ||
|
||
```yaml | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: student-<NUMBER>-jenkins | ||
namespace: argocd | ||
spec: | ||
project: default | ||
sources: | ||
- repoURL: 'https://charts.bitnami.com/bitnami' | ||
targetRevision: 12.4.0 | ||
helm: | ||
valueFiles: | ||
- $values/jenkins/values.yaml | ||
chart: jenkins | ||
- repoURL: 'https://github.com/<YOUR GIT REPO>/argocd-katas' | ||
targetRevision: main | ||
ref: values | ||
destination: | ||
server: 'https://kubernetes.default.svc' | ||
namespace: student-<NUMBER> | ||
syncPolicy: | ||
automated: | ||
prune: true | ||
selfHeal: true | ||
``` | ||
</details> | ||
- Add, commit and push the jenkins-app.yaml to the repository. | ||
- Go to the Argo CD UI and verify that the bootstrap app is present. It should now be updated to include the `apps` folder, and therefore the Jenkins app manifest. | ||
|
||
Now the jenkins app is connected with the bootstrap app. | ||
|
||
## Delete the jenkins app | ||
|
||
- In the Argo CD UI, delete the jenkins app. | ||
- What happens when you do that? | ||
|
||
|
||
## Create the App Manifest for the Quotes Helm Chart | ||
|
||
1. In the `apps` folder, create a file named `quotes-app.yaml` with the following content: | ||
|
||
```yaml | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: quotes-student-<YOURNUMBER> | ||
namespace: argocd | ||
spec: | ||
destination: | ||
server: https://kubernetes.default.svc | ||
namespace: student-<YOUR number> | ||
project: default | ||
source: | ||
repoURL: https://github.com/eficode-academy/argocd-katas.git # Update this URL if the helm chart is in a different repo | ||
targetRevision: HEAD | ||
path: quotes-flask/helm/quotes-flask | ||
helm: | ||
valueFiles: | ||
- values.yaml | ||
syncPolicy: | ||
automated: | ||
prune: true | ||
selfHeal: true | ||
``` | ||
|
||
- Click refresh in the Argo CD UI. The quotes app should now be present as an application in Argo CD. | ||
- Click on the quotes app to see all the resources that it creates. | ||
|
||
## Apply and Re-Apply the Bootstrap App | ||
|
||
1. Verify the applications are synced and running as expected. | ||
|
||
1. Delete the bootstrap app from your cluster: | ||
|
||
```bash | ||
kubectl delete -f bootstrap-app.yaml | ||
``` | ||
|
||
1. Verify that the applications and resources are removed. | ||
|
||
```bash | ||
kubectl get all | ||
``` | ||
|
||
1. Re-apply the bootstrap app manifest to your cluster: | ||
|
||
```bash | ||
kubectl apply -f bootstrap-app.yaml | ||
``` | ||
|
||
1. Verify the applications are synced and running as expected again. | ||
|
||
You have now seen how fast it is to reapply your manifests to the cluster. This is a great way to recover from a disaster, or to make sure that your cluster is in the desired state. | ||
|
||
</details> | ||
|
||
## Conclusion | ||
|
||
In this exercise, you learned how to organize Argo CD app manifests within a repository, create a new app manifest for a Helm chart, and utilize sync, prune, and self-heal features to maintain the desired state in your Kubernetes cluster. This structure and practices will help you manage and operate your applications more effectively with Argo CD. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: ApplicationSet | ||
metadata: | ||
name: pr-<NUMBER> | ||
namespace: argocd | ||
spec: | ||
generators: | ||
- pullRequest: | ||
github: | ||
# The GitHub organization or user. | ||
owner: <YOUR GITHUB USERNAME> #e.g. eficode-academy | ||
# The Github repository | ||
repo: <YOUR GIT REPO> #e.g. argocd-katas | ||
tokenRef: # your github token | ||
secretName: student-<NUMBER>-github-token # the name of the secret that contains your github token | ||
key: token # the key in the secret that contains your github token | ||
# Labels is used to filter the PRs that you want to target. (optional) | ||
labels: | ||
- test | ||
requeueAfterSeconds: 180 | ||
template: | ||
metadata: | ||
name: 'todo-<NUMBER>-{{branch}}-{{number}}' | ||
spec: | ||
project: "default" | ||
source: | ||
repoURL: 'https://github.com/eficode-academy/helm-katas.git' | ||
targetRevision: 'main' | ||
path: examples/apps/http-server | ||
helm: | ||
parameters: | ||
- name: containerPort | ||
value: "3000" | ||
- name: image.repository | ||
value: releasepraqma/todo-app | ||
- name: image.tag | ||
value: latest | ||
- name: prefix | ||
value: argo | ||
- name: app | ||
value: "todo-{{head_short_sha}}" | ||
destination: | ||
server: https://kubernetes.default.svc | ||
namespace: <YOUR NAMESPACE> | ||
syncPolicy: | ||
automated: | ||
prune: true | ||
selfHeal: true |
Oops, something went wrong.