- Install the repo on your local by: git clone https://github.com/indervirbanipal/sample-springboot-app.git
- Import the project in Intellij as a gradle project.
- Go to command line (in app's home folder) and run: ./gradlew clean build
- Look for ./build/libs/sample-springboot-app.war which gets generated.
- The next step is to build a docker image. Do
docker images
to check the existing images on the system. - Run
sh dockerCreate.sh
to create the docker image. - You should see sample-springboot-app-image:latest under
docker images
. - Go to http://localhost:8080/ and enter paul_admin:123456 to see the app up and runnning.
- Go to Postman at http://localhost:8080/ to see the app up and running.
- Use
sh dockerPush.sh
to push to the repository you want to. - Use
docker image rm <image-id>
to remove the docker image from your local (see image-id fromdocker images
). - Use
sh dockerPull.sh
to pull the image from the repository you want from. - See the image pulled from repo using
docker images
.
- Install the required tools using
brew install kubectl
,brew cask install minikube
,brew cask install virtualbox
. - Run
minikube start
. - Run
minikube config set vm-driver virtualbox
. - Run
kubectl config use-context minikube
. - Run
kubectl cluster-info
. Make sure Kubernetes master is running at https://192.168.99.100:8443 . Checkout the url http://127.0.0.1:50413/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/#!/overview?namespace=default - Push the image to minikube using
docker save sample-springboot-app-image:latest | (eval $(minikube docker-env) && docker load)
- Create deployment
kubectl run sample-springboot-app-dep1 --image=sample-springboot-app-image:latest --image-pull-policy=IfNotPresent
. Then check usingkubectl get deployments
>> showssample-springboot-app-dep1
running. - Also, check through
kubectl get pods
. Check logs usingkubectl logs <pod name>
or just dokubectl get all
orkubectl get all -o wide
. - Expose the deployment as a service through
kubectl expose deployment sample-springboot-app-dep1 --port=8080 --type=LoadBalancer --name=sample-springboot-app-serv1
.service/sample-springboot-app-serv1
gets exposed. kubectl get services
should showsample-springboot-app-serv1
running.- Do minikube ip to check the IP and lets say you get 192.168.99.105. So, hit the url 192.168.99.105:30658
where 30658 is listed alongwith 8080 under
kubectl get services
for the current service. - Better way of managing distributed deployments - Helm! Install helm using
brew install kubernetes-helm
. Usekubectl config current-context
to check if the current context ishelm
. Install tiller usinghelm init --history-max 200
. - After tiller install, it can be verified by
kubectl get pods --namespace kube-system | grep tiller
. - Check the versions for the helm client and server using
helm version
.
- Use
helm install --name postgres1 stable/postgresql
to install local postgres pods. You can verify if they are in the same namespace as the spring boot app usingkubectl get pods --namespace default
.