Giter Club home page Giter Club logo

example-voting-app's Introduction

example-voting-app

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.

Get started

Building the images

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).

Create a Redis cluster and a PostgreSQL database

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.

Deploy the Vote app

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

Deploy the Worker app

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

Deploy the Result app

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 services

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:

Postgres database

  • 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>

Redis

  • 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>

Vote

  • Register the vote service
  • Set exposure to External

Worker

  • Register the <worker service
  • Set exposure to Private (default)

Result

  • Register the <result> service
  • Set exposure to External

example-voting-app's People

Contributors

srodenhuis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.