diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..b882d76 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,6 @@ +{ + "MD013": false, + "MD033": { + "allowed_elements": ["details", "summary"] + } +} \ No newline at end of file diff --git a/README.md b/README.md index d0c242a..c1a05e5 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. @@ -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 +* +* diff --git a/app-of-apps.md b/app-of-apps.md index 56c0ae8..57c8870 100644 --- a/app-of-apps.md +++ b/app-of-apps.md @@ -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
More Details -* 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 @@ -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`. @@ -112,19 +111,19 @@ spec: prune: true selfHeal: true ``` +
- 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: @@ -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 @@ -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. diff --git a/applicationsets.md b/applicationsets.md index 9c1a1de..c55378b 100644 --- a/applicationsets.md +++ b/applicationsets.md @@ -2,44 +2,44 @@ ## 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
More Details -#### 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 @@ -47,16 +47,16 @@ kubectl create secret generic --dry-run=client student--github-token -n ``` -* Edit the secret and replace `` with your number (student-X) +- Edit the secret and replace `` 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 @@ -80,12 +80,12 @@ spec: github: # The GitHub organization or user. owner: #e.g. eficode-academy - # The Github repository + # The GitHub repository repo: #Just the repository name e.g. argocd-katas. Not your entire URL - tokenRef: # your github token - secretName: student--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--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 @@ -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 - * `` with your github username - * `` with your git repo - * `` with your namespace - * `` with your number (student-X) - * `` 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 + - `` with your github username + - `` with your git repo + - `` with your namespace + - `` with your number (student-X) + - `` 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: @@ -207,41 +208,39 @@ Status: Events: ``` - #### 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 ``` -* Get your ingress hostname +- Get your ingress hostname ```bash kubectl get ingress -n ``` -* 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 @@ -251,7 +250,7 @@ kubectl get applications -n argocd ### Clean up -* Delete the applicationset +- Delete the applicationset ```bash kubectl delete -f applicationsets/pull-request.yaml @@ -259,7 +258,7 @@ 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) diff --git a/argocd-and-helm.md b/argocd-and-helm.md index 7b8440b..6499165 100644 --- a/argocd-and-helm.md +++ b/argocd-and-helm.md @@ -1,4 +1,4 @@ -# Exercise: Deploying helm charts with Bitnami +# Exercise: Deploying Helm charts with Bitnami ## Learning Goals @@ -14,7 +14,6 @@ :bulb: Example ```yaml - apiVersion: argoproj.io/v1alpha1 kind: Application metadata: @@ -28,7 +27,7 @@ spec: destination: # The namespace the application should be deployed to. namespace: student-X - # Specify the name of the destination cluster, either name or server url. + # Specify the name of the destination cluster, either name or server URL. name: in-cluster # Define the synchronization policy for the Application. @@ -39,7 +38,7 @@ spec: sources: # Specify the repository URL for the Helm chart. - repoURL: 'https://charts.bitnami.com/bitnami' - # Specify the target revision of the helm repository. + # Specify the target revision of the Helm repository. targetRevision: 12.4.0 # Specify the name of the Helm chart as "Jenkins". chart: jenkins @@ -55,8 +54,8 @@ spec: targetRevision: main # name this source "values" for reference in the above source. ref: values - ``` +
## Exercise @@ -65,20 +64,20 @@ spec: In this exercise, you will: -- Deploy Jenkins in the ArgoCD UI using Bitnami Helm chart. +- Deploy Jenkins in the ArgoCD UI using the Bitnami Helm chart. - Change the source of the deployment file. - Write a multi-source deployment file. - Change the values in the deployment file for automatic changes to the Jenkins app. - -### Step by Step Instructions +### Step-by-Step Instructions
More Details ### Tasks -**Deploying Jenkins with Bitnami Helm** +#### Deploying Jenkins with Bitnami Helm + - Look into the repository site (Click `settings`, and then `repositories`) to see that a repository called `bitnami` with the URL `https://charts.bitnami.com/bitnami` is there. - Click on `Applications` in the navigation bar. - Click on `New App` to create a new application. @@ -87,7 +86,7 @@ In this exercise, you will: - **Project Name**: `default` - **Sync Policy**: `Automatic` - **Repository Type**: `Helm` - - **Repository URL**: https://charts.bitnami.com/bitnami (or select from the dropdown) + - **Repository URL**: (or select from the dropdown) - **Chart**: `Jenkins` - **Version**: `12.4.0` - **Cluster**: `in-cluster` or `https://kubernetes.default.svc` @@ -106,12 +105,13 @@ Under the helm parameters, you can see that there are a lot of parameters that c - Find the http nodeport by clicking on the `studentx-jenkins` service. - Access the Jenkins site by going to `http://:`. You can find the external node IP by running `kubectl get nodes -o wide`. -**Customizing the Jenkins deployment with a values file** +#### Customizing the Jenkins deployment with a values file + We will change the values of the Jenkins deployment by using a values file. This is useful when you want to keep your values in a separate file and not in the ArgoCD UI. - Look at the `values.yaml` file in the `jenkins` directory. You can see that the `service.type` is set to `NodePort`, and two other values. - Now find the manifest in the ArgoCD UI by clicking on `app details`. -- Change your manifest in ArgoCD in to use the `values.yaml` file by changing `source` to `sources` like the following: +- Change your manifest in ArgoCD to use the `values.yaml` file by changing `source` to `sources` like the following: ``` yaml project: default @@ -131,7 +131,8 @@ sources: targetRevision: main ref: values ``` -💡 Remember to add your own repo to the file as well, as seen on the bottom. Pay attention to formatting. + +💡 Remember to add your repo to the file as well, as seen at the bottom. Pay attention to formatting. - Click save. @@ -139,8 +140,6 @@ sources: > :bulb: It might also be that the application has a hard time syncing the new pod. You can try to delete the replica set and see if it works. If not, you can delete the application and try again. - - Try to change something in the `values.yaml` file, push it up, and see that the application is synced automatically. If you lack inspiration, you can change the `service.type` to `ClusterIP` and see that the service is now a ClusterIP service.
- diff --git a/examples/folder-structures/README.md b/examples/folder-structures/README.md index 57c3ff6..0198741 100644 --- a/examples/folder-structures/README.md +++ b/examples/folder-structures/README.md @@ -1 +1 @@ -Different ways of organizing your applications in ArgoCD +# Different ways of organizing your applications in ArgoCD diff --git a/examples/folder-structures/folder-per-env-helm-enabled/README.md b/examples/folder-structures/folder-per-env-helm-enabled/README.md index d5bf579..b83c605 100644 --- a/examples/folder-structures/folder-per-env-helm-enabled/README.md +++ b/examples/folder-structures/folder-per-env-helm-enabled/README.md @@ -2,10 +2,10 @@ Only one values file per environment. +## Pros -# Pros - only display what the developer really needs to touch +## Cons -# Cons -- blackbox for developers \ No newline at end of file +- blackbox for developers diff --git a/examples/folder-structures/folder-per-env/README.md b/examples/folder-structures/folder-per-env/README.md index 91660aa..150848e 100644 --- a/examples/folder-structures/folder-per-env/README.md +++ b/examples/folder-structures/folder-per-env/README.md @@ -3,10 +3,12 @@ An app manifest and a values file per application in the environment. Pros: + - Clear separation of environments - Easy to understand - Easy to get an overview of what is deployed where - - `tree . -L 2` gives a good overview + - `tree . -L 2` gives a good overview Cons: -- Application manifests are "bleeding" into dev environment \ No newline at end of file + +- Application manifests are "bleeding" into dev environment diff --git a/intro.md b/intro.md index ff6d710..a38c511 100644 --- a/intro.md +++ b/intro.md @@ -11,7 +11,7 @@ ## Introduction -In this exercise, you will be diving deeper into the management of applications using ArgoCD. +In this exercise, you will be diving deeper into the management of applications using ArgoCD. ## Exercise @@ -31,22 +31,21 @@ In this exercise, you will: - **Refresh**: This action updates the live view in ArgoCD with the current state of the cluster and the state of the git repo. It does not change any resources in the cluster. - **Sync**: This action deploys the desired state from the Git repository to the cluster. If there are differences between the Git repo and the cluster, Sync will make the necessary changes to align them. -### Step by Step Instructions +### Step-by-Step Instructions
More Details ### Tasks -**Updating the Application** +#### Updating the Application - -* In the terminal, type `kubectl get all` to see that even though we have made the application manifest, the application is not yet deployed to the cluster. -* In the ArgoCD UI, select your `quotes-flask` application. -* Click on `Refresh` and observe that the live view is updated, but the application state remains unchanged. -* Click on `Sync` and confirm with `Synchronize` to deploy the changes you made in the repository to the cluster. -* Notice how all the resources in the UI are now turning from yellow to green, indicating that the application is in a healthy state. -* In the terminal, type `kubectl get all` to see that the application is now deployed to the cluster. +- In the terminal, type `kubectl get all` to see that even though we have made the application manifest, the application is not yet deployed to the cluster. +- In the ArgoCD UI, select your `quotes-flask` application. +- Click on `Refresh` and observe that the live view is updated, but the application state remains unchanged. +- Click on `Sync` and confirm with `Synchronize` to deploy the changes you made in the repository to the cluster. +- Notice how all the resources in the UI are now turning from yellow to green, indicating that the application is in a healthy state. +- In the terminal, type `kubectl get all` to see that the application is now deployed to the cluster. ```bash NAME READY STATUS RESTARTS AGE @@ -70,63 +69,64 @@ replicaset.apps/frontend-6776498dd8 1 1 1 8m2s replicaset.apps/postgres-7bc8b45445 1 1 1 8m2s ``` +#### Using the Diff Feature in UI -**Using the Diff Feature in UI** - -* Make a change to the `quotes-flask` application in your GitHub repository in the file `quotes-flask/k8s/frontend-deployment.yaml` - * Change the replica count of the `frontend` deployment to `2`. - * Commit and push the changes to the repository. -* Go to the ArgoCD UI. - * Select the `quotes-flask` application and click on `Refresh`. This will update the live view in ArgoCD with the current state of the cluster. - * Click on `App Diff`. This will show the differences between the live application and the desired state in the Git repository. If the full diff is too long, you click on the `compact diff` button to see a summary of the changes. - * Click on `Sync` and confirm with `Synchronize` to deploy the changes you made in the repository to the cluster. +- Make a change to the `quotes-flask` application in your GitHub repository in the file `quotes-flask/k8s/frontend-deployment.yaml` + - Change the replica count of the `frontend` deployment to `2`. + - Commit and push the changes to the repository. +- Go to the ArgoCD UI. + - Select the `quotes-flask` application and click on `Refresh`. This will update the live view in ArgoCD with the current state of the cluster. + - Click on `App Diff`. This will show the differences between the live application and the desired state in the Git repository. If the full diff is too long, you click on the `compact diff` button to see a summary of the changes. + - Click on `Sync` and confirm with `Synchronize` to deploy the changes you made in the repository to the cluster. **Updating Replicas with `kubectl`** -* Use `kubectl` to scale the replicas of the `quotes-flask` application: +- Use `kubectl` to scale the replicas of the `quotes-flask` application: ```bash kubectl scale deployment frontend --replicas=3 ``` -* In the ArgoCD UI, notice that the application is now `OutOfSync` because the live state (3 replicas) differs from the desired state in the Git repository. +- In the ArgoCD UI, notice that the application is now `OutOfSync` because the live state (3 replicas) differs from the desired state in the Git repository. -> :bulb: This demonstrates the importance of maintaining a single source of truth. Manual changes can cause drift from the desired state. +> :bulb: This demonstrates the importance of maintaining a single source of truth. Manual changes can cause drift from the desired state. -**Rolling Back Changes** +#### Rolling Back Changes -* In the ArgoCD UI, select the `quotes-flask` application. -* Click on the `History and rollback` button. -* Choose a previous successful sync and click `Rollback` to revert the application to that state. +- In the ArgoCD UI, select the `quotes-flask` application. +- Click on the `History and rollback` button. +- Choose a previous successful sync and click `Rollback` to revert the application to that state. This can be handy as a quick way to revert changes that were made in error. However, it is not a replacement for a proper GitOps workflow. In a GitOps workflow, you would revert the changes in the Git repository and then sync the application in ArgoCD. In the later exercises, we will automate the sync process, making ArgCD revert the changes automatically. -**Testing Self-Heal Policy** +#### Testing Self-Heal Policy -* In the ArgoCD UI, select the `quotes-flask` application. -* Click on `app details`, scroll down to `sync policy` and enable Auto-Sync. -* Use `kubectl` to make a change to the `quotes-flask` application (e.g., scale the replicas to 4): +- In the ArgoCD UI, select the `quotes-flask` application. +- Click on `app details`, scroll down to `sync policy` and enable Auto-Sync. +- Use `kubectl` to make a change to the `quotes-flask` application (e.g., scale the replicas to 4): ```bash kubectl scale deployment frontend --replicas=4 ``` -* Verify that there are four replicas: +- Verify that there are four replicas: ```bash kubectl get pods ``` -* In the ArgoCD UI, notice that the application is now `OutOfSync` because the live state (4 replicas) differs from the desired state in the Git repository. -* In the ArgoCD UI, select the `quotes-flask` application. +- In the ArgoCD UI, notice that the application is now `OutOfSync` because the live state (4 replicas) differs from the desired state in the Git repository. -* Then enable the `Self Heal` section under `Sync Policy` and click on `Save`. +- In the ArgoCD UI, select the `quotes-flask` application. + +- Then enable the `Self Heal` section under `Sync Policy` and click on `Save`. Now, if you make a change to the application using `kubectl`, ArgoCD will automatically revert the change to the desired state defined in the Git repository. -* Use `kubectl` to see that ArgoCD has reverted the change: +- Use `kubectl` to see that ArgoCD has reverted the change: + ```bash kubectl get pods NAME READY STATUS RESTARTS AGE @@ -136,16 +136,16 @@ frontend-6776498dd8-zfw5l 1/1 Running 0 20h postgres-7bc8b45445-kshd8 1/1 Running 1 20h ``` -**Troubleshooting Faulty Manifests** +#### Troubleshooting Faulty Manifests -* Intentionally introduce an error in one of the Kubernetes manifests `.spec` part in your GitHub repository (e.g., a typo in a field name). -* Try to sync the application in ArgoCD. The sync will fail. -* In the ArgoCD UI, navigate to the `Events` tab under `app details` for the `quotes-flask` application. Here, you can see detailed error messages that will help you identify the issue. -* Fix the error in the manifest, commit, and push the changes to the repository. -* Sync the application again in ArgoCD. The sync should now succeed. +- Intentionally introduce an error in one of the Kubernetes manifests `.spec` part in your GitHub repository (e.g., a typo in a field name). +- Try to sync the application in ArgoCD. The sync will fail. +- In the ArgoCD UI, navigate to the `Events` tab under `app details` for the `quotes-flask` application. Here, you can see detailed error messages that will help you identify the issue. +- Fix the error in the manifest, commit, and push the changes to the repository. +- Sync the application again in ArgoCD. The sync should now succeed.
### Cleanup -Go ahead and delete the app in the ArgoCD UI. We will add it later as a true GitOps application +Go ahead and delete the app in the ArgoCD UI. We will add it later as a true GitOps application. diff --git a/projects.md b/projects.md index 8a848a6..24d2dc3 100644 --- a/projects.md +++ b/projects.md @@ -2,16 +2,15 @@ ## Learning Goals -- Introduction to the appproject manifest -- Examine the restrictions you can make with the appprojects +- Introduction to the app project manifest +- Examine the restrictions you can make with the app projects ## Introduction -Argo CD `projects` logically group applications for multiple teams, providing deployment restrictions to things like source repos, destination clusters/namespaces, resource definitions etc. -The default project that comes baked in to ArgoCD allows unrestricted deployments. +Argo CD `projects` logically group applications for multiple teams, providing deployment restrictions to things like source repos, destination clusters/namespaces, resource definitions, etc. +The default project that comes baked into ArgoCD allows unrestricted deployments. New projects should be created for team-specific access levels, managing source repos, destinations, and Kubernetes resource kinds. -Projects can be created with either Argo CD cli or declaratively. - +Projects can be created with either Argo CD CLI or declaratively. An `AppProject` is a custom resource definition (CRD) that defines a project in Argo CD. An example of an `AppProject` is shown below: @@ -37,15 +36,14 @@ We are going to try out restrictions with the `appproject` kind. We will apply a ### Overview -* create a project manifest -* apply the project manifest -* apply the application manifest that violates the restrictions -* choose selective sync to partially sync the application - +- Create a project manifest +- Apply the project manifest +- Apply the application manifest that violates the restrictions +- Choose selective sync to partially sync the application -### Step by step instructions +### Step-by-step instructions -**Create a project manifest** +#### Create a project manifest Look at the file [project.yaml](projects/project.yaml) in the projects folder. It looks like the following: @@ -71,9 +69,9 @@ spec: It is a simple project manifest that restricts the deployment to a specific namespace and restricts the deployment of `Role` resources. -- change the `name`, `spec.description` and `spec.destinations.namespace` fields to your student number +- Change the `name`, `spec.description`, and `spec.destinations.namespace` fields to your student number -**Apply the project manifest** +#### Apply the project manifest ```bash kubectl apply -f projects/project.yaml @@ -98,11 +96,12 @@ Go to the ArgoCD UI and see the project from there as well. - Click on `Settings` -> `Projects` and you should see the project there - Click on the project and see the details. Here you can see the different options that can be set for the project. -- Verify that the description reflects your student number as well, e.g `a project for student-0 to play with` +- Verify that the description reflects your student number as well, e.g, `a project for student-0 to play with` -**Apply the application manifest that violates the restrictions** +#### Apply the application manifest that violates the restrictions - Open the file [application.yaml](projects/application.yaml) in the projects folder. It looks like the following: + ```yaml apiVersion: argoproj.io/v1alpha1 kind: Application @@ -119,6 +118,7 @@ spec: server: 'https://kubernetes.default.svc' namespace: student-x # remember to change this to your namespace! ``` + - Change the `name`, `spec.project` and `spec.destination.namespace` fields to your student number. - Apply the application manifest @@ -131,7 +131,7 @@ kubectl apply -f projects/application.yaml The project restricts the deployment of `Role` resources, so the application will not be deployed successfully. -**Choose selective sync to partially sync the application** +#### Choose selective sync to partially sync the application - Click on the application in the UI - Click on `Sync` and in the list of resources, uncheck the `Role` resource @@ -140,11 +140,10 @@ The project restricts the deployment of `Role` resources, so the application wil ### Optional: Create an application outside your namespace If time permits, try to create an application that is deployed to a namespace that is not allowed by the project. -> **NOTE:** Don't do this by simply manipulating the destination of the application you just applied as that will -> potentially interfere with the other students exercises. - -What are the differences in the error messages, compared to the previous application? +> **NOTE:** Don't do this by simply manipulating the destination of the application you just applied, as that will +> potentially interfere with the other students' exercises. +What are the differences in the error messages compared to the previous application? ### Clean up @@ -153,4 +152,3 @@ To clean up the resources created in this exercise, run the following commands: ```bash kubectl delete -f projects ``` - diff --git a/sealed-secrets.md b/sealed-secrets.md index 948afb6..cc060e4 100644 --- a/sealed-secrets.md +++ b/sealed-secrets.md @@ -1,7 +1,8 @@ +# Sealed Secrets + * Make a new application manifest for the k8s raw manifest -* take the k8s manifest quotes flask -* look at the postgres secret -* seal the secret with kubeseal +* Take the k8s manifest quotes flask +* Look at the postgres secret +* Seal the secret with kubeseal * Apply the new sealed secret (add to your repo and push it to see that Argo fetches it) * See that everything still works -* diff --git a/setup.md b/setup.md index 75baff7..61073d2 100644 --- a/setup.md +++ b/setup.md @@ -17,22 +17,17 @@ In this exercise, you will be deploying the `quotes-flask` application using `ku ## Exercise ### Overview -In this exercise we are creating your own instance of this templated repository, connecting that to ArgoCD + +In this exercise, we are creating your instance of this templated repository, connecting that to ArgoCD - Creating an instance of the template repository - Access and familiarize with the ArgoCD UI. - Deploy your first application through the UI. -### Step by Step Instructions - -
-More Details - -### Overview - +### Step-by-Step Instructions
-:bulb: This requires git email and name to configured on your machine. If you have not done this, here are the commands to set it up +:bulb: This requires git email and name to be configured on your machine. If you have not done this, here are the commands to set it up You need to provide your email and name to git with the following commands. @@ -52,23 +47,23 @@ git config --global user.name ### Tasks -**Creating a repository from the template** +#### Creating a repository from the template -- Go to Code tab of this repository and click `Use this template` +- Go to the Code tab of this repository and click `Use this template` ![Use this template](img/template.png) -- Select your GitHub user as the owner and name the repository (f.x. argocd-katas-training). Leave the repo public for argo to be able to see it. +- Select your GitHub user as the owner and name the repository (f.x, argocd-katas-training). Leave the repo public for Argo to be able to see it. > :bulb: **From this point forward, all actions should be performed in the repository you just created, not the template repository** -**Exploring the ArgoCD UI** +#### Exploring the ArgoCD UI - Open a browser and navigate to the provided ArgoCD instance URL. - Log in using the provided credentials.
- 💡 if you are running this on your own, you can get them by running the following command: + 💡 If you are running this on your own, you can get them by running the following command: ``` bash kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d @@ -78,7 +73,7 @@ kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.pas - See that the main page shows a list of applications that are currently deployed in the cluster. It might not show any applications at the moment, but we will be deploying one in the next step. -- In the navigation bar, click on `Settings` to create a connection to your own repository. +- In the navigation bar, click on `Settings` to create a connection to your repository. - Click on `Repositories` and then `Connect Repo`. - Fill in the following details: - **Connection method**: `HTTPS` @@ -90,16 +85,14 @@ kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.pas ![alt](img/repository_synced.png) +#### Setting up your first application -**Setting up your first application** - -In order to do this, we first need to know our own namespace. We can do this by running the following command: +In order to do this, we first need to know our namespace. We can do this by running the following command: ``` bash kubectl config view --minify -o jsonpath='{..namespace}' ``` - - Click on `Applications` in the navigation bar to see the list of applications that are currently deployed in the cluster. - Click on `New App` to create a new application. - Fill in the following details: @@ -109,20 +102,17 @@ kubectl config view --minify -o jsonpath='{..namespace}' - **Repository URL**: `` - **Revision**: `HEAD` - **Path**: `quotes-flask/k8s` - - **Cluster**: `in-cluster` OR https://kubernetes.default.svc + - **Cluster**: `in-cluster` OR - **Namespace**: `` -![](img/app1.png) -![](img/app2.png) +![alt](img/app1.png) +![alt](img/app2.png) - Click on `Create`. - Head back to the main page and see that the application is now listed. ![alt](img/unsynced-app-overview.png) -The application is in a `OutOfSync` state. This is because we have not yet synced the application with the repository. We will do this in the next step. +The application is in an `OutOfSync` state. This is because we have not yet synced the application with the repository. We will do this in the next step.
- - - diff --git a/trainer/exercise-template.md b/trainer/exercise-template.md index 267dd06..c6fef9f 100644 --- a/trainer/exercise-template.md +++ b/trainer/exercise-template.md @@ -6,14 +6,14 @@ ## Introduction -Here you will provide the bare minimum of information people need to solve the exercise. +Here, you will provide the bare minimum of information people need to solve the exercise. ## Subsections You can have several subsections if needed.
-:bulb: If an explanaition becomes too long, the more detailed parts can be encapsulated in a drop down section +:bulb: If an explanation becomes too long, the more detailed parts can be encapsulated in a drop-down section
## Exercise @@ -22,14 +22,14 @@ You can have several subsections if needed. - In bullets, what are you going to solve as a student -### Step by step instructions +### Step-by-step instructions
More Details -**take the same bullet names as above and put them in to illustrate how far the student have gone** +#### Take the same bullet names as above and put them in to illustrate how far the student has gone -- all actions that you believe the student should do, should be in a bullet +- All actions that you believe the student should do should be in a bullet point > :bulb: Help can be illustrated with bulbs in order to make it easy to distinguish.