This repo contains the source code to build the vote
, worker
and results
images for deploying the Docker samples [example-voting-app] in Otomi using the provided Helm charts in the Otomi Catalog.
Use the Build feature in Otomi to build the images with mode-Docker
. Set the path
to ./vote/Dockerfile
(or ./worker/Dockerfile
or ./result/Dockerfile
).
Use the postgresql
and the redis
charts in the Otomi Catalog to create a Redis master-replica cluster and a PostgreSQL database. For this demo, Redis authentication needs to be turned off by setting auth.enabled=false
.
Use the k8s-deployment
chart to deploy the vote app. Use the following values:
Name: vote
containerPorts:
- name: http
containerPort: 80
protocol: TCP
env:
- name: REDIS_HOST
value: <redis-cluster-name>-master
Use the k8s-deployment
chart to deploy the worker app. Use the following values:
Name: worker
containerPorts:
- name: http
containerPort: 80
protocol: TCP
env:
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: <psql-cluster-name>-superuser
key: username
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: <psql-cluster-name>-superuser
key: password
- name: REDIS_HOST
value: <redis-cluster-name>-master
- name: DATABASE_HOST
value: <psql-cluster-name>-rw
Use the k8s-deployment
chart to deploy the result app. Use the following values:
Name: result
containerPorts:
- name: http
containerPort: 80
protocol: TCP
env:
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: <psql-cluster-name>-superuser
key: username
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: <psql-cluster-name>-superuser
key: password
- name: DATABASE_HOST
value: <psql-cluster-name>-rw
Register the vote
and result
services in Otomi and configure them for external exposure. If Network policies
are enabled, then register all services and configure the network policies:
- Register the
<workload-name>-rw
Postgresql service - Set exposure to
Private
(default) - In
Network policies
add the Pod Selector<postgres-workload-name>
- Select
Allow selected
- Add From team name
<team-name>
and From label value<postgres-workload-name>
- Add From team name
<team-name>
and From label value<worker>
- Add From team name
<team-name>
and From label value<result>
- Register the
<workload-name>-master
Redis service - Set exposure to
Private
(default) - In
Network policies
add the Pod Selector<redis-workload-name>
- Select
Allow selected
- Add From team name
<team-name>
and From label value<redis-workload-name>
- Add From team name
<team-name>
and From label value<worker>
- Add From team name
<team-name>
and From label value<vote>
- Register the
vote
service - Set exposure to
External
- Register the
<worker
service - Set exposure to
Private
(default)
- Register the
<result>
service - Set exposure to
External