This project is an example for Lightbend Orchestration for Kubernetes.
This project consists of a simple Play application which has the SBT Reactive App plugin enabled. Using this plugin and the combination of Reactive CLI, deployment to a target runtime can be done in a seamless and timely manner.
At the point of writing the target runtime supported is Kubernetes, although the tool might be extended to support DC/OS and other target runtime.
Refer to DESIGN.md
to see how the application is put together.
- Minikube installed and running with insecure registry enabled.
- Docker command line tools installed and enabled.
- OpenJDK 8 or Oracle Java 8
- SBT
See the Lightbend Orchestration for Kubernetes documentation.
There's two ways you can deploy to Minikube. There's a manual process which matches what you would typically do in
a production environment, that is generating resources using rp
and piping those to kubectl
.
The SBT task, deploy minikube
, automates this for you for local development.
Both are documented below.
Use the SBT task to deploy the application. This will build and deploy both applications to your Minikube. Three
instances of clustered-impl
will be started (see build.sbt for this configuration).
sbt 'deploy minikube'
You can also run this task directly from within SBT.
Setup Minikube Docker environment variables.
$ eval $(minikube docker-env)
Clone this project from Github.
Go into the recently cloned project directory.
$ cd hello-reactive-tooling
Publish the project as Docker images into Minikube.
$ sbt frontend/docker:publishLocal simple-impl/docker:publishLocal clustered-impl/docker:publishLocal
Deploy the simple-impl
to minikube using the following command. Note for the simple-impl
we don't generate the Ingress resource as we don't wish to expose the endpoint outside of Kubernetes.
$ rp generate-kubernetes-resources simple-impl:0.0.1 --generate-services --generate-pod-controllers --env JAVA_OPTS="-Dplay.http.secret.key=simple" | kubectl apply -f -
Similarly, deploy the clustered-impl
. We also won't expose clustered-impl
outside of Kubernetes. We also scale the clustered-impl
to 3
instances to test the cluster functionality.
$ rp generate-kubernetes-resources clustered-impl:0.0.1 --generate-services --generate-pod-controllers --pod-controller-replicas 3 --env JAVA_OPTS="-Dplay.http.secret.key=clustered" | kubectl apply -f -
Deploy the frontend
to minikube using the following command.
$ rp generate-kubernetes-resources frontend:0.0.1 --generate-all --env JAVA_OPTS="-Dplay.http.secret.key=hereiam -Dplay.filters.hosts.allowed.0=$(minikube ip)" | kubectl apply -f -
Run the following command to access the deployed frontend
.
$ curl -vLk "https://$(minikube ip)/"
The frontend
application exposes various other endpoints.
Run the following command to access the simple-impl
through frontend
.
$ curl -vLk "https://$(minikube ip)/simple/hello"
The frontend
will invoke the ServiceLocator
provided by reactive-lib
to locate simple-impl
service.
Run the following command to access the clustered-impl
through frontend
.
$ curl -vLk "https://$(minikube ip)/clustered/hello"
The frontend
will invoke the ServiceLocator
provided by reactive-lib
to locate clustered-impl
service.
Run the following command.
$ curl -vLk "https://$(minikube ip)/forward/hello"
- The
frontend
will invoke theServiceLocator
provided byreactive-lib
to locateclustered-impl
service. - The
clustered-impl
service will invoke Lagom client provided by theservice-api
. Internally Lagom will invoke theLagomServiceLocator
provided byreactive-lib
.
Run the following command, replacing <service-name>
with the actual service name or the SRV entry you'd like to find. This command will return a list of address for a given service name.
$ curl -vLk "https://$(minikube ip)/srv/<service-name>"
Example:
$ curl -vLk "https://$(minikube ip)/srv/_http._tcp.simple-service.default.svc.cluster.local"
Run the following command, replacing <service-name>
with the actual service name and <endpoint-name>
with the actual endpoint name. This command will return a list of address for a given service name and endpoint name.
$ curl -vLk "https://$(minikube ip)/srv/<service-name>/<endpoint-name>"
Example:
$ curl -vLk "https://$(minikube ip)/srv/simple-service/http"