This project was generated using Spring initializr
This demo demonstrates how to quickly get a spring boot application up and running, and how to deploy to Cloud Native platforms like Pivotal Web Services (PWS) and K8s.
- This project just shows how to push an app quickly. It doesn't follow best practices such as Testing, CI/CD, and proper build configurations. But, hopefully it can show how easy it is to push apps to production with the right Cloud Native frameworks and tools!
$ ./gradlew bootRun
To test:
$ curl http://localhost:8080/api/v1/hello
- cf cli installed
- Org and Space (account) provisioned on PWS or any CFAR like VMWare Tanzu Application Service
- Build the application by running:
$ ./gradlew assemble
- Login using cf cli. This is an example for PWS:
$ cf login -a https://api.run.pivotal.io
-
Ensure that manifest.yml is populated
-
Push!
$ cf push
-
By default, the cf cli will use the
manifest.yml
in the current directory for deployment. The included default manifest requests a random route for the app. Watch your terminal output to see the URL at which you can access the app. -
Done! Query the appropriate URL.
- K8s cluster provisioned. See Tanzu Kubernetes Grid, GKE, or EKS
- kubectl installed, and configured with context pointing to K8s cluster
- Local Docker installed
- DockerHub account, to push and host container images. This can be replaced with private container registries (such as Harbor), which is beyond the scope of this demo
- Update the following files, and replace
yourUser/yourRepoNameHere
with the name of your own repository. Note that in subsequent steps, replace the same placeholder with the proper value. - Run a gradle sync to sync dependencies
- Build the image using:
$ ./gradlew bootBuildImage
- Run the image locally:
$ docker run -it --rm -p 8080:8080 yourUser/yourRepoNameHere:latest
- Test that the application is running by making a request and checking the response:
$ curl http://localhost:8080/api/v1/hello
- Push to DockerHub:
$ docker push yourUser/yourRepoNameHere:latest
- Push to K8s:
$ kubectl apply -f k8s-manifest.yml
- Wait for the LoadBalancer public IP to come up, by watching the External IP for the
demo-app-spring
service. Note: this was tested on GKE, but different K8s platforms may have different implementations/requirements for LoadBalancers.
$ kubectl get services
- Done! Query the appropriate URL
- Please reach out to me through github if you encounter any issues. Thanks for looking!