This is very basic/simple java-maven project for cicd environment and the purpose of the project is to showcase how to ship application from development to kubernetes environment using CICD.
Build and deploy locally using docker
-
mvn clean install -
docker build -t hello-world . -
docker run -d -p 8080:8080 --name hello-world hello-world -
Access the application on
localhost:8080
How to deploy on Kubernetes
- First create namesapce by applying yaml file
kubectl apply -f kubernetes/namespace.yaml - Then apply rest of the files from kubernetes folder using
kubectl apply -f kubernetes/ - Now check if everything is up and running on our namespace using
kubectl get all -n cicd-java-maven - And make sure our application pod is up and running
kubectl get pods -n cicd-java-maven
Ok, but how to access the application over browser ????
I assume you have either docker dekstop or kind cluster or minikube
-
We need to deploy the ingress-controller for that by applying the yaml file from this official documentation
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.2/deploy/static/provider/cloud/deploy.yaml -
Check everything is up and running on
kubectl get all -n ingress-nginxif everything is up and running then we are good to go. -
Now edit your hosts file from this location on Windows
C:\Windows\System32\drivers\etc\hostsand on Mac/Linuxsudo vim /etc/hostsand add the entry in it127.0.0.1 exmaple-test.com -
Access the application on browser
exmaple-test.comnow you should see our awesome project text.
If you like and want to extend our awesome application then please feel free to contribute :)