Try GitOps on your laptop
Mohamed Elnaggar
Telco Cloud Tech Lead @ Cisco (NFV | CNF/VNF |Openstack | Kubernetes | Automation | IP | SDN)
In this article, I share my basic experience about how to connect Github, ArgoCD and Openshift, and deploy a helm chart application using this GitOps model.
This Lab covers some basics of the GitOps tools, of course it seems basic for DevOps Gurus, but for me it is a good approach to understand in a practical way how these DevOps tools (islands) connect to each other and how cool is it to work with these tools. So I decided to share what I've done after playing around with these tools :). Let's start.
The main goal of this LAB is to deploy an application and check the changes happen on Openshift when an update happens to the app code on GitHub.
The main tools to use are:
Redhat Openshift Local, Helm Chart, ArgoCD and GitHub
Install Red?Hat OpenShift Local (formerly Red Hat CodeReady Containers)
Follow these easy steps to setup Openshift Locally on your machine https://access.redhat.com/documentation/en-us/red_hat_openshift_local/2.5/html/getting_started_guide/installation_gsg#doc-wrapper ?
Install Helm on your machine (Optional)
Only to get familiar with helm and create test helm charts to use later https://helm.sh/docs/intro/install/
Prepare GitHub repository
Install ArgoCD on OCP
oc create namespace argocd
oc apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
Due to some issues with privileges, download the install.yaml file first and search for below lines and remove them, then apply the file to install the ArgoCD
wget https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
vi install.yaml
remove "securityContext:" and the two lines below
Save the file and run
oc apply -f install.yaml
oc get pods -n argocd??
oc -n argocd patch deployment argocd-server -p '{"spec":{"template":{"spec":{"$setElementOrder/containers":[{"name":"argocd-server"}],"containers":[{"command":["argocd-server","--insecure","--staticassets","/shared/app"],"name":"argocd-server"}]}}}}
oc -n argocd create route edge argocd-server --service=argocd-server --port=http --insecure-policy=Redirect'?
领英推荐
Username: admin
oc -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo?
Link ArgoCD with GitHub and create an application
From UI, click on new App and fill below fields
Application Name: <app-name>
Project Name: default
SOURCE
Repository URL: <Github repo link>?
????????????????To get the repo link, make sure you click on the repo name on Github, click on the green button on the right named "code", then copy the HTTPS URL
Revision: HEAD
Path: <path to folder holding files>
DESTINATION:
Cluster URL: Change the drop down menu from URL to NAME, then write "in-cluster"
Namespace: <namespace on openshift cluster>
Click on CREATE and enjoy playing with Git and ArgoCD
I hope it was informative to you.
Your feedback will be more than appreciated.
Thanks
Enjoy :)