Mastering CICD with GitOps guide
Introduction
Welcome to our comprehensive guide on setting up automated deployment using GitOps principles. In this tutorial, you will learn how to leverage MicroK8s, ArgoCD, Helm Charts, Docker, and GitHub Actions to automate the deployment of a Node.js application in a Kubernetes environment. Follow along to streamline your CI/CD pipeline and enhance your DevOps skills.
Key Skills and Technologies
By following this guide, you'll enhance your skills in the following areas:
- CI/CD Automation: Leveraging GitHub Actions to automate your build and deployment processes.
- Kubernetes Management: Using MicroK8s to manage your Kubernetes clusters efficiently.
- GitOps: Implementing GitOps principles with ArgoCD for continuous deployment.
- Helm Charts: Creating and managing Helm charts for application deployment.
- Docker: Building and pushing Docker images to DockerHub.
- Node.js Deployment: Deploying Node.js applications in a cloud-native environment.
Step-by-Step Guide to Automated Deployment
1. Prerequisites
Ensure you have the following installed and configured:
- MicroK8s: A lightweight Kubernetes distribution.
- Docker: For containerizing your Node.js application.
- ArgoCD: A declarative, GitOps continuous delivery tool for Kubernetes.
- Node.js: Your application code.
- GitHub: A repository to store your code and workflows.
2. Clone the Repository
Start by cloning your repository from GitHub:
git clone <repo_url>
Add the necessary code from the provided repository: Node.js Application Repository.
3. GitHub Actions Workflow for CI/CD Automation
Set up a GitHub Actions workflow to automate the build, push, and Helm chart update process:
- Check out the code from your repository.
- Log in to DockerHub using credentials stored in GitHub Secrets.
- Build and push the Docker image to DockerHub.
- Update the Helm chart with the new Docker image tag.
- Commit and push the updated Helm chart back to the repository.
4. Create and Configure Helm Chart
Create a Helm chart for your application:
helm create <chart_name>
Update the values.yaml file with your Docker image details:
replicaCount: 1
image:
repository: <your_dockerhub_username>/node-app
pullPolicy: IfNotPresent
tag: ""
service:
type: ClusterIP
port: 3000
targetPort: 3000
5. Deploy with ArgoCD
Configure ArgoCD to monitor your repository and automatically deploy changes:
- Provide the repository URL and path to the Helm chart in ArgoCD.
- Enable automatic sync to detect and apply changes.
6. Verify Deployment
Verify your deployment using the following commands:
kubectl get pods -n <namespace>
kubectl get svc
If needed, use port forwarding for local access:
kubectl port-forward svc/<service_name> <local_port>:3000
7. Using NodePort for Accessing Services
In addition to deploying your application with ArgoCD, you can also expose your services using NodePort for direct access:
1. Expose Service with NodePort
To expose a Kubernetes service externally via NodePort:
kubectl expose deployment <deployment_name> --type=NodePort --port=3000 --target-port=3000
This command exposes the service on a static port on each Node in the cluster.
2. Access Service
Once exposed, you can access your service using any Node's IP address and the allocated NodePort:
http://<node_ip>:<node_port>
Replace `
Conclusion
In this guide, you've learned how to automate deployment using GitOps with MicroK8s, ArgoCD, Helm Charts, Docker, and GitHub Actions. By integrating these tools, you've streamlined CI/CD pipelines, enhanced Kubernetes management, and implemented effective GitOps practices for continuous deployment. Now equipped with these skills, you can confidently automate and scale your deployments, ensuring efficient and reliable application delivery in cloud-native environments.
Vijay Kumar A
LinkedIn Profile: https://www.linkedin.com/in/vijaykumara01/

Comments
Post a Comment