A Web App with ArgoCD
Table of Contents
I recently transformed a command line desktop application into a web app and successfully deployed it to Kubernetes. You can find the code here and run it locally with Docker, or deploy it via Helm or ArgoCD to your Kubernetes cluster.
Project Overview
I initially developed this application using GoLang with AI assistance, as detailed in a previous article- an approach which has since become normalised. I wanted to convert it into a web-based service with automated test, build, package and deployment with ArgoCD to Kubernetes. To manage costs, I conducted initial development locally and with GitHub’s free services.
Transition to the Web
From Command Line to Web Interface
The first challenge was migrating from a command line interface to a web-based interface. After evaluating net/http
, gin
, and echo
, I chose gin
for its simplicity and robust support. This required adapting the user options, license, and results interface to match web routes and API endpoints with gin
. I also had to refactor the error handling and tests to suit the new architecture.
Incorporating Visual Elements
To enhance user experience, I included images of the tarot cards, sourced from Wikipedia/Wikimedia Commons for public domain artwork. I made a tool to download these images for display in the application. One image didn’t fit the naming convention but I opted not to rename it- I am not a fan of special case ‘magic’ code. I also added functionality to show the cards upside down if they are returned reversed, and set a sans-serif font for a cleaner look.
Containerization and Deployment
Containerizing the Application
To run the application on Kubernetes, containerization was essential. I used colima
initially on Mac and updated the GitHub Actions pipeline to target Docker, dropping cross-platform binary builds. Updating the GitHub Actions workflow posed some challenges due to outdated actions, but I ultimately configured it to build the latest image on every push and tag it on manual release.
Helm Chart Creation
With a working Docker build, I proceeded to create a Helm
chart for deployment. After a brief review of the options for local (and cheaper!) Kubernetes development I chose Rancher Desktop for my test cluster as it seemed straightforward and supported AMD64 container images on Mac ARM. I installed metrics-server
, Prometheus
, and Grafana
with Helm, along with ArgoCD
. For my application’s Helm chart, helm create
provided a solid starting point, and I chose a node port for ingress, similar to the ArgoCD
demo ‘Guestbook’ deployment.
Managing Deployment with ArgoCD
Here I was using ArgoCD to install my Helm chart, which meant ironing out the kinks in my deployment with both at the same time. There was some pain due to the fact that I was developing in a private repo and so had to handle secrets and authorisation. I also hadn’t double checked running the GitHub build of my container locally with Docker… As isn’t unusual, this stage took by far the longest to get working correctly and I switched back from FROM:scratch to FROM:ALPINE temporarily at one point in order to debug.
Public Release
Once I achieved a working Helm deployment, I moved the code to a public repository, updating it to reflect the new location and remove the now-redundant secrets handling. You can now install it on your own cluster with a few commands using helm
or ArgoCD
.
Reflections
This project emphasizes:
- GitOps
- Automated testing
- Automated builds
It demonstrates a functional, albeit relatively bare-bones, web application built in Golang. While not intended for production use, it showcases the integration of various tools and technologies to deliver a user-interactive web service. License is AGPL so you need to make source code available to your users if you are distributing or serving it to others.