Skip to content

CoalChris/Spring-Boot-Maven-Test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

Spring-Boot-Maven-Test

This is a barebones Spring Boot project testing structural interdependencies among parent, child and sibling (Java) Maven modules, and migrating them to cloud hosting using Kubernetes.

To re-create the process:

  1. Clone the entire project: https://github.com/CoalChris/Spring-Boot-Maven-Test.git
  2. Modify the deployment.yaml, service.yaml files in "[service]/k8s" folder and "[service]/src/resources/application.properties" file to reflect desired ports and versions.
  3. To re-compile the code and output the required JAR library, run Maven command with goals "clean package"
  4. Upload to GitHub

For this project, we will migrate to Google Cloud Platform, but feel free to use another cloud services provider.

  1. Create a Google Cloud Platform project
  2. Enable Kubernetes Engine
  3. Create a Kubernetes Cluster and assign it with 1 or more compute engines / nodes
  4. Open Cloud Shell console for the project (You may have to copy the given command to connect the console to your project)
  5. Clone your repository from GitHub

For each service, move to the main directory of the service (e.g. "name-service" folder) and execute the following commands:

  1. This will build your Docker image, using Dockerfile, for containers to run on: "docker build -t gcr.io/[your-Google-Cloud-Platform-project-name]/[service]:[version-numbers] ."
  2. Push the Docker image to the Docker Hub registry: "docker push gcr.io/[your-Google-Cloud-Platform-project-name]/[service]:[version-numbers]"
  3. Move to "k8s" folder
  4. Create a Kubernetes pod: "kubectl create -f deployment.yaml". Check status: "kubectl get pods"
  5. Copy the NAME of the pod
  6. Create a Kubernetes service: "kubectl create -f service.yaml". Check status: "kubectl get svc"
  7. Make note of the service port number, between 30000 and 32767
  8. Install curl command in the container: "kubectl exec [pod-name] apk add curl"
  9. Check the service runs properly: "kubectl exec [pod-name] curl http://localhost:[port-number]". Default port is 8050 for name-service and 8051 for hello-service
  10. (Optional) If connection is failing, go to Google Cloud Platform main menu -> VPC Network -> Firewall Rules -> Create Firewall Rule. Add a name, ensure targets is set to "All instances in the network", IP ranges is "0.0.0.0/0" and the tcp port for your Kubernetes service should be allowed. Click the "Create" button
  11. Check your nodes' external IP address(es): "kubectl get nodes -o wide"
  12. Test that your service is accessible: "curl http://[node-external-ip]:[service-port-number]"
  13. Test via browser by accessing the URL "http://[node-external-ip]:[service-port-number]"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published