mirror of https://github.com/knative/docs.git
Fixed markdown syntax in helloworld-java-spring/README.md (#5164)
* Fixed markdown syntax in helloworld-java-spring/README.md Signed-off-by: Helber Belmiro <helber.belmiro@gmail.com> * Update code-samples/serving/hello-world/helloworld-java-spring/README.md Co-authored-by: Samia Nneji <snneji@vmware.com> * Update code-samples/serving/hello-world/helloworld-java-spring/README.md Co-authored-by: Samia Nneji <snneji@vmware.com> * Update code-samples/serving/hello-world/helloworld-java-spring/README.md Co-authored-by: Samia Nneji <snneji@vmware.com> * Update code-samples/serving/hello-world/helloworld-java-spring/README.md Co-authored-by: Samia Nneji <snneji@vmware.com> * Update code-samples/serving/hello-world/helloworld-java-spring/README.md Co-authored-by: Samia Nneji <snneji@vmware.com> * Update code-samples/serving/hello-world/helloworld-java-spring/README.md Co-authored-by: Samia Nneji <snneji@vmware.com> * Update code-samples/serving/hello-world/helloworld-java-spring/README.md Co-authored-by: Samia Nneji <snneji@vmware.com> * Update code-samples/serving/hello-world/helloworld-java-spring/README.md Co-authored-by: Samia Nneji <snneji@vmware.com> * Update code-samples/serving/hello-world/helloworld-java-spring/README.md Co-authored-by: Samia Nneji <snneji@vmware.com> * Update code-samples/serving/hello-world/helloworld-java-spring/README.md Co-authored-by: Samia Nneji <snneji@vmware.com> * Update code-samples/serving/hello-world/helloworld-java-spring/README.md * Update code-samples/serving/hello-world/helloworld-java-spring/README.md * Update code-samples/serving/hello-world/helloworld-java-spring/README.md * Update code-samples/serving/hello-world/helloworld-java-spring/README.md * Update code-samples/serving/hello-world/helloworld-java-spring/README.md Signed-off-by: Helber Belmiro <helber.belmiro@gmail.com> Co-authored-by: Samia Nneji <snneji@vmware.com>
This commit is contained in:
parent
acb827c003
commit
37b432c6f1
|
@ -32,10 +32,10 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-java-spring
|
||||||
unzip helloworld.zip
|
unzip helloworld.zip
|
||||||
```
|
```
|
||||||
|
|
||||||
If you don't have `curl` installed, you can accomplish the same by visiting the
|
If you don't have `curl` installed, you can accomplish the same by visiting the
|
||||||
[Spring Initializr](https://start.spring.io/) page. Specify Artifact as
|
[Spring Initializr](https://start.spring.io/) page. Specify Artifact as
|
||||||
`helloworld` and add the `Web` dependency. Then click **Generate Project**,
|
`helloworld` and add the `Web` dependency. Then click **Generate Project**,
|
||||||
download and unzip the sample archive.
|
download and unzip the sample archive.
|
||||||
|
|
||||||
1. Update the `SpringBootApplication` class in
|
1. Update the `SpringBootApplication` class in
|
||||||
`src/main/java/com/example/helloworld/HelloworldApplication.java` by adding a
|
`src/main/java/com/example/helloworld/HelloworldApplication.java` by adding a
|
||||||
|
@ -77,7 +77,7 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-java-spring
|
||||||
./mvnw package && java -jar target/helloworld-0.0.1-SNAPSHOT.jar
|
./mvnw package && java -jar target/helloworld-0.0.1-SNAPSHOT.jar
|
||||||
```
|
```
|
||||||
|
|
||||||
Go to `http://localhost:8080/` to see your `Hello World!` message.
|
Go to `http://localhost:8080/` to see your `Hello World!` message.
|
||||||
|
|
||||||
1. In your project directory, create a file named `Dockerfile` and copy the following code block into it:
|
1. In your project directory, create a file named `Dockerfile` and copy the following code block into it:
|
||||||
|
|
||||||
|
@ -105,9 +105,9 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-java-spring
|
||||||
CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/helloworld.jar"]
|
CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/helloworld.jar"]
|
||||||
|
|
||||||
```
|
```
|
||||||
For detailed instructions on dockerizing a Spring Boot app, see [Spring Boot with Docker](https://spring.io/guides/gs/spring-boot-docker/).
|
For detailed instructions on dockerizing a Spring Boot app, see [Spring Boot with Docker](https://spring.io/guides/gs/spring-boot-docker/).
|
||||||
|
|
||||||
For additional information on multi-stage docker builds for Java see [Creating Smaller Java Image using Docker Multi-stage Build](http://blog.arungupta.me/smaller-java-image-docker-multi-stage-build/).
|
For additional information on multi-stage docker builds for Java see [Creating Smaller Java Image using Docker Multi-stage Build](http://blog.arungupta.me/smaller-java-image-docker-multi-stage-build/).
|
||||||
|
|
||||||
1. Use Docker to build the sample code into a container, then push the container to the Docker registry:
|
1. Use Docker to build the sample code into a container, then push the container to the Docker registry:
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-java-spring
|
||||||
# Push the container to docker registry
|
# Push the container to docker registry
|
||||||
docker push {username}/helloworld-java-spring
|
docker push {username}/helloworld-java-spring
|
||||||
```
|
```
|
||||||
Where `{username}` is your Docker Hub username.
|
Where `{username}` is your Docker Hub username.
|
||||||
|
|
||||||
|
|
||||||
## Deploying the app
|
## Deploying the app
|
||||||
|
@ -133,75 +133,74 @@ During the creation of a Service, Knative performs the following steps:
|
||||||
|
|
||||||
To deploy the app:
|
To deploy the app:
|
||||||
|
|
||||||
=== "YAML"
|
### YAML
|
||||||
|
|
||||||
1. Create a new file named `service.yaml` and copy the following service definition
|
1. Create a new file named `service.yaml` and copy the following service definition
|
||||||
into the file:
|
into the file:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: serving.knative.dev/v1
|
apiVersion: serving.knative.dev/v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: helloworld-java-spring
|
name: helloworld-java-spring
|
||||||
namespace: default
|
namespace: default
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
spec:
|
spec:
|
||||||
template:
|
containers:
|
||||||
spec:
|
- image: docker.io/{username}/helloworld-java-spring
|
||||||
containers:
|
env:
|
||||||
- image: docker.io/{username}/helloworld-java-spring
|
- name: TARGET
|
||||||
env:
|
value: "Spring Boot Sample v1"
|
||||||
- name: TARGET
|
```
|
||||||
value: "Spring Boot Sample v1"
|
Where `{username}` is your Docker Hub username.
|
||||||
```
|
|
||||||
Where `{username}` is your Docker Hub username.
|
|
||||||
|
|
||||||
**Note:** Ensure that the container image value in `service.yaml` matches the container you built in the previous step.
|
**Note:** Ensure that the container image value in `service.yaml` matches the container you built in the previous step.
|
||||||
|
|
||||||
1. Apply the YAML file by running the command:
|
1. Apply the YAML file by running the command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl apply -f service.yaml
|
kubectl apply -f service.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "kn"
|
### kn
|
||||||
|
|
||||||
With `kn` you can deploy the service with
|
With `kn` you can deploy the service with
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kn service create helloworld-java-spring --image=docker.io/{username}/helloworld-java-spring --env TARGET="Spring Boot Sample v1"
|
kn service create helloworld-java-spring --image=docker.io/{username}/helloworld-java-spring --env TARGET="Spring Boot Sample v1"
|
||||||
```
|
```
|
||||||
|
|
||||||
This will wait until your service is deployed and ready, and ultimately it will print the URL through which you can access the service.
|
|
||||||
|
|
||||||
|
This will wait until your service is deployed and ready, and ultimately it will print the URL through which you can access the service.
|
||||||
|
|
||||||
## Verification
|
## Verification
|
||||||
|
|
||||||
1. Find the domain URL for your service:
|
1. Find the domain URL for your service:
|
||||||
|
|
||||||
=== "kubectl"
|
- For kubectl, run:
|
||||||
```bash
|
|
||||||
kubectl get ksvc helloworld-java-spring --output=custom-columns=NAME:.metadata.name,URL:.status.url
|
|
||||||
```
|
|
||||||
|
|
||||||
Example:
|
```bash
|
||||||
|
kubectl get ksvc helloworld-java-spring --output=custom-columns=NAME:.metadata.name,URL:.status.url
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
Example:
|
||||||
NAME URL
|
|
||||||
helloworld-java-spring http://helloworld-java-spring.default.1.2.3.4.xip.io
|
|
||||||
```
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
NAME URL
|
||||||
|
helloworld-java-spring http://helloworld-java-spring.default.1.2.3.4.xip.io
|
||||||
|
```
|
||||||
|
|
||||||
=== "kn"
|
- For kn, run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kn service describe helloworld-java-spring -o url
|
kn service describe helloworld-java-spring -o url
|
||||||
```
|
```
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
http://helloworld-java-spring.default.1.2.3.4.xip.io
|
http://helloworld-java-spring.default.1.2.3.4.xip.io
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Make a request to your app and observe the result. Replace
|
1. Make a request to your app and observe the result. Replace
|
||||||
the following URL with the URL returned in the previous command.
|
the following URL with the URL returned in the previous command.
|
||||||
|
@ -222,12 +221,12 @@ To deploy the app:
|
||||||
|
|
||||||
To remove the sample app from your cluster, delete the service.
|
To remove the sample app from your cluster, delete the service.
|
||||||
|
|
||||||
=== "kubectl"
|
### kubectl
|
||||||
```bash
|
```bash
|
||||||
kubectl delete -f service.yaml
|
kubectl delete -f service.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "kn"
|
### kn
|
||||||
```bash
|
```bash
|
||||||
kn service delete helloworld-java-spring
|
kn service delete helloworld-java-spring
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue