- If you don't already have one, sign-up for an IBM Cloud pay-as-you-go account. We will only be using the free Lite Tier service instances for the workshop.
-
If you don't already have one, create an Event Streams service instance.
a. Log in to the IBM Cloud console.
b. Click the Event Streams service in the Catalog.
c. Select the Lite plan on the service instance page.
d. Enter a name for your service. You can use the default value.
e. Click Create. The Event Streams Getting started page opens.
-
If you don't already have them, install the following prerequisites:
GitHub Repo: https://github.com/jritten/ibm-x-sib
-- clone the repo --
$ git clone https://github.com/jritten/ibm-x-sib
-- cd into stream-video-eventstreams --
$ cd stream-video-eventstreams
Add the Event Streams Service Credentials to the App.
-- add username env var --
$ export USERNAME=”token”
-- add password env var --
$ export PASSWORD=”<SERVICE_CREDENTIALS_PASSWORD>”
-- add broker env var (first in list) --
$ export BROKERS=”<KAFKA_BROKERS_SASL[0]>”
-- build a docker image --
$ docker build . --tag event_consumer
-- run the docker image --
$ docker run --rm -e BROKERS=$BROKERS -e USERNAME=$USERNAME -e PASSWORD=$PASSWORD -p 8080:8080 event_consumer
-- view the app --
http://127.0.0.1:8080
-- check that Python3 is installed --
$ python3 --version
-- create python3 virtual env; run venv module to create the directory .venv where our files will be stored --
$ python3 -mvenv .venv
-- activate the virtual env --
$ source .venv/bin/activate
-- install the modules we need --
$ pip3 install -r requirements.txt
-- run the app in python3 virtual env --
$ python3 producer.py
-- view the app --
http://127.0.0.1:5000
-- tag the docker image --
$ docker tag event_consumer <DOCKERHUB_REPO>/event_consumer:latest
-- push the image to docker hub --
$ docker push <DOCKERHUB_REPO>/event_consumer:latest
-- copy the image location from the output --
$ The push refers to repository [docker.io/<DOCKERHUB_REPO>/event_consumer]
Add the location of the container image in Docker Hub.
[docker.io/<DOCKERHUB_REPO>/event_consumer]
Select your Code Engine project.
Configure the Runtime. Update the Max concurrency to “2”.
Add Environment Variables. Add your environment variables as key-value pairs so Code Engine can inject them into the application for global use. Add each key-value pair as a Literal value.
Deploy to Code Engine. Click Create.
Close all instances of the running application (close all the browser tabs where the application is currently running), and watch the application scale down to zero in the Overview.
Share the App URL with others, and have them start instances of the running App in the browser. Watch Code Engine auto-scale the App based on incoming HTTP-requests in the Overview.