This app provides a minimal example of a chat app, sending messages to all clients that are currently connected.
It consists of a simple static webpage with minimal scripts to send messages through the application server to a connected RabbitMQ cluster. Due to the exchange type "fanout", all messages will be relayed to all connected clients.
Note this is a minimal example which does not consider persistence, reconnection / error handling, cleaning up etc.
The application server accepts the websocket connections, and would generally be able to exchange messages between them. However, typically multiple application server instances exist, and usually not all clients are connected to the same instance. The RabbitMQ cluster takes care of exchanging the messages between those.
The platform admin needs to activate RabbitMQ
and Harbor
in the Platform Apps.
The app does not include a .Dockerfile
, but an image can be created using Buildpacks
.
- In the app platform, select
Build
, thenCreate Build
. - Provide an image name, e.g.
rmq-example-app
. - Select as Mode
Buildpacks
. - Set the Repo URL to
https://github.com/linode/apl-examples.git
. - Set the path to
rabbitmq-python-example
. - Confirm with
Submit
. - Copy out the image repository for creating the workload in the following step.
- Go to
Workloads
, thenCreate Workload
. - Select
RabbitMQ-Cluster
. - Set a name, e.g.
example
. - Click
Submit
.
- Go to
Workloads
, thenCreate Workload
. - Select
K8s-Deployment
. - Set a name, e.g.
rmq-example-app
. - In the chart values, update the
image
andenv
section. Adjustimage.repository
with the value from the build. Also, update thename
references in thesecretKeyRef
entries. The format of the secret name is<name>-rabbitmq-cluster-default-user
, where<name>
is to be replaced with the cluster name you chose above. It should look like this:
image:
repository: <your-image-repo>
pullPolicy: IfNotPresent
tag: latest
env:
- name: NOTIFIER_RABBITMQ_HOST
valueFrom:
secretKeyRef:
name: example-rabbitmq-cluster-default-user
key: host
- name: NOTIFIER_RABBITMQ_USER
valueFrom:
secretKeyRef:
name: example-rabbitmq-cluster-default-user
key: username
- name: NOTIFIER_RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: example-rabbitmq-cluster-default-user
key: password
- Go to
Network Policies
, selectCreate Netpol
. - Provide any name for the policy, e.g.
rabbitmq-example
. - Rule type is
ingress
. Set the selector nameotomi.io/app
and valueexample-rabbitmq-cluster
, where applicable replacingexample
with the name you chose for the RabbitMQ instance. - Set mode to
AllowOnly
. - Set the namespace to
team-<team-name>
, according to the team deploying the application, e.g.team-demo
. - Optionally limit the in-cluster exposure to the app, i.e. set the selector label name to
otomi.io/app
and the selector label value to the name of your app workload, e.g.rmq-example-app
.
- As soon as the workload is deployed, go to
Services
andCreate Service
. - Select the name of your workload from the list, e.g.
rmq-example-app
. - Under Exposure, select
External
- Confirm with
Submit
.
As soon as the service is configured, the app should be available using the link URL in the application platform console.