workspace

module
v0.0.0-...-2cbf6af Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0

README

Workspace

After installing requirements and running the whole project in local environment, you can see todo app for more details on APIs for the ToDo app.

Workspace is a Mono-repository template for building and deploying distributed applications.

Workspace aim to unify and structure your Go applications and deployment model. It comes with a Kit framework for production ready Go application. It also comes with a set a tools for managing and working with the infrastructure, the base model relies on Kubernetes via Kustomize and overlays. Workspace can run on your laptop for ease of development and can be deployed to any cloud providers.

Contents

Why?

Mono repo is a model that aims to group a set of services, tool, and deployment into a single repository, by doing so you can have this benefit “out of the box”;

  • Unify versioning, one source of truth
  • Atomic change
  • Unified deployment model for all applications
  • Enforced tooling (linter, build, code search, etc)
  • Extensive code sharing and reuse
  • Simplified dependency management
  • Large-scale refactoring. codebase modernization
  • Collaboration across teams
  • Flexible team boundaries and code ownership
  • Code visibility and clear tree structure providing implicit team namespacing
The Model

The proposed approach for this mono repo architecture is to follow the namespace your applications per domain strategy. The good part of namespacing our application per domain is that you can structure the code directory to also reflect our Kubernetes namespacing strategies, by doing so you will have a logical and visual representation for the infrastructure and code. This will improve the debugging and conceptualization of the microservice architecture. Another benefit of namespacing the applications is that you will be able to also apply specific resource limits and service account rules per namespace, limiting the resource allocation and visibility of our microservices.

workspace/
├── .github                       # GitHub folder that contain workflow, codeowners and templates
├── README.md
├── Tiltfile                      # Configuration for running a local env
├── go.mod
├── go.sum
├── api                           # Represent our Proto API definition
├── kit                           # Represent the Go framework for building services
├── sample                        # Represent a sample namespace and service
│   ├── sampleapp
│   ├── kustomization.yaml
│   ├── namespace.yaml
│   ├── resource-limit.yaml
│   └── service-account.yaml
├── sdlc                          # Represent a software development tools
├── overlays                      # Represent a deployment mode (local, staging, production)
│   └── local
│       ├── kustomization.yaml
│       └── dependencie           # Represent a dependency configuration
├── vendors                       # Represent all the vendor files
├── .ko.yaml                      # Ko build settings
├── LICENSE                       # Workspace licensing
├── Makefile                      # Simple Makefile for short-cut. run command `make help`
├── golangci.yml                  #  List of linting rules
└── tools.go
Observability

Workspace is built with observability at heat. Kit integrate with OpenTelemetry and local overlays set up the basic Loki, Grafana, Tempo, Prometheus stack. All tracing, login and monitoring endpoint and setting are preset via Kit framework.

Documentation

In order to have more context on the decision and guidelines, you can refer to the documentation folder.

Requirements

You need to have Go installed in your system. The minimal version of Go is 1.20

You can run make onboarding to see if you have required tools missing.

  • Rancher-desktop or Docker-desktop
  • Go brew install go
  • ko brew install ko
  • Kustomize brew install kustomize
  • helm brew install helm
  • vendir brew tap vmware-tanzu/carvel; brew install vendir
  • Tilt brew install tilt
  • Buf and Generate code brew install buf with following binaries
    • go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
    • go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
    • go install github.com/envoyproxy/protoc-gen-validate@latest
    • go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest
    • go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest
  • golangci-lint brew install golangci-lint
  • kubeseal brew install kubeseal
  • mockery brew install mockery

Installation and usage

This workspace is built using ko, Tilt and Go modules.

# First fork or clone the repository
git clone git@github.com:mukhtarkv/ToDoApp.git

# you can run the whole project on your local kubernetes (via docker desktop or rancher desktop)
tilt up

Workspace comes with a simple app that illustrate how to use this framework.

Accessible Dashboard

Directories

Path Synopsis
api
sample/sampleapp/v1
Package sampleappv1 is a reverse proxy.
Package sampleappv1 is a reverse proxy.
todo/todoapp/v1beta1
Package todoappv1beta1 is a reverse proxy.
Package todoappv1beta1 is a reverse proxy.
kit
cache
Package cache contains interfaces for caching data.
Package cache contains interfaces for caching data.
config
Package config provides a simple logic that will read configuration from configmaps, io.Reader or envvar.
Package config provides a simple logic that will read configuration from configmaps, io.Reader or envvar.
errors
Package errors provides simple error handling primitives.
Package errors provides simple error handling primitives.
grpc
Package grpc provides function for managing gRPC system calls (client and server).
Package grpc provides function for managing gRPC system calls (client and server).
id
Package id is a globally unique id generator suited for web scale.
Package id is a globally unique id generator suited for web scale.
log
Package log provides function for managing structured logs.
Package log provides function for managing structured logs.
pagination
Package pagination provides functions for managing next page token pagination as well as a batcher that will dynamically batch size a list query.
Package pagination provides functions for managing next page token pagination as well as a batcher that will dynamically batch size a list query.
pubsub
Package pubsub contains interfaces for publishing data to queues and subscribing and consuming data from those queues.
Package pubsub contains interfaces for publishing data to queues and subscribing and consuming data from those queues.
sql
Package sql provides function for managing connection to various database.
Package sql provides function for managing connection to various database.
telemetry
Package telemetry provides functions for managing instrumented code and measure data about that code's performance and operation.
Package telemetry provides functions for managing instrumented code and measure data about that code's performance and operation.
sample
todo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL