This project demonstrates a complete CI/CD pipeline for a simple Go application that prints "Hello World". The pipeline includes Docker containerization, Kubernetes deployment, and GitHub Actions for automated building and deployment.
src/main.go
: A simple Go application that prints "Hello World"src/main_test.go
: code to test the Go application.Dockerfile
: Instructions for building a Docker image of the Go applicationkubernetes/
:deployment.yaml
: Kubernetes Deployment configurationservice.yaml
: Kubernetes Service configuration
scripts/
:build.sh
: Shell script to build the Docker imagedeploy.sh
: Shell script to deploy to Kubernetes
.github/workflows/ci-cd.yml
: GitHub Actions workflow for CI/CD
- Docker Desktop (for local Docker engine and Kubernetes cluster)
- Go programming language
- kubectl CLI
- GitHub account
- DockerHub account
-
Build the Docker image: ./scripts/build.sh
-
Push the docker image to docker hub.
-
Deploy to local Kubernetes cluster: ./scripts/deploy.sh
The project uses GitHub Actions for continuous integration and deployment. The workflow consists of two main jobs:
- Build and Push: Builds the Docker image and pushes it to DockerHub.
- Deploy: Deploys the application to the local Kubernetes cluster using a self-hosted runner.
To use this pipeline:
- Set up a self-hosted runner on your local machine.
- Configure DockerHub credentials as GitHub secrets.
- Push changes to the main branch to trigger the workflow.
- Update the DockerHub repository in GitHub Actions workflow.
- Modify Kubernetes configurations in
kubernetes/
as needed. - Adjust GitHub Actions workflow in
.github/workflows/ci-cd.yml
for your specific requirement.