Skip to content

Commit

Permalink
Updated helidon labs
Browse files Browse the repository at this point in the history
  • Loading branch information
mickeyboxell authored and Jesse Butler committed Dec 11, 2018
1 parent f9f83ef commit 9e6fa32
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 71 deletions.
11 changes: 2 additions & 9 deletions labs/helidon-cicd-wercker/readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
---
layout: ziplab
description: Use Wercker to set up a CI/CD Pipeline with OCIR and OKE
tags: Oracle Cloud, Oracle Cloud Infrastructure, OCI, OKE, CI/CD, Wercker, Helidon
permalink: /ziplabs/helidon-wercker-cicd/index.html
---

# Helidon CI/CD with Wercker, Container Registry, and Oracle Container Engine for Kubernetes

## Before You Begin
Expand All @@ -31,7 +24,7 @@ The following list shows the minimum versions:

## Create a Wercker Application

1. Begin by logging into your GitHub account forking the quickstart-se application from [our GitHub repo](https://github.com/mickeyboxell/helidon).
1. Begin by logging into your GitHub account forking the quickstart-se application from [our GitHub repo](https://github.com/mickeyboxell/helidon/helidon-se-codeone-2018).

2. Navigate to https://app.wercker.com/. Create an account if you do not already have one.

Expand All @@ -55,7 +48,7 @@ The following list shows the minimum versions:

1. In the **Environment** tab create each of the following environment variables and click **Add** after each one.

* Docker Username must include the `<tenancy name>/<username>`Docker Password is the `auth_token` for your cluster. Click **Protected** checkbox. NOTE: It must not contain a $ character.
* Docker Username must include the `<tenancy name>/<username>`Docker Password is the [authentication token](https://docs.cloud.oracle.com/iaas/Content/Registry/Tasks/registrygettingauthtoken.htm). Click **Protected** checkbox. NOTE: It must not contain a $ character.
* Docker Repo must include `<region-code>.ocir.io/<tenancy name>/<registry name>`
* Docker Username must include the `<tenancy name>/<username>`

Expand Down
58 changes: 32 additions & 26 deletions labs/helidon-hello-world/readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
---
layout: ziplab
description: An introduction to building microservices with Helidon
tags: Oracle Cloud, Oracle Cloud Infrastructure, OCI, Helidon, Microservices
permalink: /ziplabs/helidon-hello-world/index.html
---

# Helidon Hello World

## Before You Begin
Expand All @@ -25,9 +18,12 @@ The following list shows the minimum versions:
- [Maven 3.5](https://maven.apache.org/download.cgi)
- [Docker 18.02](https://docs.docker.com/install/)
- [Kubectl 1.7.4](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
- Kubernetes: Enable [Kubernetes Support for Mac](https://docs.docker.com/docker-for-mac/#kubernetes) or [Kubernetes Support for Windows](https://docs.docker.com/docker-for-windows/#kubernetes).

[Here](https://helidon.io/docs/latest/#/getting-started/01_prerequisites) is an updated list of pre-requisites for using Helidon.



## Generate The Project

Generate the project sources using the Helidon SE Maven archetypes. The Helidon SE example implements the REST service using the Helidon WebServer component directly. It shows the basics of configuring the WebServer and implementing basic routing rules.
Expand All @@ -47,26 +43,51 @@ mvn archetype:generate -DinteractiveMode=false \
2. change directories into the one created by the archetype:

```
cd quickstart-se```
cd quickstart-se
```

3. Build the application:

```
mvn package
```

4. The project builds an application jar for the example and saves all runtime dependencies in the target/libs directory. This means you can easily start the application by running the application jar file
4. The project builds an application jar for the example and saves all runtime dependencies in the target/libs directory. This means you can easily start the application by running the application jar file:

```
java -jar target/quickstart-se.jar
```
You can now access the application at http://localhost:8080/greet

The example is a very simple "Hello World" greeting service. It supports GET requests for generating a greeting message, and a PUT request for changing the greeting itself. The response is encoded using JSON. For example:

```
curl -X GET http://localhost:31431/greet
{"message":"Hello World!"}
curl -X GET http://localhost:31431/greet/Joe
{"message":"Hello Joe!"}
curl -X PUT http://localhost:31431/greet/greeting/Hola
{"greeting":"Hola"}
curl -X GET http://localhost:31431/greet/Jose
{"message":"Hola Jose!"}
```

5. The project also contains a Docker file so that you can easily build and run a docker image. Because the example’s runtime dependencies are already in target/libs, the Docker file is pretty simple (see target/Dockerfile). To build the Docker image, you need to have Docker installed and running on your system.

```
docker build -t quickstart-se target
```

6. If you would like to start the application with Docker run:

```
docker run --rm -p 8080:8080 quickstart-se:latest
```
You can access the application at http://localhost:8080/greet

## Deploy the Application to Kubernetes.

[Install Kubernetes on your desktop](https://helidon.io/docs/latest/#/getting-started/04_kubernetes). Then deploy the example.
Expand Down Expand Up @@ -97,27 +118,12 @@ kubectl proxy
kubectl get service quickstart-se
```

5. Note the PORTs. You can now connect to the application using the second port number (the NodePort) instead of 8080. For example:
5. Note the ports. You can now connect to the application using the second port number (the NodePort) instead of 8080. For example:

```
curl -X GET http://localhost:31431/greet
```

6. The example is a very simple "Hello World" greeting service. It supports GET requests for generating a greeting message, and a PUT request for changing the greeting itself. The response is encoded using JSON. For example:

http://localhost:31431/greet
```
curl -X GET http://localhost:31431/greet
{"message":"Hello World!"}

curl -X GET http://localhost:31431/greet/Joe
{"message":"Hello Joe!"}
curl -X PUT http://localhost:31431/greet/greeting/Hola
{"greeting":"Hola"}
curl -X GET http://localhost:31431/greet/Jose
{"message":"Hola Jose!"}
```

## Clean Up

Expand Down
46 changes: 10 additions & 36 deletions labs/helidon-metrics/readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
---
layout: ziplab
description: Microservice Metrics and Tracing
tags: Oracle Cloud, Oracle Cloud Infrastructure, OCI, Zipkin, Prometheus, Helidon, Microservice
permalink: /ziplabs/helidon-metrics-tracing/index.html
---

# Helidon Metric Collection and Tracing

## Before You Begin
Expand Down Expand Up @@ -38,11 +31,7 @@ The following list shows the minimum versions:
git clone https://github.com/mickeyboxell/helidon
```

2. Change into the helidon-se-codeone-2018 directory:

```
cd helidon-se-codeone-2018
```
2. Change into the helidon-se-codeone-2018 directory

3. Build the application with:

Expand Down Expand Up @@ -89,7 +78,7 @@ curl -X GET http://localhost:8080/greet/Jose
curl -X POST -d '{"greeting" : "Howdy"}' http://localhost:8080/greet/greeting
# Change greeting by POSTing JSON to a slow handler
# Using asynchronous processig
# Using asynchronous processing
curl -X POST -d '{"greeting" : "Hi"}' http://localhost:8080/greet/slowgreeting
```

Expand All @@ -107,9 +96,8 @@ curl -H 'Accept: text/plain' -X GET http://localhost:8080/metrics/

### Downloading and Running Prometheus on your Local Machine

What use are metrics without a tool to consume them?

https://prometheus.io/docs/prometheus/latest/getting_started/
What use are metrics without a tool to consume them? In this lab we will be using a tool called [Prometheus](
https://prometheus.io/docs/prometheus/latest/getting_started/).

1. [Download the latest release](https://prometheus.io/download) of Prometheus for your platform, then extract and run it:

Expand Down Expand Up @@ -205,21 +193,7 @@ kubectl get service quickstart-se # Get service info
helm install stable/prometheus -n prometheus
```

2. To allow Prometheus to scrape metrics from your Heldion quickstart-se application you will have to modify the service information. Enter:

```
kubectl edit svc prometheus-server
```

3. Under `metadata` add the following:

```
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9102"
```

4. Get the Prometheus server URL by running these commands in the same shell:
2. Get the Prometheus server URL by running these commands in the same shell:

```
export POD_NAME=$(kubectl get pods --namespace default -l "app=prometheus,component=server" -o jsonpath="{.items[0].metadata.name}")
Expand All @@ -229,22 +203,22 @@ export POD_NAME=$(kubectl get pods --namespace default -l "app=prometheus,compon
kubectl --namespace default port-forward $POD_NAME 9090
```

5. Once Prometheus is runnining access the console (e.g. `localhost:9090/graph`) and click `Graph`. Enter `application:accessctr` then click `Execute`. You should see the graph plotting the application's `accessctr` metric. Exercise the application some more using the curl commands that were described earlier. Click `Execute` again and you should see the counter increase.


3. Once Prometheus is runnining access the console (e.g. `localhost:9090/graph`) and click `Graph`. Enter `application:accessctr` then click `Execute`. You should see the graph plotting the application's `accessctr` metric. Exercise the application some more using the curl commands that were described earlier. Click `Execute` again and you should see the counter increase.

## Kubernetes Traces: Downloading and Running Zipkin on Kubernetes

1. Clone our example Zipkin yaml file to a local directory and change to that directory. To install Zipkin enter:
1. To install Zipkin enter:

```
kubectl create -f zipkin.yaml
kubectl create -f https://raw.githubusercontent.com/mickeyboxell/helidon/master/metrics_tracing/zipkin.yaml
```

This will install Zipkin on your cluster with the NodePort of 31001 and the port of 9411.

2. As mentioned before, the application has been instrumented to share tracing data. By default the application is configured to connect to zipkin at `http://localhost:9411`. This is configured in `application.yaml`. In this example your are deploying to a Kubernetes cluster. In `application.yaml` change the zipkin.endpoint to `zipkin.endpoint: "http://zipkin:9411"`.

Remember, you will have to re-package the application with `mvn package` and re-build the Docker image with `docker build -t quickstart-se target` everytime the application is modified.

3. Browse to http://localhost:9411 and choose "greet-service" from the list of available service names. Click "Find Traces" to see tracing data for the service.

## Clean Up
Expand Down

0 comments on commit 9e6fa32

Please sign in to comment.