Skip to content
/ goilerplate Public template

Go + Boilerplate πŸ”₯πŸ”₯πŸ”₯

License

Notifications You must be signed in to change notification settings

slowhigh/goilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5958196 Β· Jan 29, 2024
Apr 8, 2023
Apr 8, 2023
Nov 9, 2022
Dec 6, 2022
Dec 12, 2022
Apr 8, 2023
Apr 8, 2023
Apr 22, 2023
Dec 6, 2022
Dec 12, 2022
Dec 12, 2022
Dec 12, 2022
Mar 13, 2023
Apr 8, 2023
May 10, 2022
Apr 22, 2023
Jan 29, 2024
Dec 6, 2022
Dec 6, 2022
Nov 9, 2022

Repository files navigation

Goilerplate

For the perfect template. πŸ”₯πŸ”₯πŸ”₯

Contents

Features

Structure

  • Routing - Gin Web Framework ---------------------------- πŸ“š :octocat:
  • CLI - Cobra ------------------------------------------------- πŸ“š :octocat:
  • DI pattern - Fx --------------------------------------------- πŸ“š :octocat:
  • Environment - Viper --------------------------------------- :octocat:
  • Logging - Zap ---------------------------------------------- :octocat:
  • PostgreSQL ORM - GORM --------------------------------- πŸ“š :octocat:
  • Redis ORM - Go-Redis ------------------------------------- πŸ“š :octocat:
  • DB Viewer - pgAdmin4 (Web) ----------------------------- πŸ“š 🐳 :octocat:
  • Authentication - JWT (Access + Refresh) ----------------- πŸ“š :octocat:
  • Makefile - make -------------------------------------------- πŸ“š
  • CI/CD - GitHub-Actions ------------------------------------ πŸ“š

Infra

  • CNI(Container Network Interface)- flannel --------------- :octocat:
  • Load Balancer - MetalLB ----------------------------------- πŸ“š :octocat:
  • Ingress - NGINX -------------------------------------------- πŸ“š
  • AutoScaling - k8s-HPA ------------------------------------- πŸ“š

Kubernetes

Network

Load Balancer

Ingress

Auto Scaling

API

PostgreSQL

pgAdmin4

Redis

Quick start

Make sure you have make installed.

$ sudo apt install make

Kubernetes in Docker Desktop (localhost)

$ make deploy-to-docker-desktop
API Server URL (api.localhost)

Run in Postman

pgAdmin4 URL

https://pgadimin4.localhost

Kubernetes in Public Cloud (goilerplate.com)

# Check the IP of the Kubernetes control plane.
$ kubectl cluster-info
Kubernetes control plane is running at https://10.0.0.8:6443
CoreDNS is running at https://10.0.0.8:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

# Edit the addresses of ipaddress-pools.yaml.
$ vi k8s/ipaddress-pools.yaml
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: first-pool
  namespace: metallb-system
spec:
  addresses:
  - 10.0.0.8-10.0.0.8             <---- edit IP
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: l2-advert
  namespace: metallb-system

$ make deploy-to-cloud
API Server (api.goilerplate.com)

Run in Postman

pgAdmin4

https://pgadimin4.localhost

Makefile Macros

Docker Control

# Push the API Docker Image to the DockerHub.
$ make push_api

# Push the PostgreSQL Docker Image to the DockerHub.
$ make push_postgres

# Push the Redi Docker Image to the DockerHub.
$ make push_redis

# Push the pgAdmin4 Docker Image to the DockerHub.
$ make push_pgadmin4

# Push the All Docker Image to the DockerHub.
$ make push_all

Kubectl Control

# Deploy to the Docker Desktop. (WSL + Docker Desktop)
$ make deploy-to-docker-desktop

# Undeploy to the Docker Desktop. (WSL + Docker Desktop)
$ make delete-to-docker-desktop

# Deploy to the Public Cloud.
$ make deploy-to-cloud

# Undeploy to the Public Cloud.
$ make delete-to-cloud