Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"MD013": false,
"MD033": {
"allowed_elements": ["details", "summary"]
}
}
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# Argo CD Katas

Welcome to the Argo CD Katas repository! This project is designed to help users learn and master Argo CD through practical exercises and challenges.
Welcome to the Argo CD Katas repository! This project is designed to help users learn and master Argo CD through practical exercises and challenges.

Whether you are a beginner looking to understand the basics or an experienced user seeking to deepen your knowledge, these katas will guide you through various aspects of using Argo CD in a real-world context.

## About Argo CD

Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.
It allows for Kubernetes resources to be managed using git repositories as the source of truth, making it easier to implement continuous deployment strategies in cloud-native environments.
Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.
It enables Kubernetes resources to be managed using Git repositories as the source of truth, making it easier to implement continuous deployment strategies in cloud-native environments.
For more info on ArgoCD itself, please visit [their website](https://argoproj.github.io/cd/).


## Exercise list in order

It is recommended to follow the exercises in the following order.
Expand All @@ -26,7 +25,7 @@ It is recommended to follow the exercises in the following order.
## Using this outside of the workshop

You need to have ArgoCD installed and running.
All exercises should work on minikube, or kind.
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.

Expand All @@ -51,8 +50,7 @@ The repository is structured as follows:
└── trainer # Trainer folder
```


## Links

* https://codefresh.io/blog/argo-cd-best-practices/
* https://github.com/akuity/awesome-argo/blob/main/CONTRIBUTING.md
* <https://codefresh.io/blog/argo-cd-best-practices/>
* <https://github.com/akuity/awesome-argo/blob/main/CONTRIBUTING.md>
35 changes: 17 additions & 18 deletions app-of-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@

## Learning Goals

- Create a bootstrap app manifest
- 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.
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
- Create a folder for All Apps
- Move Jenkins App Manifest
- Create the App Manifest for the Quotes Helm Chart

### Step by step instructions
### 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.

- Create Bootstrap app manifest
- Create a 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

Expand Down Expand Up @@ -69,7 +68,7 @@ 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.
## Step 2: Create a 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`.

Expand Down Expand Up @@ -112,19 +111,19 @@ spec:
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.
Now the Jenkins app is connected with the bootstrap app.

## Delete the jenkins app
## Delete the Jenkins app

- In the Argo CD UI, 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:
Expand Down Expand Up @@ -162,7 +161,7 @@ spec:

1. Verify the applications are synced and running as expected.

1. Delete the bootstrap app from your cluster:
1. Delete the Bootstrap app from your cluster:

```bash
kubectl delete -f bootstrap-app.yaml
Expand All @@ -182,7 +181,7 @@ 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.
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>

Expand Down
83 changes: 41 additions & 42 deletions applicationsets.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,61 @@

## Learning Goals

- Trying out a pull request based application set
- Trying out a pull-request based application set

## Introduction

In this exercise we will try out a pull request based application set. We will try to create an application set that will create an application for each pull request in a repository.
In this exercise, we will try out a pull-request based application set. We will try to create an application set that will create an application for each pull request in a repository.

## Application set

The sole responsibility of the ApplicationSet controller is to create, update, and delete `Application` resources within the Argo CD namespace. The controller's only job is to ensure that the Application resources remain consistent with the defined declarative ApplicationSet resource, and nothing more.

Thus the ApplicationSet controller does not create/modify/delete Kubernetes resources (other than the Application CR)
Thus, the ApplicationSet controller does not create/modify/delete Kubernetes resources (other than the Application CR)

## Exercise

### Overview

- Create a github token
- Create a GitHub token
- Add the token to a secret in the argocd namespace
- Create an applicationset manifest
- Test with a pull request
- Close the pull request

### Step by step instructions
### Step-by-step instructions

<details>
<summary>More Details</summary>

#### Create a github token
#### Create a GitHub token

* Go to your github account settings and [create a new token](https://github.com/settings/tokens?type=beta) with the following permissions:
- Go to your GitHub account settings and [create a new token](https://github.com/settings/tokens?type=beta) with the following permissions:

![github token permissions](img/github-token-permissions.png)

* Copy the token to your clipboard
- Copy the token to your clipboard

#### Add the token to a secret in the argocd namespace

* Create a secret in the argocd namespace with the token
- Create a secret in the argocd namespace with the token

```bash

kubectl create secret generic --dry-run=client student-<NUMBER>-github-token -n argocd -o yaml --from-literal token=github_pat_yourtokenhere > secret.yaml

```

* Edit the secret and replace `<NUMBER>` with your number (student-X)
- Edit the secret and replace `<NUMBER>` with your number (student-X)

* Apply the secret
- Apply the secret

```bash
kubectl apply -f secret.yaml

```

* Check that the secret is there
- Check that the secret is there

```bash

Expand All @@ -80,12 +80,12 @@ spec:
github:
# The GitHub organization or user.
owner: <YOUR GITHUB USERNAME> #e.g. eficode-academy
# The Github repository
# The GitHub repository
repo: <YOUR GIT REPO> #Just the repository name e.g. argocd-katas. Not your entire URL
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)
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 are used to filter the PRs that you want to target. (optional)
labels:
- enhancement
requeueAfterSeconds: 60
Expand Down Expand Up @@ -118,23 +118,24 @@ spec:
prune: true
selfHeal: true
```
* take the contents of the file, and paste it into a file in your workstation. The file could be named ´appset.yaml´.
* edit the file and replace
* `<YOUR GITHUB USERNAME>` with your github username
* `<YOUR GIT REPO>` with your git repo
* `<YOUR NAMESPACE>` with your namespace
* `<NUMBER>` with your number (student-X)
* `<YOUR PREFIX>` The first part before `eficode.academy` as `gitops.eficode.academy`

* Apply the manifest
- Copy the contents of the file and paste it into a file in your workstation. The file could be named ´appset.yaml´.
- edit the file and replace
- `<YOUR GITHUB USERNAME>` with your github username
- `<YOUR GIT REPO>` with your git repo
- `<YOUR NAMESPACE>` with your namespace
- `<NUMBER>` with your number (student-X)
- `<YOUR PREFIX>` The first part before `eficode.academy` as `gitops.eficode.academy`

- Apply the manifest

```bash
kubectl apply -f appset.yaml
```

* Make sure that it is there by listing the applicationsets: `k get applicationsets.argoproj.io -n argocd`.
- Make sure that it is there by listing the applicationsets: `k get applicationsets.argoproj.io -n argocd`.

* Look at the status on it by `k describe applicationsets.argoproj.io -n argocd pr-X` where X is your number.
- Look at the status on it by `k describe applicationsets.argoproj.io -n argocd pr-X` where X is your number.

Output should look like the following:

Expand Down Expand Up @@ -207,41 +208,39 @@ Status:
Events: <none>
```


#### Test with a pull request

* Create a pull request in your git repo. The change does not matter at this time, since we are not using the source code in the pull request. 💡 The name of your branch needs to have all lowercase characters, otherwise it will not work.

- Create a pull request in your git repo. The change does not matter at this time, since we are not using the source code in the pull request. 💡 The name of your branch needs to have all lowercase characters, otherwise it will not work.

* Remember to set the label `enhancement` on the pull request. The label does not exist, so create it in the Github UI.
- Remember to set the label `enhancement` on the pull request. The label does not exist, so create it in the GitHub UI.

* Check that an application has been created in ArgoCD
- Check that an application has been created in ArgoCD

```bash
kubectl get applications -n argocd
```

* Check that an application has been created in your namespace
- Check that an application has been created in your namespace

```bash
kubectl get pods -n <YOUR NAMESPACE>
```

* Get your ingress hostname
- Get your ingress hostname

```bash
kubectl get ingress -n <YOUR NAMESPACE>
```

* Access the application in your browser (remember to add https:// in front of the hostname)
- Access the application in your browser (remember to add https:// in front of the hostname)

You should see something like the follwing:
You should see something like the following:

![the todo application](img/todo-app.png)

#### Close the pull request

* now close the pull request, and see that the application is deleted from ArgoCD
- Now, close the pull request, and see that the application is deleted from ArgoCD

```bash
kubectl get applications -n argocd
Expand All @@ -251,15 +250,15 @@ kubectl get applications -n argocd

### Clean up

* Delete the applicationset
- Delete the applicationset

```bash
kubectl delete -f applicationsets/pull-request.yaml
```

#### Further reading

* [ApplicationSet](https://argocd-applicationset.readthedocs.io/en/stable/)
* [ApplicationSet Generators](https://argocd-applicationset.readthedocs.io/en/stable/Generators/)
* [ApplicationSet Templates](https://argocd-applicationset.readthedocs.io/en/stable/Template/)
* [ApplicationSet Pr example](https://dev.to/camptocamp-ops/using-argocd-pull-request-generator-to-review-application-modifications-236e)
- [ApplicationSet](https://argocd-applicationset.readthedocs.io/en/stable/)
- [ApplicationSet Generators](https://argocd-applicationset.readthedocs.io/en/stable/Generators/)
- [ApplicationSet Templates](https://argocd-applicationset.readthedocs.io/en/stable/Template/)
- [ApplicationSet Pr example](https://dev.to/camptocamp-ops/using-argocd-pull-request-generator-to-review-application-modifications-236e)
Loading