Service | Description |
---|---|
todo | todoMVC backend API |
gokit-todo-frontend | todoMVC client |
- Kubernetes/GKE: The app is designed to run on Kubernetes (both locally on "Docker for Desktop", as well as on the cloud with GKE).
- gRPC: Microservices use a high volume of gRPC calls to communicate to each other.
- Istio: Application works on Istio service mesh.
- Skaffold: Application is deployed to Kubernetes with a single command using Skaffold.
- go-kit/kit: Go kit is a programming toolkit for building microservices (or elegant monoliths) in Go. We solve common problems in distributed systems and application architecture so you can focus on delivering business value.
- todomvc: Helping you select an MV* framework
I use go-kit/kit(microservices toolkit) to build business project and run on Kubernetes and Istio. I also to give few talks about How i use gokit
- GoPherCon 2020 TW: 如何透過 Go-kit 快速搭建微服務架構應用程式實戰 | KaiChu
- GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernete…
- GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
- cage1016/gokit-workshop
Go kit microservices toolkit include many microservices components itself (auth, circuitbreaker, ratelimit etcs.). We build microservices application and deploy to Kubernetes. We could drop those microservices components out with Service Mesh soluation (Istion Envoy proxy) and keep single microservice core business logic clear without any infra codes.
This demo project is todomvc/gokit-todo-frontend backend API implemented by gokit microservice tookit with best practice by myself.
- Project: quick start a new microservice by toolchain cage1016/gk. Team member could follow same guideline to develop microservice quickly.
- project layout
- Testing: how to write
unit
test with table testgo-sqlmock
andgomock
.integration
test,e2e
test withTestMain
anddocker-compose
- DevOps: setup CI/CD workflow to increase devops lifecycle
- skaffold
- github action (CI)
- Kubernetes
- Istio
this demo support docker-compose
or nginx-ingress
and istio
- Run todomvc frontend & gokit-todo backend API with docker-compose
docker-compose -f docker-compose.full.yaml up -d
- Visit http://localhost:8080 for demo
- Clean docker-compose
docker-compose -f docker-compose.full.yaml down --volume
- Prepare a Kubernetes cluster
- Install Istio (1.6.11)
istioctl install kubectl label namespace default istio-injection=enabled
- Install
gokit-todo
&frontend
kubectl apply -f https://raw.githubusercontent.com/cage1016/gokit-todo/master/deployments/k8s-istio.yaml
- Set up
GATEWAY_HTTP_URL
export INGRESS_HTTP_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}') export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') export GATEWAY_HTTP_URL=$INGRESS_HOST:$INGRESS_HTTP_PORT echo $GATEWAY_HTTP_URL
- Visit
$GATEWAY_HTTP_URL
to access todomvc with gokit-todo backend API - Delete
gokit-todo
&frontend
kubectl delete -f https://raw.githubusercontent.com/cage1016/gokit-todo/master/deployments/k8s-istio.yaml
- Uninstall Istio
istioctl manifest generate | kubectl delete -f - kubectl delete namespace istio-system kubectl label namespace default istio-injection=enabled --overwrite
- Prepare a Kubernetes cluster
- Install
nginx-ingress
CRD by helm3helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx helm repo update helm install ingress-nginx ingress-nginx/ingress-nginx
- Install
gokit-todo
&frontend
kubectl apply -f https://raw.githubusercontent.com/cage1016/gokit-todo/master/deployments/k8s-nginx-ingress.yaml
- Set up
INGRESS_HTTP_URL
export INGRESS_HTTP_PORT=$(kubectl get ingress frontend-ingress -o jsonpath='{.spec.rules.*.http.paths.*.backend.servicePort}') export INGRESS_HOST=$(kubectl get ingress frontend-ingress -o jsonpath='{.status.loadBalancer.ingress.*.hostname}') export INGRESS_HTTP_URL=$INGRESS_HOST:$INGRESS_HTTP_PORT echo $INGRESS_HTTP_URL
- Visit
$INGRESS_HTTP_URL
to access todomvc with gokit-todo backend API - Delete
gokit-todo
&frontend
kubectl delete -f https://raw.githubusercontent.com/cage1016/gokit-todo/master/deployments/k8s-nginx-ingress.yaml
- Uninstall nginx ingress
helm uninstall ingress-nginx
Makefile
$ make down docker-compose down generate Regenerates GRPC proto and gomock help this help mod tidy go mod run docker-compose stop & up stop docker-compose stop test test: run unit test test-e2e test-e2e: run e2e test test-integration test-integration: run integration test up docker-compose up
- unit test
make test
- unit integration test by docker-compose
make test-integration
- unit e2e test by docker-compose
make test-e2e