Hey there! This is Timber.
Timber is an app that you'll use in the challenge we've set you following your recent training.
It replicates a "traditional web app" setup, where there is a frontend, a backend and a database (you'll use Redis).
Functionality in the app is enabled & disabled mostly through environment variables.
Timber is written in Python 3, but if you're not a Python expert, fear not! It is, we hope, well-documented and fairly easy to understand.
The backend is an API exposing data through HTTP endpoints. They are all GET endpoints for simplicity. Some endpoints have a description
value to pass a human readable sentence to the frontend. Some endpoints require Timber to be running in a Kubernetes cluster, and so their descriptions are omitted for this challenge.
The entrypoint of the Backend API is app.py
.
Returns a fortune cookie read from a file on a volume. This file is generated by a separate service.
This API endpoint returns the configuration of Timber, which is set through environment variables.
Environment Variable | What it does | Default |
---|---|---|
TIMBER_LIVENESS_PROBE_ENABLED |
Set to any value to enable /probe/liveness |
Disabled |
TIMBER_READINESS_PROBE_ENABLED |
Set to any value to enable /probe/readiness |
Disabled |
TIMBER_VERSION |
Currently running application version | v1.0 |
TIMBER_REDIS_HOST |
Redis server used if state is set to redis |
redis |
TIMBER_STATE |
State storage: inmemory , redis |
inmemory |
TIMBER_LISTEN_PORT |
Set the port Timber listens on | 8080 |
{
description: <...>,
liveness_probe_enabled: <true/false>,
readiness_probe_enabled: <true/false>,
redis_host: <...>,
state: <...>,
version: <...>
}
This API endpoint returns deterministic hex colors.
Colors are generated based on the values of TIMBER_VERSION
, TIMBER_HOSTNAME
, TIMBER_STATE
.
{
hostname: <...>,
state: <...>,
version: <...>
}
This API returns information about the state kept by the backend.
{
type: <inmemory|redis>,
image_link: <...> # The picture we are keeping in state
state_hits: <int> # Number of times the state has been checked
}
The frontend shows all the data that the backend provides, and some more.
Data from all the backend APIs is used, as well as showing the frontend hostname.
This is the frontend index. It uses index.html as a template, and gets the data from the backend API.
The frontend is configured using environment variables.
Environment Variable | What it does | Default |
---|---|---|
TIMBER_BACKEND_API_URL |
Sets the backend URL | http://backend:8080 |
TIMBER_LISTEN_PORT |
Sets the port Timber listens on | 8080 |
The fortune service is a basic bash script. It's a simple loop that writes a fortune cookie to the directory /var/htdocs
every 10 seconds.