This version of the documentation is no longer actively maintained. The site that you are currently viewing is an archived snapshot.

For up-to-date documentation, see the latest version.

Hello World - Scala using Akka HTTP

A microservice which demonstrates how to get set up and running with Knative Serving when using Scala and Akka HTTP. It will respond to a HTTP request with a text specified as an ENV variable named MESSAGE, defaulting to "Hello World!".

Follow the steps below to create the sample code and then deploy the app to your cluster. You can also download a working copy of the sample, by running the following commands:

git clone -b "{{< branch >}}" knative-docs
cd knative-docs/docs/serving/samples/hello-world/helloworld-scala

Before you begin

  • A Kubernetes cluster installation with Knative Serving up and running.
  • Docker installed locally, and running, optionally a Docker Hub account configured or some other Docker Repository installed locally.

Configuring the Service descriptor

Importantly, in service.yaml change the image reference to match up with your designated repository, i.e. replace {username} with your Dockerhub username in the example below.

kind: Service
  name: helloworld-scala
  namespace: default
      - image:{username}/helloworld-scala
        - name: TARGET
          value: "Scala Sample v1"

Publishing to Docker

In order to build the project and create and push the Docker image, run:

# Build the container on your local machine
docker build -t {username}/helloworld-scala .

# Push the container to docker registry
docker push {username}/helloworld-scala

Deploying to Knative Serving

Apply the Service yaml definition:

kubectl apply --filename service.yaml

Then find the service host:

kubectl get ksvc helloworld-scala \,URL:.status.url

# It will print something like this, the URL is what you're looking for.
# NAME                URL
# helloworld-scala

Finally, to try your service, use the obtained URL:

curl -v


kubectl delete --filename service.yaml