- Version:
0.1.0
- License:
MIT
// TODO
-
Learn how to deploy an app using GitOps approach
-
Learn how use Argo CD as a GitOps platform
-
Familiarity with Kubernetes
-
Basic notions on Node.js (JavaScript) programming language
-
Good understanding of YAML (Yet Another Markup Language)
This lab runs on any K8s cluster with few adjusts on the ingresses, we recommend using a free trial account on Google Cloud Platform. You can create one through this documentation. You can download and install the Google CLI gcloud
by checking this document.
In case you use a GCP account for this lab, we provided the Google Kubernetes Engine (GKE) recommended configuration below:
- GKE Configuration
Parameter | Value |
---|---|
GKE mode | Standard with static K8s version |
Location type | Zonal |
Release channel | None |
Kubernetes version | v1.24.6-gke.1500 |
Number of nodes | 3 |
Machine type | e2-medium |
Image type | cos_containerd |
- GKE cluster creation
You can create a K8s cluster for this lab with the following commands:
gcloud auth login
gcloud container clusters create gitops-sim --no-enable-autoupgrade --enable-service-externalips \
--enable-kubernetes-alpha --region=<your_closest_region> --cluster-version= v1.24.6-gke.1500 \
--machine-type=e2-medium --monitoring=NONE
- kubectl configuration
You can configure your local kubectl
environment and credentials with the following command:
gcloud container clusters get-credentials gitops-sim \
--zone <your_closest_zone> --project <your_project_id>
- Argo CD
Argo CD is installed through its default K8s manifest file located here.
- Node.js API app
There's a dummy Node.js API available as K8s manifest files here. It points to a public Docker image located at the Docker Hub.
image: rod4n4m1/node-api:0.1.2
- Folder contents:
argocd
File / folder | Description |
---|---|
deploy.sh | Automation script to deploy latest stable Argo CD release to a K8s cluster |
ingress.yaml | A K8s ingress for Argo CD in case one is needed |
install.sh | Automation script to create an Argo CD app and deploy the Node.js API using GitOps approach to a K8s cluster |
README.d | This file |
process.env | Example of environmental variables definition to configure the deploy.sh script |
- Install Argo CD
This automation script will deploy the latest stable Argo CD release to a K8s cluster under the argocd
namespace.
cd argo-cd
./install.sh
- More information here
-
Change environmental variables accordingly
-
File: process.env
#!/bin/bash
export ARGOCD_ADMIN_NAME="admin"
export APP_NAME="simple-node-api"
export APP_REPO_URL="https://github.com/kyndryl-open-source/gitops-app-examples.git"
export APP_REPO_PATH="simple-node-api"
- You can fork the above repository if you want to modify the application image and version. Under a
GitOps
approach, all changes to the application or infrastructure is made to the GitHub repository and not on the K8s cluster directly.
- Deploy a Simple Node.js API
This will deploy a K8s app as an Argo CD app to the cluster where it's running. An Argo CD app synchronizes with IaC and app manifest files in a GitHub repo.
cd argo-cd
./deploy.sh
- You can access the Argo CD console by checking the
LoadBalancer
service IP address:
kubectl get svc -n argocd
-
Open a browser with the following ULR:
http://<load_balancer_ip>
-
Log into the console using the
admin
username and its initial password -
The
deploy.sh
script have created an Argo CD app that synchronizes with a GitHub repo -
If you have forked the application repository, you can change the image and version, then resynchronize the Argo CD app