Skip to content

🪙 Coinlog is an assistant to keep track of your personal finance records.

License

Notifications You must be signed in to change notification settings

maestre3d/coinlog

Repository files navigation

🪙 Coinlog

Continuous Integration Go Report Card codebeat badge codecov Go Version

Coinlog is an assistant to keep track of your personal finance records.

How-To

Setup local environment

Coinlog is ready to deploy its infrastructure using Kubernetes (K8s) or docker compose. In this tutorial, K8s is preferred.

First, create namespace and select it:

kubectl apply -f deployments/global.yml
kubectl config set-context --current --namespace=coinlog

Apache Kafka deployment

Build the Apache Kafka docker image contained in kafka deployments folder.

docker build -t coinlog/kafka-kraft ./deployments/kafka

This image is ready to use Kafka 3.4.0 with KRaft consensus protocol (Apache Zookeeper-less).

Then, deploy the image:

kubectl apply -f deployments/kafka/kafka.yml

This will deploy 3 Kafka nodes available at coinlog-kafka.coinlog.svc.cluster.internal port 9092.

Postgres deployment

The Postgres deployment requires to manually create the database coinlog after its deployment. DO NOT deploy application if database was not created otherwise they will get stuck in CrashLoop state.

If kubegres operator not installed, please run the following command:

kubectl apply -f https://raw.githubusercontent.com/reactive-tech/kubegres/v1.16/kubegres.yaml

Reference here.

Then, perform the actual Postgres node deployments:

kubectl apply -f deployments/postgres/postgres.yml

This will deploy 1 master node and 2 replicas.

Get access to shell in Postgres master node (pod/coinlog-postgres-1-0):

kubectl exec -it pod/coinlog-postgres-1-0 -- /bin/sh

Then run (use root as postgres user password) to create database:

psql user=postgres
postgres=# CREATE DATABASE coinlog;

Backend Application deployment

First, build the docker image:

docker build -t coinlog/http-api:0.0.1 -f ./deployments/coinlog-http-api/Dockerfile .

NOTE: Use image tags to perform rolling updates for deployments. Every change will require to update the K8s YAML.

If nginx ingress controller not installed, please run the following command:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.5.1/deploy/static/provider/cloud/deploy.yaml

Reference here.

Then, perform the actual deployment:

kubectl apply -f deployments/coinlog-http-api/coinlog.yml

This will deploy 3 node stateless replicas.

If api.coinlog.info hostname was not set, run the command:

echo "127.0.0.1 api.coinlog.info" >> /etc/hosts

This will enable external traffic to nginx edge proxy.

Finally, export application nodes to cluster-external traffic:

kubectl port-forward services/coinlog-http-api-svc 8080:8080

Or just use nginx ingress (localhost:80 or api.coinlog.info).

More information about k8s nginx ingress controller here.

Frontend Web Application deployment

First, build the docker image:

docker build -t coinlog/web-client:0.0.1 -f ./deployments/coinlog-web-client/Dockerfile ./client/coinlog-web

NOTE: Use image tags to perform rolling updates for deployments. Every change will require to update the K8s YAML.

Then, perform the actual deployment:

kubectl apply -f deployments/coinlog-web-client/coinlog-web.yml

This will deploy 3 node stateless replicas.

If app.coinlog.info hostname was not set, run the command:

echo "127.0.0.1 api.coinlog.info" >> /etc/hosts

This will enable external traffic to nginx edge proxy.

Finally, export application nodes to cluster-external traffic:

kubectl port-forward services/coinlog-http-api-svc 8080:8080

Or just use nginx ingress (localhost:80 or api.coinlog.info).

More information about k8s nginx ingress controller here.

About

🪙 Coinlog is an assistant to keep track of your personal finance records.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published