Skip to content

Microservice CDN written in Go for educational purposes. Full stack deployment.

Notifications You must be signed in to change notification settings

Chris-AS1/go-cdn

Repository files navigation

Go-CDN

Microservice that serves image BLOBs via a REST API, using the following services:

Architecture

architecture

Configuration Sample (configs.yaml)

consul:
  enable: 
  service_name:    # Service under which the microservices will be registered. Each one will have an unique id.
  service_address: # Either auto or manually set. auto finds the first non-loopback address.
  address: 
  datacenter: 
  port: 

redis:
  enable:       # Optional
  host:         # If Consul is enabled then this is the service name, otherwise ip:port
  password: 
  db: 

postgres:
  host:         # If Consul is enabled then this is the service name, otherwise ip:port
  database: 
  username:
  password: 
  ssl:              # Optional

http:
  port:             # Optional
  allow_insert: 
  allow_delete:
  rate_limit_enable:
  rate_limit:       # RPS

telemetry:
  enable: 
  jaeger_address:    # If Consul is enabled then this is the service name, otherwise ip:port
  sampling:          # Optional
  logs_path: 
  logs_max_size:     # Optional
  logs_max_backups:  # Optional
  logs_max_age:      # Optional

Docker Deployment

Build the image

docker build -t local/go-cdn .

Run

docker run -v "./configs/config-docker.yaml:/cdn/configs.yaml:ro" --net "cdn-default" -d local/go-cdn

Docker Compose

Check the provided docker-compose.yml for a deployment example. The provided stack contains an example Consul container for demo purposes.

docker compose build 
docker compose up -d
docker compose logs -f

Kubernetes Deployment

Apply all the deployments.

kubectl apply -f .

Testing

Due the nature of Go, tests are ran inside their respective packages. This creates confusion with the relative paths regarding configs and migrations. To get around this limitation it's possible to compile each test individually, and then run it from the root of the folder:

go test -c ./...
./{PACKAGE}.test 

Otherwise use:

make test

About

Microservice CDN written in Go for educational purposes. Full stack deployment.

Resources

Stars

Watchers

Forks