This repository contains all the backend logic and kubernetes configuration files for the PenQuiz project. The front-end React Native repository is located here.
- Engaging trivia battles
- Public matchmaking
- Private lobbies
- Match history and statistics
- Submit your own questions to the game
- Login with Google account
- Admin panel
The production backend is hosted on Azure, while the frontend React Native application is hosted on Netlify. The RabbitMQ provider we use is CloudAMQP.
Visit the fully working game at https://penquiz.netlify.app/
The backend consists of 3 microservices which utilize RabbitMQ and GRPC to communicate with each other and send messages via SignalR to the frontend React Native application.
- NET 5
- SQL Server / PostgreSQL (Entity ORM)
- CockroachDB
- SignalR
- GRPC
- JWT Authentication
- RabbitMQ
- Docker
- Kubernetes
Embracing eventual consistency pattern, we use the RabbitMQ message bus to send messages between the microservices and we "pull" for any missing data whenever a microservice starts.
If you want to run PenQuiz locally with Kubernetes you need the following pre-requisites:
- Docker Desktop installed
- Kubernetes enabled in docker desktop
Create a namespace for the cluster if you don't want it to be stored in the default one
kubectl create secret generic mssql --from-literal=SA_PASSWORD="yourpassword"
In the K8S Folder run this command:
kubectl apply -f .
This will generate all services, deployments, keel.sh, a persistant volume claim and an nginx ingress controller.
There is a possibility that some deployments will not be registered, so make sure to verify if all services in the K8S directory are running
You can then access the backend production web server on https://localhost/api/account If you issued a self-signed SSL certificate you'd be prompted to allow access to this URL
Each microservice has multiple environmental variables which are usually stored in an appsettings.json, however for docker we inject them through a ConfigMap. There are 3 example configmaps in the K8S directory. Add your own secrets, endpoints etc. and apply them.
There are currently 3 microservices running on a single node:
- AccountService - {host}/api/account
- GameService - {host}/api/game
- QuestionService - {host}/api/question
Backend is also using Keel.sh to poll dockerhub for new container images and redeploys a service if it finds a new digest.
The kubernetes cluster doesn't communicate with HTTPS between the pods, however if you want to expose it to the public you have to make sure that the public IP has valid HTTPS. We use Cert Manager to manage our SSL Certificates
kubectl apply --validate=false -f cert-manager.yaml
If you want a self-signed certificate you need to apply these 2 files in the selfsigned directory
kubectl apply -f issuer.yaml
kubectl apply -f certificate.yaml
If you want to expose the K8S cluster to the public you need to either connect a DNS through google or use tunneling when port forwarding isn't available on the machine (ISP blocking it)
To open it through tunnel you can use NGrok
ngrok http -region=eu 443