Code Monkey home page Code Monkey logo

gokit-todo's Introduction

gokit-todo

GitHub Workflow Status "GitHub Discussions" GoDev codecov Go Report Card MIT license

Service Description
todo todoMVC backend API
gokit-todo-frontend todoMVC client

gokit-todo

Features

  • 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

Motivation

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

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.

Goals

  • 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 test go-sqlmock and gomock. integration test, e2e test with TestMain and docker-compose
  • DevOps: setup CI/CD workflow to increase devops lifecycle
    • skaffold
    • github action (CI)
    • Kubernetes
    • Istio

Install

this demo support docker-compose or nginx-ingress and istio

Docker-Compose

  1. Run todomvc frontend & gokit-todo backend API with docker-compose
    docker-compose -f docker-compose.full.yaml up -d
  2. Visit http://localhost:8080 for demo
  3. Clean docker-compose
    docker-compose -f docker-compose.full.yaml down --volume

k8s + Istio

  1. Prepare a Kubernetes cluster
  2. Install Istio (1.6.11)
    istioctl install
    kubectl label namespace default istio-injection=enabled
  3. Install gokit-todo & frontend
    kubectl apply -f https://raw.githubusercontent.com/cage1016/gokit-todo/master/deployments/k8s-istio.yaml
  4. 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
  5. Visit $GATEWAY_HTTP_URL to access todomvc with gokit-todo backend API
  6. Delete gokit-todo & frontend
    kubectl delete -f https://raw.githubusercontent.com/cage1016/gokit-todo/master/deployments/k8s-istio.yaml
  7. Uninstall Istio
    istioctl manifest generate | kubectl delete -f -
    kubectl delete namespace istio-system
    kubectl label namespace default istio-injection=enabled --overwrite

k8s + nginx-ingress

  1. Prepare a Kubernetes cluster
  2. Install nginx-ingress CRD by helm3
    helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
    helm repo update
    helm install ingress-nginx ingress-nginx/ingress-nginx
  3. Install gokit-todo & frontend
    kubectl apply -f https://raw.githubusercontent.com/cage1016/gokit-todo/master/deployments/k8s-nginx-ingress.yaml
  4. 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
  5. Visit $INGRESS_HTTP_URL to access todomvc with gokit-todo backend API
  6. Delete gokit-todo & frontend
    kubectl delete -f https://raw.githubusercontent.com/cage1016/gokit-todo/master/deployments/k8s-nginx-ingress.yaml
  7. Uninstall nginx ingress
    helm uninstall ingress-nginx

Testing

  1. 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
  2. unit test
    make test
  3. unit integration test by docker-compose
    make test-integration
  4. unit e2e test by docker-compose
    make test-e2e

License

Copyright © 2020 kaichu.io.
This project is MIT licensed.

gokit-todo's People

Contributors

cage1016 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

maksymtrykur

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.