Skip to main content

Posts

Showing posts from October 23, 2019

How to Build and Deploy a Spring Boot Java application with Docker & Kubernetes

Pre-requisites: Install Docker client/server Install K8s cluster. In the K8s Master Node. git clone https://github.com/spring-guides/gs-spring-boot-docker cd gs-spring-boot-docker/complete ./mvnw install -e -X # This will create a .jar file in the newely created target directory. sudo docker build -t image-sb1 -f Dockerfile . sudo docker images sudo docker tag image-sb1 trow.kube-public:31000/myrepo # Tag the new image with your private registry (Optional) sudo docker push trow.kube-public:31000/myrepo  # Push the new image to your local private registry (Optional) kubectl run image-sb --image=trow.kube-public:31000/myrepo --port=8080 kubectl expose deployment/image-sb --type="NodePort" --port 8080 Testing: ---------------------------------------------------------------------- ubuntu@namenode:~$ kubectl get svc NAME          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE kubernetes    ClusterIP   10.96.0.1                443/TCP