diff --git a/quickstarts/maven/spring-boot/README.md b/quickstarts/maven/spring-boot/README.md index f51cfc166f..d93404f37f 100644 --- a/quickstarts/maven/spring-boot/README.md +++ b/quickstarts/maven/spring-boot/README.md @@ -6,74 +6,108 @@ description: | --- # Spring Boot Sample -This is a sample project to use Eclipse JKube plugins. +This is an example of a Spring Boot Web application demonstrating the use of Eclipse JKube Maven Plugin to deploy Spring Boot applications to Kubernetes and OpenShift. -**Notice:** -> k8s:watch / oc:watch goal won't work as Spring devtools automatically -> ignores projects named `spring-boot`, `spring-boot-devtools`, `spring-boot-autoconfigure`, `spring-boot-actuator`, -> `and spring-boot-starter`. +> [!NOTE] +> k8s:watch / oc:watch goal won't work as Spring devtools automatically ignores projects named `spring-boot`, `spring-boot-devtools`, `spring-boot-autoconfigure`, `spring-boot-actuator`, `and spring-boot-starter`. +> +> To learn how to use Spring Devtools with Eclipse JKube, please refer to the [`spring-boot-watch` quickstart](../spring-boot-watch/README.md). -### Steps to use +This example consists of a single `@RestController` that returns a simple greeting message. -Make sure that OpenShift/Kubernetes cluster or Minishift/Minikube is running. In case, if anything of this is not running, you can -run Minishift/Minikube to test this application by using following command. +It is built to showcase how to deploy Spring Boot applications, both native and JVM, to Kubernetes and OpenShift using Eclipse JKube. +Let's start by checking the JVM build mode. +## JVM build +To build the application in JVM mode, run the following command: -#### For OpenShift -``` -minishift start -``` -Below command will create your OpenShift resource descriptors. -``` -mvn clean oc:resource -Popenshift +```bash +mvn clean package ``` -Now start S2I build by hitting the build goal. -``` -mvn package oc:build -Popenshift +This command will build the application and create a JAR file in the `target` directory. + +To deploy the application to Kubernetes, run the following command: + +> [!NOTE] +> In case it's a Minikube cluster you want to share the Docker registry first: +> +> `eval $(minikube docker-env)` + +```bash +mvn -Pkubernetes k8s:build k8s:resource k8s:apply ``` -Below command will deploy your application on OpenShift cluster. +Once the application is deployed and ready, the list of pods should display something like: + +```bash +$ kubectl get pods +NAME READY STATUS RESTARTS AGE +spring-boot-5987c95fd6-phwv4 1/1 Running 0 22s ``` -mvn oc:deploy -Popenshift + +You can now access your application using cURL with the following command: + +```bash +$ curl $(minikube ip):$(kubectl get svc spring-boot -n default -o jsonpath='{.spec.ports[].nodePort}') +Greetings from Spring Boot!! ``` -#### For Kubernetes -Start your cluster: +## Native Build + +To build the application in JVM mode, run the following command: + +```bash +mvn -Pnative clean native:compile ``` -minikube start + +This command will build the application and create a JAR file in the `target` directory. + +To deploy the application to Kubernetes, run the following command: + +> [!NOTE] +> In case it's a Minikube cluster you want to share the Docker registry first: +> +> `eval $(minikube docker-env)` + +```bash +mvn -Pkubernetes k8s:build k8s:resource k8s:apply ``` -Below command will create your Kubernetes resource descriptors. + +Once the application is deployed and ready, the list of pods should display something like: + +```bash +$ kubectl get pods +NAME READY STATUS RESTARTS AGE +spring-boot-5987c95fd6-phwv4 1/1 Running 0 22s ``` -mvn clean k8s:resource -Pkubernetes + +You can now access your application using cURL with the following command: + +```bash +$ curl $(minikube ip):$(kubectl get svc spring-boot -n default -o jsonpath='{.spec.ports[].nodePort}') +Greetings from Spring Boot!! ``` -Now start docker build by hitting the build goal. +## For OpenShift + ``` -mvn package k8s:build -Pkubernetes +minishift start ``` - -Below command will deploy your application on Kubernetes cluster. +Below command will create your OpenShift resource descriptors. ``` -mvn k8s:deploy -Pkubernetes +mvn clean oc:resource -Popenshift ``` -Once deployed, you can see the pods running inside your Kubernetes cluster: +Now start S2I build by hitting the build goal. ``` -~/work/repos/jkube/quickstarts/maven/spring-boot : $ kubectl get pods -NAME READY STATUS RESTARTS AGE -spring-boot-59b4bb66-j42fv 1/1 Running 0 94s +mvn package oc:build -Popenshift ``` -You can try to access your application using `minikube service` command like this: + +Below command will deploy your application on OpenShift cluster. ``` -~/work/repos/jkube/quickstarts/maven/spring-boot : $ minikube service spring-boot -|-----------|-------------|-------------|----------------------------| -| NAMESPACE | NAME | TARGET PORT | URL | -|-----------|-------------|-------------|----------------------------| -| default | spring-boot | http | http://192.168.39.76:32429 | -|-----------|-------------|-------------|----------------------------| - Opening service default/spring-boot in default browser... +mvn oc:deploy -Popenshift ``` #### Generating Ingress for your generated Service diff --git a/quickstarts/maven/spring-boot/pom.xml b/quickstarts/maven/spring-boot/pom.xml index bd3ae7044a..ccc3e7fb29 100644 --- a/quickstarts/maven/spring-boot/pom.xml +++ b/quickstarts/maven/spring-boot/pom.xml @@ -21,7 +21,8 @@ org.springframework.boot spring-boot-starter-parent - 2.7.17 + 3.4.1 + org.eclipse.jkube.quickstarts.maven @@ -36,51 +37,31 @@ + 17 ${project.version} - - - sonatype-nexus-snapshots - Sonatype Nexus Snapshots - https://oss.sonatype.org/content/repositories/snapshots/ - - - sonatype-nexus-staging - Nexus Release Repository - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - - org.springframework.boot spring-boot-starter-web - org.springframework.boot spring-boot-starter-actuator - - - org.jolokia - jolokia-core - - - + + org.graalvm.buildtools + native-maven-plugin + org.springframework.boot spring-boot-maven-plugin - - @@ -93,9 +74,7 @@ org.eclipse.jkube kubernetes-maven-plugin ${jkube.version} - - @@ -103,11 +82,7 @@ - - - spring-boot - always @@ -115,9 +90,6 @@ - - jkube-expose - NodePort @@ -125,16 +97,6 @@ - - - - - resource - build - helm - - - @@ -147,7 +109,6 @@ org.eclipse.jkube openshift-maven-plugin ${jkube.version} - @@ -156,11 +117,7 @@ - - - spring-boot - always @@ -168,9 +125,6 @@ - - jkube-expose - NodePort @@ -178,15 +132,6 @@ - - - - - resource - build - - -