A sample appliccation to demo CI/CD of an application with autoscaling using CirlceCI, ArgoCD and Kubernetes
.
Golang
📦netguruTask
📦.circleci
┗ 📜config.yml
┣ 📜deployment.yaml
┣ 📜.gitignore
┣ 📜Dockerfile
┣ 📜go.mod
┣ 📜main_test.go
┣ 📜main.go
┣ 📜README.md
- .circleci: Contains configuration for deployment
git clone https://github.com/{github_username}/netguruTask.git
The App is deployed on the main
branch you will need to checkout to the app branch using:
git checkout main
- To run the CI part of the application you will need to link your repository with CircleCI by creating an account and connecting your repo.
- To add the environment variables. Click on Dashboard, Select your pipeline, on the far right of your screen go to Project Settings -> Environment variables. Add
DOCKER_PASSWORD
,DOCKER_USERNAME
andGITHUB_PERSONAL_TOKEN
. - Update the .circleci/config.yml from line 32 to line 53 to reflect yur changes and your docker image.
- Update deployment.yaml on line 39 of the CI part and line 39 of the CD task to reflect your container image
- Run the the application using
go run main.go
- In your browser, navigate to
http://localhost:3000/
-
- Create the Docker image
docker build -t your-username/appdemo:v1 .
Example
docker build -t adefemi171/appdemo:v1 .
-
Run the docker file
docker run -p 3000:3000 --name appdemo: YOURNAME/appdemo:v1
Example
docker run -p 3000:3000 --name appdemo adefemi171/appdemo:v1
-
To confirm if your container was built, run:
docker ps -a
-
View the image in your localhost port 8888 by typing
localhost:3000
in your browser
- Once you have successfully installed ArgoCD and all neccessary components
- Link your projects with the repository as stated here
- Create a new application as stated here
- Once your application is created and synced, check to see if you have your pods running by using the command
kubectl get po --all-namespaces
You should see a pod called app-demo-deployment-**** 5. Get the current svc that the application is running on by using
kubectl get svc --all-namespaces
- Do a port forward to be able to access the container o your browser, run
kubectl port-forward svc/app-demo -n app-demo 3000:3000
And visit the endpoint in your browser as specified above
Note: app-demo can be any name you gave your service in the deployment.yaml file.
NOTE: Docker, Golang, and Kubernetes needs to be installed to run this application