Files
workshops/data/app-delivery/exercise7.mdx

91 lines
3.6 KiB
Plaintext

---
title: Optional - Deploying an application via gitops
exercise: 7
date: '2024-07-25'
tags: ['openshift','containers','kubernetes','argocd','gitops']
draft: false
authors: ['default']
summary: "Keen to explore a more advanced deployment pattern?"
---
Now that you've had a taste of most of the more basic deployment methods let's introduce the concept of [GitOps](https://www.redhat.com/en/topics/devops/what-is-gitops) and deploy an application using this more advanced approach.
In simple terms GitOps uses Git repositories as a single source of truth to deliver applications or infrastructure as code. Whenever you merge or push code into a specifc Git branch in a repository, an GitOps continuous delivery tool such as [ArgoCD](https://argo-cd.readthedocs.io/en/stable) can then automatically sync that to one or more Kubernetes clusters.
<Zoom>
|![argocd](/static/images/argocd-ui.gif) |
|:-------------------------------------------------------------------:|
| *ArgoCD user interface* |
</Zoom>
For many organisations GitOps is a goal deployment methodology as application definitions, configurations, and environments should ideally be declarative and version controlled. Application deployment and lifecycle management should be automated, auditable, and easy to understand.
Since 2021 OpenShift has included a fully supported [OpenShift GitOps](https://www.redhat.com/en/blog/announcing-openshift-gitops) operator, based on the upstream ArgoCD project.
This operator has already been installed on your cluster so let's take it for a spin now! 🚀
## 7.1 - Deploy openshift gitops
To get started with OpenShift GitOps we will need an instance of ArgoCD deployed.
Click the **+** button in the top right corner menu bar of the OpenShift web console. This is a fast way to quickly import snippets of YAML for testing or exploration purposes.
Paste the below snippet of YAML into the editor and replace the instance of `userX` with your assigned user.
Click **Create**. In a minute or so you should see the ArgoCD instance running successfully in your project.
```bash
apiVersion: argoproj.io/v1beta1
kind: ArgoCD
metadata:
finalizers:
- argoproj.io/finalizer
name: argocd
namespace: userX
spec:
rbac:
defaultPolicy: role:admin
scopes: '[groups]'
server:
route:
enabled: true
sso:
dex:
openShiftOAuth: true
provider: dex
```
## 7.2 Login to argocd
With ArgoCD running let's open the route in a new tab in our browser and click **Log in with OpenShift**. You can retrieve the ~Route~ by running the following command in your web terminal:
```bash
oc get route argocd-server
```
<Zoom>
|![argocd login](/static/images/argocd-login.png) |
|:-------------------------------------------------------------------:|
| *ArgoCD login* |
</Zoom>
## 7.3 Deploy an application
Now that you're logged into ArgoCD, have a go at creating a new `Application` using the ArgoCD web interface by clicking **+ New App**. The workload we'll deploy is a new mission critical training simulator called "Quake 3 Arena".
Use the following values for your Application:
|Field|Value|
|-----|-----|
|Name |`quake`|
|Project|`default`|
|Repository URL|`https://github.com/jmhbnz/workshops`|
|Path|`data/app-delivery`|
|Cluster URL| `https://kubernetes.default.svc`|
|Namespace|`userX`|
## 7.4 Access the mission critical simulator - challenge
Your final challenge for this exercise is to access the mission critical training simulator by creating a `Route`.