2 ms·
Google Kubernetes Engine - How to deploy Spring Boot microservice Step 1: Create a project After the login goto "My First Project" and click on it. Step 2 :
by rahulwagh17 6y ago
Google Kubernetes Engine - How to deploy Spring Boot microservice
Step 1: Create a project
After the login goto "My First Project" and click on it.
Step 2 : Create Cluster
If you haven’t selected your project then please do select from “My First Project ” menu. After than navigate to “Kubernetes Engine” menu in the left hand side and then click on “Cluster“
Step 3: Push spring boot docker image to google container registry(gcr.io)
1- Download the google SDK from the ttps://cloud.google.com/sdk/docs/downloads-versioned-archives
2- Now you need to goto directory – google-cloud-sdk-294.0.0-linux-x86_64/google-cloud-sdk run the install.sh
$./install.sh
$ docker build -t gcr.io/jhooq-sprinboot-k8s-demo/jhooq-springboot:v1 .
$ docker push gcr.io/jhooq-sprinboot-k8s-demo/jhooq-springboot:v1
Step 4: Deploy the spring boot microservice inside kubernetes cluster
1– Connect to cloudshell. Click on the connect button for the cloudshell
2– Now we need to do kubectl deployment, use the following command for the creating the deployment
$ kubectl create deployment jhooq-springboot --image=gcr.io/jhooq-sprinboot-k8s-demo/jhooq-springboot:v1
deployment.apps/jhooq-springboot created
3- expose deployment on external IP
$ kubectl expose deployment jhooq-springboot --type=LoadBalancer --port 80 --target-port 8080
service/jhooq-springboot exposed
Find the external IP of service, so that you can access the spring boot microservice outside of the network
$ kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
jhooq-springboot LoadBalancer 10.64.8.231 34.72.142.92 80:32537/TCP 11m
kubernetes ClusterIP 10.64.0.1 <none> 443/TCP
Now you can access your rest end point with the external IP .i.e. http://34.72.142.92:80/hello http://34.72.142.92:80/hello