🟢 The website is running in localhost. To update and push the changes in the server, I have Jenkins for CI and argoCD for CD.
🟢 As soon as the code repo updated, jenkins job will start executing, pull repo, build docker image, push image to docker with new build number and also update the deployment.yaml file in deployment github repository which argoCD will use for kubernetes deployment.
🟢 The deployment.yaml file in "go-jenkins-argocd-deployment" repository also got updated by jenkins.
🟢 The application is deployed on argoCD namespace in kubernetes. This is the previous version 1.0.0 which is running.
🟢 As soon as deployment.yaml file got updated with new image tag 14, argoCD will sync, pull image from dockerhub and deploy new updated container based on the image build number 14.Therefore, version 3.1.2 is now being servered by argoCD and service file is doing the load balancing and inside each container nginx is doing reverse proxy.
- EC2: To connect using aws ec2 instances, first check if "etc/ssh/sshd_config -> PasswordAuthentication yes", incase it is set to no then change it to yes otherwise using putty you cant connet to the ec2 instances.
- Jenkins: Install java runtime environment. For Jenkins installing follow https://www.jenkins.io/doc/book/installing/linux/.
- ArgoCD: For argocd installation follow
🎯 In summary, Updating code and pushing it to git repository will trigger the webhook, jenkins will pull the updated code repo in the project workspace and execute necessary shell comands for port and running the website.
- Css and static files were not being served. Solution: Make sure to get and set working directory is the executables directory and then use relative path in your code. (os.Chdir(exeDir), templates/index.html, static/styles.css etc)
- Jenkins issues: sudo usermod -aG docker $username, for example "sudo usermod -aG docker jenkins" and "newgrp docker". And reboot the server. so jenkins will be able to access docker comands. Use t2.small, the t2.micro stuck in the dokcer build stage.