Skip to content

Commit f90dbf1

Browse files
committed
Added ArgoCD tutorial
1 parent 4129042 commit f90dbf1

27 files changed

+337
-1
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
---
2+
id: index-argocd
3+
title: 'ArgoCD: What It Is And Why It Should Be Part of Your Redis CI-CD Pipeline'
4+
sidebar_label: Redis using ArgoCD
5+
slug: /operate/continuous-integration-continuous-deployment/argocd
6+
authors: [ajeet,talon]
7+
---
8+
9+
## What is an Argo CD?
10+
11+
Argo CD is a combination of the two terms “Argo” and “CD,” [Argo](https://argoproj.github.io/) being an open source container-native workflow engine for Kubernetes. It is a [CNCF-hosted project](https://www.cncf.io/blog/2020/04/07/toc-welcomes-argo-into-the-cncf-incubator/) that provides an easy way to combine all three modes of computing—services, workflows, and event-based—all of which are very useful for creating jobs and applications on Kubernetes. It is an engine that makes it easy to specify, schedule, and coordinate the running of complex workflows and applications on Kubernetes. The CD in the name refers to [continuous delivery](https://en.wikipedia.org/wiki/Continuous_delivery), which is an extension of continuous integration (CI) since it automatically deploys all code changes to a testing and/or production environment after the build stage.
12+
13+
![preview image](images/argo_preview1.png)
14+
15+
Argo CD follows [GitOps methodology](https://about.gitlab.com/topics/gitops/). GitOps is a CD methodology centered around using [Git as a single source of truth](https://git-scm.com/) for declarative infrastructure and application code. It watches a remote Git repository for new or updated manifest files and synchronizes those changes with the cluster. By managing manifests in Git and syncing them with the cluster, you get all the advantages of a Git-based workflow (version control, pull-request reviews, transparency in collaboration, etc.) and a one-to-one mapping between what is in the Git repo and what is deployed in the cluster.
16+
17+
Argo CD empowers organizations to declaratively build and run cloud native applications and workflows on Kubernetes using GitOps. It is a pull-based, declarative, GitOps continuous delivery tool for Kubernetes with a[ fully loaded UI](https://github.com/argoproj/argo-cd/tree/master/ui). The tool reads your environment configuration from your Git repository and applies it to your Kubernetes namespaces. App definitions, environment, and configurations should be declarative and version controlled. App deployment and life cycle management should be automated, audible, and easy to understand.
18+
19+
Built specifically to make the continuous deployment process to a Kubernetes cluster simpler and more efficient, Argo CD solves multiple challenges, such as the need to set up and install additional tools outside of Jenkins for a complete CI/CD process to Kubernetes, the need to configure access control to Kubernetes in and out (including cloud platforms), the need to have visibility of deployment status once a new app gets pushed to a Kubernetes cluster, and more.
20+
21+
Please note that Argo CD isn’t just deployed inside of Kubernetes but should be looked at as an extension of Kubernetes as it uses existing Kubernetes resources and functionalities like etcd and controllers to store data and monitor real-time updates of application state.
22+
23+
24+
## How does Argo CD work?
25+
26+
27+
28+
29+
![how argocd work](images/argocd_2.png "image_tooltip")
30+
31+
32+
It solves the problems above in the CD process by being a more integral part of the Kubernetes cluster. Instead of pushing changes to the Kubernetes cluster, Argo CD pulls Kubernetes manifest changes and applies them to the cluster. Once you set up Argo CD inside of your Kubernetes cluster, you configure Argo CD to connect and track your Git repo changes.
33+
34+
If any changes are detected, then Argo CD applies those changes automatically to the cluster. Now developers can commit code (for example, Jenkins), which will automatically build a new image, push it to the docker repo, and then finally update the Kubernetes manifest file that will be automatically pulled by Argo CD, ultimately saving manual work, reducing the initial setup configuration, and eliminating security risks. But what about DevOps teams making other changes to the application configuration? Whatever manifest files connected to the Git repo will be tracked and synced by Argo CD and pulled into the Kubernetes cluster, providing a single flexible deployment tool for developers and DevOps.
35+
36+
Argo CD watches the changes in the cluster as well, which becomes important if someone updates the cluster manually. Argo CD will detect the divergence of states between the cluster and Git repo. Argo CD compares desired configuration in the Git repo with the actual state in the Kubernetes cluster and syncs what is defined in the Git repo to the cluster, overriding whatever update was done manually—guaranteeing that the Git repo remains the single source of truth. But, of course, Argo CD is flexible enough to be configured to not automatically override manual updates if a quick update needs to happen directly to the cluster and an alert be sent instead.
37+
38+
39+
## **What are Argo CD’s capabilities?**
40+
41+
- Argo CD is a very simple and efficient way to have declarative and version-controlled application deployments with its automatic monitoring and pulling of manifest changes in the Git repo, but it also has easy rollback and reverts to the previous state, not manually reverting every update in the cluster.
42+
43+
- It also provides automation and traceability via GitOps workflow with a web UI for visualizing Kubernetes resources.
44+
45+
- Argo CD defines Kubernetes manifests in different ways: it supports Kubernetes YAML files, Helm Charts, Kustomize, and other template files that generate Kubernetes manifests. \
46+
47+
- Argo CD also has a command-line interface application, a Grafana metrics dashboard, and audit trails for application events and API calls.
48+
49+
- Argo CD has a very simple cluster disaster recovery process whereby pointing a new cluster to the Git repo if a cluster has gone down will automatically recreate the same exact state without any intervention because of its declarative nature.
50+
51+
- Kubernetes cluster access control with Git and Argo CD is simple—you can configure who can commit merge requests and who can actually approve those merge requests, providing a clean way to manage cluster access indirectly via Git. There is also no need to give external access to other tools like Jenkins, keeping cluster credentials safe because Argo CD is already running in the cluster and is the only tool that actually applies changes.
52+
53+
54+
## Prerequisites:
55+
56+
57+
58+
* Install Docker Desktop
59+
* Enable Kubernetes
60+
* Install Argo CD
61+
62+
## Getting Started
63+
64+
65+
### Step 1. Install Argo CD
66+
67+
68+
69+
```
70+
brew install argocd
71+
```
72+
73+
74+
75+
### Step 2. Create a new namespace
76+
77+
Create a namespace argocd where all Argo CD resources will be installed.
78+
79+
80+
```
81+
kubectl create namespace argocd
82+
```
83+
84+
85+
86+
### Step 3. Install Argo CD resources
87+
88+
89+
```
90+
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
91+
92+
kubectl get po -n argocd
93+
NAME READY STATUS RESTARTS AGE
94+
argocd-application-controller-0 0/1 ContainerCreating 0 3m9s
95+
argocd-dex-server-65bf5f4fc7-5kjg6 0/1 Init:0/1 0 3m13s
96+
argocd-redis-d486999b7-929q9 0/1 ContainerCreating 0 3m13s
97+
argocd-repo-server-8465d84869-rpr9n 0/1 Init:0/1 0 3m12s
98+
argocd-server-87b47d787-gxwlb 0/1 ContainerCreating 0 3m11s
99+
```
100+
101+
102+
103+
### Step 4. Ensure that all Pods are up and running
104+
105+
106+
```
107+
kubectl get po -n argocd
108+
NAME READY STATUS RESTARTS AGE
109+
argocd-application-controller-0 1/1 Running 0 5m25s
110+
argocd-dex-server-65bf5f4fc7-5kjg6 1/1 Running 0 5m29s
111+
argocd-redis-d486999b7-929q9 1/1 Running 0 5m29s
112+
argocd-repo-server-8465d84869-rpr9n 1/1 Running 0 5m28s
113+
argocd-server-87b47d787-gxwlb 1/1 Running 0 5m27s
114+
```
115+
116+
117+
118+
### Step 5. Configure Port Forwarding for Dashboard Access
119+
120+
121+
```
122+
kubectl port-forward svc/argocd-server -n argocd 8080:443
123+
Forwarding from 127.0.0.1:8080 -> 8080
124+
Forwarding from [::1]:8080 -> 8080
125+
```
126+
127+
128+
![access argocd](images/argocd_3.png "image_tooltip")
129+
130+
131+
132+
### Step 6. Log in
133+
134+
135+
```
136+
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
137+
138+
HcD1I0XXXXXQVrq-
139+
```
140+
141+
142+
![login](images/argocd_4.png "image_tooltip")
143+
144+
145+
146+
### Step 7. Install Argo CD CLI on Mac using Homebrew
147+
148+
149+
```
150+
brew install argocd
151+
```
152+
153+
154+
155+
### Step 8. Access the Argo CD API Server
156+
157+
By default, the Argo CD API server is not exposed with an external IP. To access the API server, choose one of the following techniques to expose the Argo CD API server:
158+
159+
160+
```
161+
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
162+
service/argocd-server patched
163+
```
164+
165+
166+
167+
### Step 9. Log in to Argo CD
168+
169+
170+
```
171+
argocd login localhost
172+
WARNING: server certificate had error: x509: certificate signed by unknown authority. Proceed insecurely (y/n)? y
173+
Username: admin
174+
Password:
175+
'admin:login' logged in successfully
176+
Context 'localhost' updated
177+
```
178+
179+
180+
181+
### Step 10. Update the password
182+
183+
184+
```
185+
% argocd account update-password
186+
*** Enter password of currently logged in user (admin):
187+
*** Enter new password for user admin:
188+
*** Confirm new password for user admin:
189+
Password updated
190+
Context 'localhost' updated
191+
ajeetraina@Ajeets-MacBook-Pro ~ %
192+
```
193+
194+
195+
196+
### Step 11. Register a Cluster to Deploy Apps to
197+
198+
As we are running it on Docker Desktop, we will add it accordingly.
199+
200+
201+
```
202+
argocd cluster add docker-desktop
203+
WARNING: This will create a service account `argocd-manager` on the cluster referenced by context `docker-desktop` with full cluster level admin privileges. Do you want to continue [y/N]? y
204+
INFO[0002] ServiceAccount "argocd-manager" created in namespace "kube-system"
205+
INFO[0002] ClusterRole "argocd-manager-role" created
206+
INFO[0002] ClusterRoleBinding "argocd-manager-role-binding" created
207+
Cluster 'https://kubernetes.docker.internal:6443' added
208+
```
209+
210+
211+
212+
### Step 12. Create a New Redis application
213+
214+
Click “Create” and provide a repository URL as [https://github.com/argoproj/argo-cd/tree/master/manifests/base/redis](https://github.com/argoproj/argo-cd/tree/master/manifests/base/redis)
215+
216+
217+
![create new redis app](images/argocd_5.png "image_tooltip")
218+
219+
220+
221+
![arogocd app](images/argocd_6.png "image_tooltip")
222+
223+
224+
```
225+
argocd app list
226+
NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS REPO PATH TARGET
227+
redisdemo https://kubernetes.docker.internal:6443 argocd default Synced Healthy <none> <none> https://github.com/argoproj/argo-cd manifests/base/redis HEAD
228+
229+
230+
```
231+
232+
233+
![redisdemo app](images/argocd_7.png "image_tooltip")
234+
235+
236+
237+
![summary of the app](images/argocd_8.png "image_tooltip")
238+
239+
240+
241+
![health of the redisdemo app](images/argocd_10.png "image_tooltip")
242+
243+
244+
245+
### Step 13. Delete the Redis app
246+
247+
248+
```
249+
argocd app delete redisdemo
250+
```
251+
252+
253+
254+
#### Example: Voting App
255+
256+
257+
258+
Let’s try to deploy a voting app. The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client.
259+
260+
![voting app](images/argocd_21.png "image_tooltip")
261+
262+
263+
264+
265+
266+
* A Python web app which lets you vote between two options
267+
* A Redis queue which collects new votes
268+
* A .NET worker which consumes votes and stores them in …
269+
* A Postgres database backed by a Docker volume
270+
* A Node.js web app which shows the results of the voting in real time
271+
272+
Go to the Argo CD dashboard, enter the [repository URL](https://github.com/dockersamples/example-voting-app/tree/master/k8s-specifications), and supply the right PATH. Click “Create App” to deploy the application on your Docker Desktop.
273+
274+
275+
![enter the repo](images/argocd_11.png "image_tooltip")
276+
277+
278+
Next, visualize the complete application by choosing “Group by Node.”
279+
280+
281+
282+
283+
![votingapp status](images/argocd_12.png "image_tooltip")
284+
285+
286+
### Step 14. Grouping by Parent Resources
287+
288+
289+
290+
![parent resources and grouping](images/argocd_13.png "image_tooltip")
291+
292+
293+
Keep a close watch over the events by clicking on “Events” section.
294+
295+
296+
![events](images/argocd_14.png "image_tooltip")
297+
298+
299+
Below is the complete overview of the voting application.
300+
301+
302+
![overview](images/argocd_15.png "image_tooltip")
303+
304+
305+
Access the app via [http://localhost:31000/](http://localhost:31000/)
306+
307+
![access app](images/argocd_16.png "image_tooltip")
308+
309+
310+
The results are accessible via [http://localhost:31001/](http://localhost:31001/)
311+
312+
![results](images/argocd_17.png "image_tooltip")
313+
314+
315+
### Additional References:
316+
317+
318+
319+
- [https://argo-cd.readthedocs.io/en/stable/](https://argo-cd.readthedocs.io/en/stable/)
320+
- [https://github.com/argoproj/argo-cd](https://github.com/argoproj/argo-cd)
321+
- [https://blog.argoproj.io/doing-gitops-at-scale-6313f5889775](https://blog.argoproj.io/doing-gitops-at-scale-6313f5889775)

docs/operate/continuous-integration-continuous-deployment/index-continuous-integration-continuous-deployment.mdx

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ The following links provides you with the available options to embed Redis into
1818
description="Learn how to deploy Redis Enterprise Database from a Jenkins Pipeline"
1919
page="/operate/continuous-integration-continuous-deployment/jenkins"
2020
/>
21+
</div>
22+
23+
<div class="col">
24+
<RedisCard
25+
title="ArgoCD - What It Is And Why It Should Be Part of Your Redis CI-CD Pipeline"
26+
description="Learn about ArgoCD and implement voting app using Redis"
27+
page="/operate/continuous-integration-continuous-deployment/argocd"
28+
/>
2129
</div>
2230

2331
</div>

docusaurus.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ module.exports = {
3131
title: 'Developer Growth Manager at Redis',
3232
image: 'profile_pic_ajeet_raina.jpg'
3333
},
34+
talon: {
35+
name: 'Talon Miller',
36+
link: 'https://www.linkedin.com/in/talon-miller-005054109/',
37+
title: 'Technical Product Marketing Manager at Redis',
38+
image: 'profile_pic_talon_miller.jpg'
39+
},
3440
alex: {
3541
name: 'Alex Mikhalev',
3642
link: 'https://www.linkedin.com/in/alexmikhalev',

sidebars.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ module.exports = {
340340
items: [
341341
'operate/continuous-integration-continuous-deployment/index-continuous-integration-continuous-deployment',
342342
'operate/continuous-integration-continuous-deployment/jenkins/index-jenkins',
343-
]
343+
'operate/continuous-integration-continuous-deployment/argocd/index-argocd',
344+
]
344345
},
345346
{
346347
type: 'category',
43.4 KB
Loading

0 commit comments

Comments
 (0)