You have built the 3 microservices composing the Chat application:
-
chat-ui
a stateless service serving the UI -
friends
a stateful service to manage the friend list of an user -
presence
a stateful service to maintain the online state of an user
You have built the docker images of these services and published these images to your Docker registry. You have also run each of these images and tested that the service is in working order.
If this is not the case, please review Cloudstate Sample Chat Application to complete the prerequisites.
We are now ready to deploy the Chat application, which we have chosen to deploy using Akka Serverless (managed hosting). Compared to the alternative of deploying on your own Kubernetes cluster, Akka Serverless relieves the developer from the burden related to the infrastructure:
-
no need to provision hardware to setup (and maintain!) a Kubernetes cluster
-
simplify network configuration
-
simplify deployment
-
Get [your Akka Serverless Account](https://docs.cloudstate.com/getting-started/lightbend-account.html)
-
Install [akkasls](https://docs.cloudstate.com/getting-started/set-up-development-env.html)
With your Akka Serverless account, you will be granted a Kubernetes cluster on the cloud. This cluster is managed by Akka Serverless. It is customized to host services created using the Cloudstate library.
Instructions: Using an Akka Serverless account
akkasls
is the command line tool that you will use to deploy an application on your Akka Serverless cluster. Instructions: Install Akka Serverless CLI
The akkasls
minimum version required is 0.0.16 which you can verify by:
$ akkasls version
0.0.16
An Akka Serverless project is a space within your Akka Serverless cluster. In this space, you will deploy your Cloudstate-aware application. In this step we use the Akka Serverless CLI akkasls
to:
-
Login to your Akka Serverless cluster (which you got when signing-up for a Akka Serverless account)
-
Create an Akka Serverless project
-
Deploy your services in the project
More details on akkasls
is available at akkasls reference documentation.
#===STEP1: connect akkasls to your Akka Serverless account
$ akkasls auth login
#===STEP2: create a new Akka Serverless project
# Syntax: akkasls project new "project-friendly-name" "Project description"
# NOTE: project-friendly-name: no space, only lower case and dash
$ akkasls project new chat-application "Chat room app built with Akka Serverless services"
Created project chat-application.
To make this the currently active project, run: 'akkasls config set project chat-application'
NAME DESCRIPTION STATUS ID
chat-application Chat room app built with Akka Serverless services pending 3d864594-fefe-4708-82da-da842e4cdcde
#===STEP3: set the new Akka Serverless project as "current"
$ akkasls config set project chat-application
Project set to chat-application
- IMPORTANT
-
A newly created project is in
pending
status, ie. you cannot yet deploy on your Akka Serverless cluster. Once the project is activated by an Akka Serverless administrator (within a short moment). Its status will change toactive
, at which point, you can begin to deploy your services. In case it takes long time for your project to get activated, you can notify Akka Serverless admin
Confirm your Akka Serverless project is ready for deployment:
-
The project status is
active
-
The project is set as current. This helps to skip the
--project
parameter inakkasls
commands when deploying on your Akka Serverless cluster
$ akkasls project list
# Notice the `*` (marker for current project) in front of the project name
NAME DESCRIPTION STATUS ID
* chat-application Chat room app built with Akka Serverless services active 3d864594-fefe-4708-82da-da842e4cdcde
Now we are ready to deploy our Chat application on our Akka Serverless cluster. The deployment tool is also akkasls
.
At this point you should have all your docker images published in your Docker registry, as mentioned in the Overview section. In case you Docker registry is private, the akkasls
needs to be configured with the corresponding credentials.
$ akkasls docker add-credentials
# verify
$ akkasls docker list-credentials
In case you don’t have your own docker images, you can still proceed with the deployment, using the images prebuilt by the Akka Serverless project team.
We deploy the chat-ui
first as this is the entrypoint of the Chat application
# Syntax: $ akkasls services deploy <serviceName> <dockerImageCoordinatess>
$ akkasls services deploy chat-ui lightbend-docker-registry.bintray.io/cloudstate-samples/chat-ui:latest
# give the cluster about a minute to provision the resources
# then verify that the service has `STATUS=Ready`
$ akkasls services get
# console output
NAME AGE REPLICAS STATUS DESCRIPTION
chat-ui 86s 1 Ready
The chat-ui
service needs to be exposed to allow external access. Notice the service entrypoint given in the console output.
$ akkasls service expose chat-ui
# console output
Service 'chat-ui' was successfully exposed at: little-cherry-4517.us-east1.apps.lbcs.io
Next we deploy the backend services:
$ akkasls services deploy friends lightbend-docker-registry.bintray.io/cloudstate-samples/chat-friends-js:latest
$ akkasls services deploy presence lightbend-docker-registry.bintray.io/cloudstate-samples/chat-presence-js:latest
# wait about a minute and check that all services are `Ready`
$ akkasls services get
# console output
NAME AGE REPLICAS STATUS DESCRIPTION
chat-ui 10m 1 Ready
friends 2m14s 1 Ready
presence 2m5s 1 Ready
|
Normally, this is all we need to do to deploy the Chat application. For now, akkasls needs some workarounds to help the chat-ui to route service calls to dependant services. The step shown below is a temporary workaround. In the next version of akkasls this step will be unnecessary.
Route all calls using the same endpoint as chat-ui , which was given by akkasls service expose chat-ui in the previous step. Internally, Akka Serverless will forward the calls to friends and presence services to the appropriate endpoints.
We also need to know the fully qualified name of the service which are given by the gRPC service descriptors friends.proto and presence.proto. |
$ akkasls service expose friends \
--hostname little-cherry-4517.us-east1.apps.lbcs.io \
--uri-prefix=/cloudstate.samples.chat.friends.Friends/
$ akkasls service expose presence \
--hostname little-cherry-4517.us-east1.apps.lbcs.io \
--uri-prefix=/cloudstate.samples.chat.presence.Presence/
By design, the route to access the Chat UI is /pages/chat.html
. Using the chat-ui service entrypoint obtained when running akkasls service expose chat-ui
, our Chat application is accessible at:
https://little-cherry-4517.us-east1.apps.lbcs.io/pages/chat.html
That’s it. Now enjoy the app, the navigation guide is explained at Chat navigation guide
(end)