This guide walks you through deploying a Node.js application using Minikube and Argo CD, leveraging the GitOps methodology. By the end of this tutorial, you'll have a solid understanding of deploying applications on Kubernetes with automatic syncing through Argo CD.
Before you start, make sure you have the following installed on your local machine:
- Docker 🐳
- Minikube 🚤
- kubectl 🛠️
- Argo CD CLI 🖥️
- Git 🌿
Start your Minikube environment. This is your local Kubernetes cluster, ideal for development and testing.
minikube startEnable necessary Minikube addons like the dashboard and ingress to enhance functionality.
minikube addons enable dashboard
minikube addons enable ingressInstall Argo CD on your Minikube cluster using kubectl:
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yamlUse port forwarding to access the Argo CD UI through the Minikube IP:
kubectl port-forward svc/argocd-server -n argocd 8080:443Login Details:
-
Username: admin
-
Password: Retrieve the password using:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 --decode; echo
Create a repository to store your Kubernetes YAML files. This repository will be used by Argo CD to sync your application's state.
- Create a new repository on GitHub.
- Clone your repository:
git clone https://github.com/EzioDEVio/GitOps-ArgoCD-Deployment.git
cd GitOps-ArgoCD-DeploymentCreate deployment.yaml and service.yaml under a deployments directory in your repo, see my other repo for more deep dive and details on how to deploy kubernetes cluster with yaml files manifsts:
Example:
deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 1
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: yourusername/yourapp:latest
ports:
- containerPort: 3000service.yaml:
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
type: NodePort
ports:
- port: 3000
targetPort: 3000
nodePort: 30001
selector:
app: myappgit add .
git commit -m "Add Kubernetes deployment manifests"
git pushCreate an Argo CD application linked to your GitHub repository:
argocd app create myapp \
--repo https://github.com/yourusername/yourrepository.git \
--path deployments \
--dest-server https://kubernetes.default.svc \
--dest-namespace defaultManually sync your application from the Argo CD dashboard, or use the CLI:
argocd app sync myappCheck the deployment status in Argo CD or by using kubectl:
kubectl get allkubectl get pods -n argocd
kubectl port-forward svc/argocd-server -n argocd 8080:443
https://localhost:8080
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 --decode; echo
argocd login localhost:8080 --username admin --password <the password from the step above> --insecure
minikube service myapp-service --url -n default
minikube service myapp-service --url -n default http://127.0.0.1:58325 ❗ Because you are using a Docker driver on windows, the terminal needs to be open to run it.
The following url will be the app you deployed to ArgoCD: http://127.0.0.1:58325
Check if the service is up and NodePort is correctly mapped. Ensure your firewall or network settings are not blocking the connection. Pods Not Starting: If pods are in a pending or error state:
kubectl get pods -n default
kubectl describe pod <pod-name> -n default
Verify Minikube's network settings and ensure the tunnel is running if using minikube service. Resource Usage Monitoring: Monitor resource usage to ensure the application is not consuming excessive resources:
kubectl top pod <pod-name> -n default
Always ensure your Kubernetes environment and tools are up to date. Backup important data and configurations regularly. Feedback and Contributions Feedback and contributions to this project are welcome. Please open an issue or pull request in the GitHub repository.
You now have a Node.js application running on Kubernetes, managed via Argo CD using GitOps principles. This setup exemplifies a modern CI/CD pipeline that is scalable, manageable, and transparent.
- Customization: You may need to replace placeholders (like
your-username/your-repo) with actual values relevant to your project. - Repository Links: Adjust links to match the actual URLs where your code and Docker images are hosted.
- ArgoCD Configuration Details: This README assumes ArgoCD is already configured and operational within the cluster. If this is not the case, you might need to include setup details or refer to official ArgoCD documentation for initial setup instructions.
This README.md provides a comprehensive guide that not only helps users understand how to get the application running but also how to manage deployments through a GitOps workflow using ArgoCD.