Create a basic application that you want to deploy using pipeline. We have created a go server, main.go and go.mod.
Now create a Dockerfile that will build the image and test it locally.
Create a new Jenkins image so that docker can work in it.
FROM jenkins/jenkins:lts
USER root
RUN apt-get update
RUN curl -sSL https://get.docker.com/ | sh
And run this image using the command
sudo docker run -p 8080:8080 -p 50000:50000 -v /var/run/docker.sock:/var/run/docker.sock go/jenkins:latest
go/jenkins:latest is the name of the built image in our case.
Setup Jenkins dashboard
Create a new Pipeline project in Jenkins and enable GitSCM polling to integrate with GitHub webhooks. Add the Jenkinsfile to the script to create the pipeline steps and initialize the pipeline.
Expose your localhost port 8080 which is running Jenkins to the internet using ngrok. ''' ngrok http 8080 ''' Verify the link provided if it is now accessible.
Go to your GitHub project of your application and in settings add a new webhook with the ngrok url and add '/github-webhook/' at the end of the url, enable webhook to run on pushes, PRs and commits.
Now startup minikube and install ArgoCD using the official documentation and create a new app that links to your other repo which will include all k8s config yaml files for GitOps.
Simply expose your service using the minikube official documentation. ''' minikube service pipeline-service --url '''