SlideShare a Scribd company logo
1 of 52
Download to read offline
Build go kit Microservices at
Kubernetes with ease
2019/12/1
Cage Chung
@CageChung @cage1016
cage.chung@gmail.com
GDG Cloud Taipei co-organizer,
Google Developer Expert (GCP)
*photo*
We heritage the enthusiasm of Google Cloud Platform User Group
to create Taipei chapter
GDG Cloud Taipei Meetup #50
2019/12/12 at Google Taipei 101 Office 14F
● 我們與Kubernetes的距離, Astley Chen / GDG Cloud Taipei co-organizer, DevOps
engineer, Cloud Solution Architect
● Build go kit Microservices at Kubernetes with ease, Cage Chung / GDG Cloud Taipei
co-organizer, GDE (GCP)
Agenda
gokitconsulk8s
Go-kit
Service Mesh
Gokitconsulk8s
go kit microservice demo with consul & zipkin at kubernetes
Gokitconsulk8s
3 microservice
Router
● HTTP
● GRPC
Addsvc
● sum
● concat
Foosvc
● foo
Consul (service discovery)
Tracing (trace service)
Prometheus (monitor)
Grafana (monitor)
Fluentd (log)
Elasticsearch (log)
Kibana (log)
Gokitconsulk8s
https://github.com/cage1016/gokitconsulk8s
Gokitconsulk8s - Consul
https://github.com/cage1016/gokitconsulk8s
Gokitconsulk8s - Tracing
https://github.com/cage1016/gokitconsulk8s
Gokitconsulk8s - Prometheus
https://github.com/cage1016/gokitconsulk8s
Gokitconsulk8s - Grafana
https://github.com/cage1016/gokitconsulk8s
Gokitconsulk8s - Kibana
https://github.com/cage1016/gokitconsulk8s
$ kubectl get po
NAME READY STATUS RESTARTS AGE
addsvc-64d7d45464-jxfp6 3/3 Running 0 36m
ch-consul-connect-injector-webhook-deployment-679fcb48f-lnmt6 1/1 Running 0 37m
ch-consul-f7cj6 1/1 Running 0 37m
ch-consul-m89hf 1/1 Running 0 37m
ch-consul-qv6ms 1/1 Running 0 37m
ch-consul-server-0 1/1 Running 0 37m
ch-consul-w2lqw 1/1 Running 0 37m
ch-consul-xg5rb 1/1 Running 0 37m
foosvc-5c468bd6dd-2fflp 3/3 Running 0 36m
ingress-grpc-648786cf85-ddqsr 2/2 Running 0 36m
ingress-http-7b7b9c68f-7kwbz 2/2 Running 0 36m
router-grpc-5db4f9699b-q9qcq 2/2 Running 0 36m
router-http-5b55cf45b-57zwn 2/2 Running 0 36m
website-554db99b57-9cq9d 2/2 Running 0 36m
zipkin-5bb9d87c78-84pmk 2/2 Running 0 36m
├── cmd
│ ├── addsvc
│ │ └── main.go
│ ├── foosvc
│ │ └── main.go
│ └── router
│ └── main.go
├── consul-helm
├── deployments
│ ├── docker
│ │ ├── Dockerfile
│ │ ├── Dockerfile.cleanbuild
│ │ └── Dockerfile.debug
│ └── k8s
│ ├── website
│ ├── addsvc.yaml
│ ├── foosvc.yaml
│ ├── ingress-grpc.yaml
│ ├── ingress-http.yaml
│ ├── router-grpc.yaml
│ ├── router-http.yaml
│ ├── service-monitor.yaml
│ ├── website.yaml
│ ├── zipkin-deployment.yaml
│ └── zipkin-service.yaml
├── pkg
│ ├── addsvc
│ │ ├── endpoints
│ │ ├── service
│ │ └── transports
│ ├── foosvc
│ │ ├── endpoints
│ │ │ ├── endpoints.go
│ │ │ ├── middleware.go
│ │ │ ├── requests.go
│ │ │ └── responses.go
│ │ ├── service
│ │ │ ├── logging.go
│ │ │ └── service.go
│ │ └── transports
│ │ ├── errors.go
│ │ ├── grpc.go
│ │ └── http.go
│ └── router
│ └── transports
├── makefile
└── skaffold.yaml
## gateway sum
$ curl -X "POST" "http://34.80.152.38:8080/api/addsvc/sum" -H 'Content-Type: application/json; charset=utf-8' -d '{ "a": 3, "b": 34}'
{"rs":37,"err":null}
## gateway concat
$ curl -X "POST" "http://34.80.152.38:8080/api/addsvc/concat" -H 'Content-Type: application/json; charset=utf-8' -d '{ "a": "3", "b":
"34"}'
{"rs":"334","err":null}
## gateway foo
$ curl -X "POST" "http://34.80.152.38:8080/api/foosvc/foo" -H 'Content-Type: application/json; charset=utf-8' -d '{"s": "3ddd"}'
{"res":"3dddbar","err":null}
## grpc sum
$ grpcurl -plaintext -proto ./pb/addsvc/addsvc.proto -d '{"a": 3, "b":5}' 35.221.190.225:8081 pb.Addsvc.Sum
{
"rs": "8"
}
## grpc concat
$ grpcurl -plaintext -proto ./pb/addsvc/addsvc.proto -d '{"a": "3", "b":"5"}' 35.221.190.225:8081 pb.Addsvc.Concat
{
"rs": "35"
}
## grpc foo
$ grpcurl -plaintext -proto ./pb/foosvc/foosvc.proto -d '{"s": "foo"}' 35.221.190.225:8081 pb.Foosvc.Foo
{
"res": "foobar"
}
Demo
https://github.com/cage1016/gokitconsulk8s
Go-kit
Toolkit for microservices
Microservice solve
organizational problems
~
Microservice cause
technical problems
Problem solved
1. Team are blocked on other teams, can’t make progress
2. Product velocity stalled
Problem cause
1. Testing becomes really hard
2. Build pipelines
3. Requires dev/ops culture: devs deploy and operate their work
4. Monitoring and instrumentation - tailing logs?
5. Distributed tracing
6. Security
Go-kit goals
1. Make Go a first-class citizen for business logic
2. Microservice architecture
3. RPC as the messaging pattern
4. Provide best practices, idioms, examples and patterns
Golang UK Conference 2015 - Peter Bourgon - Go Kit A Toolkit for Microservices - https://www.youtube.com/watch?v=aL6sd4d4hxk
Go-kit non-goals
1. Be a turnkey solution
2. Require any specific infrastructure
3. Have opinions about orchestration, configuration, etc.
Golang UK Conference 2015 - Peter Bourgon - Go Kit A Toolkit for Microservices - https://www.youtube.com/watch?v=aL6sd4d4hxk
Go HTTP Servers
package main
import (
"fmt"
"net/http"
)
func hello(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "Hello Devfest Taipei 2019")
}
func main() {
http.HandleFunc("/", hello)
http.ListenAndServe(":8888", nil)
}
type Addsvc interface {
sum(a, b int64) (int64, error)
}
type SumRequest struct {
A int64 `json:"a"`
B int64 `json:"b"`
}
Add service: service and implement
func (s *addService) sum(a, b int64) (int64, error) {
return a + b, nil
}
type addService struct{}
Transports: Implement HTTP handler
func (s *addService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodPost:
var req SumRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
if res, err := s.sum(req.A, req.B); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
} else {
fmt.Fprint(w, res)
}
}
}
main
func main() {
http.ListenAndServe(":8888", &addService{})
}
$ go run main.go
$ curl -X "POST" "http://localhost:8888" -d '{ "a": 3, "b": 34}'
37
Addservice an HTTP handler, we can pass it to ListenAndServe
Logging: try to add logging
func (s *addService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodPost:
var req SumRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
code := http.StatusBadRequest
http.Error(w, err.Error(), code)
log.Printf("%s: %s %s %d", r.RemoteAddr, r.Method, r.URL, code)
return
}
if res, err := s.sum(req.A, req.B); err != nil {
code := http.StatusInternalServerError
http.Error(w, err.Error(), code)
log.Printf("%s: %s %s %d", r.RemoteAddr, r.Method, r.URL, code)
return
} else {
log.Printf("%s: %s %s %d", r.RemoteAddr, r.Method, r.URL, 200)
fmt.Fprint(w, res)
}
}
Logging
func main() {
log.Printf("listening on :8888")
log.Fatal(http.ListenAndServe(":8888", &addService{}))
}
$ go run main.go
2019/11/29 15:24:29 listening on :8888
2019/11/29 15:24:32 [::1]:52200: POST / 200
$ curl -X "POST" "http://localhost:8888" -d '{ "a": 3, "b": 34}'
37
Endpoint
type Endpoint func(request) (response)
Endpoint is the fundamental building block of servers and clients.It represents a
single RPC method.
type Endpoint func(ctx context.Context, request interface{}) (response interface{}, err error)
Add service endpoint
func MakePostSumEndpoint(s addService) endpoint.Endpoint {
return func(_ context.Context, request interface{}) (response interface{}, err error) {
p := request.(SumRequest)
return s.sum(p.A, p.B)
}
}
Create endpoint by add service constructor and keep add service pure
Endpoint middleware
Middleware is a chainable behavior modifier for endpoints.
type Middleware func(Endpoint) Endpoint
Logging middleware
func loggingMiddleware(next endpoint.Endpoint) endpoint.Endpoint {
return func(ctx context.Context, request interface{}) (response interface{}, err error) {
begin := time.Now()
defer func() {
log.Printf("request took %s", time.Since(begin))
}()
return next(ctx, request)
}
}
s := addService{}
var e endpoint.Endpoint
e = MakePostSumEndpoint(s)
e = loggingMiddleware(e)
Create endpoint by add service constructor and keep add service pure
Http transport
func NewServer(
e endpoint.Endpoint,
dec DecodeRequestFunc,
enc EncodeResponseFunc,
options ...ServerOption,
) *Server { ... }
postSum := httptransport.NewServer(e, decodeHTTPSumRequest, httptransport.EncodeJSONResponse)
r := mux.NewRouter()
r.Methods(http.MethodPost).Handler(postSum)
log.Printf("listening on :8888")
log.Fatal(http.ListenAndServe(":8888", r))
Go kit comes with handy HTTP transport. NewServer constructs a new server,
which implements http.Handler and wraps the provided endpoint.
Design — How is a Go kit microservice modeled?
https://gokit.io/faq/#design-mdash-how-is-a-go-kit-microservice-modeled
Transport
Endpoint
Service
Go + microservices = Go kit - Speaker Deck - https://speakerdeck.com/peterbourgon/go-plus-microservices-equals-go-kit?slide=78
Golang UK Conference 2015 - Peter Bourgon - Go Kit A Toolkit for Microservices - https://youtu.be/aL6sd4d4hxk?t=1022
● Authentication: Basic, casbin, JWT.
● Circuit Breaker: Hystrix, GoBreaker, and HandyBreaker.
● Logging: Provide an interface for structured logging. Recognizes
that logs are data. They need context and semantics to be useful
for analysis. Supported formats are logfmt and JSON.
● Metrics: Provides uniform interfaces for service instrumentation.
Comes with counters, gauges, and histograms. Has adapters for
CloudWatch, Prometheus, Graphite, DogStatsD, StatsD, expvar,
and more.
● Rate Limit: Uses Go's token bucket implementation.
● Service Discovery: Consul, DNS SRV, etcd, Eureka, ZooKeeper,
and more.
● Tracing: OpenCensus, OpenTracing, and Zipkin.
● Transport: AMQP, AWS Lambda, gRPC, HTTP, NATS, Thrift.
.
├── auth
├── circuitbreaker
├── cmd
├── endpoint
├── examples
├── log
├── metrics
├── ratelimit
├── sd
├── tracing
├── transport
├── util
├── .build.yml
├── .gitignore
├── .travis.yml
Demo
Gokit generator: squaresvc
Service mesh
Microservice cause
technical problems
~
Service Mesh solve technical
problems
What Is a Service Mesh? By NGINX
1. Container orchestration framework
2. Services and instances (Kubernetes pods).
3. Sidecar proxy
4. Service discovery
5. Load balancing
6. Encryption
7. Authentication and authorization
8. Support for the circuit breaker pattern
What Is a Service Mesh? - NGINX - https://www.nginx.com/blog/what-is-a-service-mesh/
The control plane in a service mesh distributes configuration across the sidecar
proxies in the data plane
What Is a Service Mesh? - NGINX - https://www.nginx.com/blog/what-is-a-service-mesh/
Consul by HashiCorp - https://www.consul.io/
Gokitconsulk8s
https://github.com/cage1016/gokitconsulk8s
addsvc.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: addsvc
name: addsvc
spec:
replicas: 1
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: addsvc
annotations:
"consul.hashicorp.com/connect-inject": "true"
"consul.hashicorp.com/connect-service": "addsvc"
"consul.hashicorp.com/connect-service-port": "8021"
"consul.hashicorp.com/connect-service-protocol": "grpc"
"consul.hashicorp.com/connect-service-upstreams": "zipkin:9411"
Consul vs. Istio
Consul Service Mesh实战【转】 - 简书 - https://www.jianshu.com/p/ad970554403d
Reference
1. Go + Microservices = Go Kit [I] - Peter Bourgon, Go Kit
2. Go kit
3. https://gokit.io/faq/
4. cage1016/gokitconsulk8s
5. cage1016/gk
6. What Is a Service Mesh?
THANK YOU
Q & A

More Related Content

What's hot

How to stay sane during your Vagrant journey
How to stay sane during your Vagrant journeyHow to stay sane during your Vagrant journey
How to stay sane during your Vagrant journeyJakub Wadolowski
 
Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;
Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;
Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;Tzung-Bi Shih
 
The Challenges of Container Configuration
The Challenges of Container ConfigurationThe Challenges of Container Configuration
The Challenges of Container ConfigurationGareth Rushgrove
 
Global Interpreter Lock: Episode I - Break the Seal
Global Interpreter Lock: Episode I - Break the SealGlobal Interpreter Lock: Episode I - Break the Seal
Global Interpreter Lock: Episode I - Break the SealTzung-Bi Shih
 
Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)Soshi Nemoto
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Rajmahendra Hegde
 
Moving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresMoving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresFrits Van Der Holst
 
G*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョンG*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョンTsuyoshi Yamamoto
 
Docker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil TayarDocker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil TayarApplitools
 
Asynchronní programování
Asynchronní programováníAsynchronní programování
Asynchronní programováníPeckaDesign.cz
 
Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Chris Ramsdale
 
Heroku 101 py con 2015 - David Gouldin
Heroku 101   py con 2015 - David GouldinHeroku 101   py con 2015 - David Gouldin
Heroku 101 py con 2015 - David GouldinHeroku
 
Google Developer Fest 2010
Google Developer Fest 2010Google Developer Fest 2010
Google Developer Fest 2010Chris Ramsdale
 

What's hot (20)

How to stay sane during your Vagrant journey
How to stay sane during your Vagrant journeyHow to stay sane during your Vagrant journey
How to stay sane during your Vagrant journey
 
(Re)discover your AEM
(Re)discover your AEM(Re)discover your AEM
(Re)discover your AEM
 
Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;
Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;
Global Interpreter Lock: Episode III - cat < /dev/zero > GIL;
 
The Challenges of Container Configuration
The Challenges of Container ConfigurationThe Challenges of Container Configuration
The Challenges of Container Configuration
 
Global Interpreter Lock: Episode I - Break the Seal
Global Interpreter Lock: Episode I - Break the SealGlobal Interpreter Lock: Episode I - Break the Seal
Global Interpreter Lock: Episode I - Break the Seal
 
Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
Everything as a code
Everything as a codeEverything as a code
Everything as a code
 
Taming AEM deployments
Taming AEM deploymentsTaming AEM deployments
Taming AEM deployments
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
 
Moving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresMoving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventures
 
G*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョンG*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョン
 
Gokit
GokitGokit
Gokit
 
Puppet Data Mining
Puppet Data MiningPuppet Data Mining
Puppet Data Mining
 
Docker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil TayarDocker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil Tayar
 
Asynchronní programování
Asynchronní programováníAsynchronní programování
Asynchronní programování
 
Gradle in 45min
Gradle in 45minGradle in 45min
Gradle in 45min
 
Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010
 
Heroku 101 py con 2015 - David Gouldin
Heroku 101   py con 2015 - David GouldinHeroku 101   py con 2015 - David Gouldin
Heroku 101 py con 2015 - David Gouldin
 
Google Developer Fest 2010
Google Developer Fest 2010Google Developer Fest 2010
Google Developer Fest 2010
 

Similar to GDG Devfest 2019 - Build go kit microservices at kubernetes with ease

如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰KAI CHU CHUNG
 
Protobuf & Code Generation + Go-Kit
Protobuf & Code Generation + Go-KitProtobuf & Code Generation + Go-Kit
Protobuf & Code Generation + Go-KitManfred Touron
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScriptQiangning Hong
 
Job Queue in Golang
Job Queue in GolangJob Queue in Golang
Job Queue in GolangBo-Yi Wu
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構Bo-Yi Wu
 
Improving go-git performance
Improving go-git performanceImproving go-git performance
Improving go-git performancesource{d}
 
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...dantleech
 
Ruby on Rails vs ASP.NET MVC
Ruby on Rails vs ASP.NET MVCRuby on Rails vs ASP.NET MVC
Ruby on Rails vs ASP.NET MVCSimone Chiaretta
 
How to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking NeedsHow to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking NeedsDigitalOcean
 
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes  with ...GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes  with ...
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...KAI CHU CHUNG
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomyDongmin Yu
 
Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019Joe Keeley
 
Net/http and the http.handler interface
Net/http and the http.handler interfaceNet/http and the http.handler interface
Net/http and the http.handler interfaceJoakim Gustin
 
Net/http and the http.handler interface
Net/http and the http.handler interfaceNet/http and the http.handler interface
Net/http and the http.handler interfaceEvolve
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopSages
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기NAVER D2
 

Similar to GDG Devfest 2019 - Build go kit microservices at kubernetes with ease (20)

如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
 
Protobuf & Code Generation + Go-Kit
Protobuf & Code Generation + Go-KitProtobuf & Code Generation + Go-Kit
Protobuf & Code Generation + Go-Kit
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript
 
gRPC in Go
gRPC in GogRPC in Go
gRPC in Go
 
Server Side Swift: Vapor
Server Side Swift: VaporServer Side Swift: Vapor
Server Side Swift: Vapor
 
Job Queue in Golang
Job Queue in GolangJob Queue in Golang
Job Queue in Golang
 
Intro to PSGI and Plack
Intro to PSGI and PlackIntro to PSGI and Plack
Intro to PSGI and Plack
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構
 
Improving go-git performance
Improving go-git performanceImproving go-git performance
Improving go-git performance
 
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
 
Ruby on Rails vs ASP.NET MVC
Ruby on Rails vs ASP.NET MVCRuby on Rails vs ASP.NET MVC
Ruby on Rails vs ASP.NET MVC
 
How to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking NeedsHow to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking Needs
 
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes  with ...GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes  with ...
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019
 
Net/http and the http.handler interface
Net/http and the http.handler interfaceNet/http and the http.handler interface
Net/http and the http.handler interface
 
Net/http and the http.handler interface
Net/http and the http.handler interfaceNet/http and the http.handler interface
Net/http and the http.handler interface
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache Hadoop
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 

More from KAI CHU CHUNG

Devfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdfDevfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdfKAI CHU CHUNG
 
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdfDevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdfKAI CHU CHUNG
 
DevFest 2022 - Cloud Workstation Introduction TaiChung
DevFest 2022 - Cloud Workstation Introduction TaiChungDevFest 2022 - Cloud Workstation Introduction TaiChung
DevFest 2022 - Cloud Workstation Introduction TaiChungKAI CHU CHUNG
 
Devfest 2021' - Artifact Registry Introduction (Taipei)
Devfest 2021' - Artifact Registry Introduction (Taipei)Devfest 2021' - Artifact Registry Introduction (Taipei)
Devfest 2021' - Artifact Registry Introduction (Taipei)KAI CHU CHUNG
 
Velero search & practice 20210609
Velero search & practice 20210609Velero search & practice 20210609
Velero search & practice 20210609KAI CHU CHUNG
 
Gdg cloud taipei ddt meetup #53 buildpack
Gdg cloud taipei ddt meetup #53 buildpackGdg cloud taipei ddt meetup #53 buildpack
Gdg cloud taipei ddt meetup #53 buildpackKAI CHU CHUNG
 
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...KAI CHU CHUNG
 
Google App Engine: Basic
Google App Engine: BasicGoogle App Engine: Basic
Google App Engine: BasicKAI CHU CHUNG
 
Global GDG Leaders Summit, Google I/O 2018 經驗分享
Global GDG Leaders Summit, Google I/O 2018 經驗分享Global GDG Leaders Summit, Google I/O 2018 經驗分享
Global GDG Leaders Summit, Google I/O 2018 經驗分享KAI CHU CHUNG
 
Google apps script introduction
Google apps script introductionGoogle apps script introduction
Google apps script introductionKAI CHU CHUNG
 
Screenshot as a service
Screenshot as a serviceScreenshot as a service
Screenshot as a serviceKAI CHU CHUNG
 
Nas 也可以揀土豆
Nas 也可以揀土豆Nas 也可以揀土豆
Nas 也可以揀土豆KAI CHU CHUNG
 
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開KAI CHU CHUNG
 
Django oscar introduction
Django oscar introductionDjango oscar introduction
Django oscar introductionKAI CHU CHUNG
 
Continuous Integration & Continuous Delivery with GCP
Continuous Integration & Continuous Delivery with GCPContinuous Integration & Continuous Delivery with GCP
Continuous Integration & Continuous Delivery with GCPKAI CHU CHUNG
 
Google apps script introduction
Google apps script introductionGoogle apps script introduction
Google apps script introductionKAI CHU CHUNG
 
Gae managed vm introduction
Gae managed vm introductionGae managed vm introduction
Gae managed vm introductionKAI CHU CHUNG
 
Google app engine (gae) 演進史
Google app engine (gae) 演進史Google app engine (gae) 演進史
Google app engine (gae) 演進史KAI CHU CHUNG
 
痞客趴趴走 Waldo
痞客趴趴走   Waldo痞客趴趴走   Waldo
痞客趴趴走 WaldoKAI CHU CHUNG
 

More from KAI CHU CHUNG (20)

Devfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdfDevfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdf
 
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdfDevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
 
DevFest 2022 - Cloud Workstation Introduction TaiChung
DevFest 2022 - Cloud Workstation Introduction TaiChungDevFest 2022 - Cloud Workstation Introduction TaiChung
DevFest 2022 - Cloud Workstation Introduction TaiChung
 
Devfest 2021' - Artifact Registry Introduction (Taipei)
Devfest 2021' - Artifact Registry Introduction (Taipei)Devfest 2021' - Artifact Registry Introduction (Taipei)
Devfest 2021' - Artifact Registry Introduction (Taipei)
 
Velero search & practice 20210609
Velero search & practice 20210609Velero search & practice 20210609
Velero search & practice 20210609
 
Gdg cloud taipei ddt meetup #53 buildpack
Gdg cloud taipei ddt meetup #53 buildpackGdg cloud taipei ddt meetup #53 buildpack
Gdg cloud taipei ddt meetup #53 buildpack
 
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
 
Google App Engine: Basic
Google App Engine: BasicGoogle App Engine: Basic
Google App Engine: Basic
 
Global GDG Leaders Summit, Google I/O 2018 經驗分享
Global GDG Leaders Summit, Google I/O 2018 經驗分享Global GDG Leaders Summit, Google I/O 2018 經驗分享
Global GDG Leaders Summit, Google I/O 2018 經驗分享
 
Google apps script introduction
Google apps script introductionGoogle apps script introduction
Google apps script introduction
 
Screenshot as a service
Screenshot as a serviceScreenshot as a service
Screenshot as a service
 
Nas 也可以揀土豆
Nas 也可以揀土豆Nas 也可以揀土豆
Nas 也可以揀土豆
 
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
 
Django oscar introduction
Django oscar introductionDjango oscar introduction
Django oscar introduction
 
Continuous Integration & Continuous Delivery with GCP
Continuous Integration & Continuous Delivery with GCPContinuous Integration & Continuous Delivery with GCP
Continuous Integration & Continuous Delivery with GCP
 
Google apps script introduction
Google apps script introductionGoogle apps script introduction
Google apps script introduction
 
Gae managed vm introduction
Gae managed vm introductionGae managed vm introduction
Gae managed vm introduction
 
Google app engine (gae) 演進史
Google app engine (gae) 演進史Google app engine (gae) 演進史
Google app engine (gae) 演進史
 
痞客趴趴走 Waldo
痞客趴趴走   Waldo痞客趴趴走   Waldo
痞客趴趴走 Waldo
 
Waldo-gcp
Waldo-gcpWaldo-gcp
Waldo-gcp
 

Recently uploaded

Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 

GDG Devfest 2019 - Build go kit microservices at kubernetes with ease

  • 1.
  • 2. Build go kit Microservices at Kubernetes with ease 2019/12/1
  • 3. Cage Chung @CageChung @cage1016 cage.chung@gmail.com GDG Cloud Taipei co-organizer, Google Developer Expert (GCP) *photo*
  • 4. We heritage the enthusiasm of Google Cloud Platform User Group to create Taipei chapter
  • 5.
  • 6. GDG Cloud Taipei Meetup #50 2019/12/12 at Google Taipei 101 Office 14F ● 我們與Kubernetes的距離, Astley Chen / GDG Cloud Taipei co-organizer, DevOps engineer, Cloud Solution Architect ● Build go kit Microservices at Kubernetes with ease, Cage Chung / GDG Cloud Taipei co-organizer, GDE (GCP)
  • 8. Gokitconsulk8s go kit microservice demo with consul & zipkin at kubernetes
  • 9. Gokitconsulk8s 3 microservice Router ● HTTP ● GRPC Addsvc ● sum ● concat Foosvc ● foo Consul (service discovery) Tracing (trace service) Prometheus (monitor) Grafana (monitor) Fluentd (log) Elasticsearch (log) Kibana (log)
  • 16. $ kubectl get po NAME READY STATUS RESTARTS AGE addsvc-64d7d45464-jxfp6 3/3 Running 0 36m ch-consul-connect-injector-webhook-deployment-679fcb48f-lnmt6 1/1 Running 0 37m ch-consul-f7cj6 1/1 Running 0 37m ch-consul-m89hf 1/1 Running 0 37m ch-consul-qv6ms 1/1 Running 0 37m ch-consul-server-0 1/1 Running 0 37m ch-consul-w2lqw 1/1 Running 0 37m ch-consul-xg5rb 1/1 Running 0 37m foosvc-5c468bd6dd-2fflp 3/3 Running 0 36m ingress-grpc-648786cf85-ddqsr 2/2 Running 0 36m ingress-http-7b7b9c68f-7kwbz 2/2 Running 0 36m router-grpc-5db4f9699b-q9qcq 2/2 Running 0 36m router-http-5b55cf45b-57zwn 2/2 Running 0 36m website-554db99b57-9cq9d 2/2 Running 0 36m zipkin-5bb9d87c78-84pmk 2/2 Running 0 36m
  • 17. ├── cmd │ ├── addsvc │ │ └── main.go │ ├── foosvc │ │ └── main.go │ └── router │ └── main.go ├── consul-helm ├── deployments │ ├── docker │ │ ├── Dockerfile │ │ ├── Dockerfile.cleanbuild │ │ └── Dockerfile.debug │ └── k8s │ ├── website │ ├── addsvc.yaml │ ├── foosvc.yaml │ ├── ingress-grpc.yaml │ ├── ingress-http.yaml │ ├── router-grpc.yaml │ ├── router-http.yaml │ ├── service-monitor.yaml │ ├── website.yaml │ ├── zipkin-deployment.yaml │ └── zipkin-service.yaml ├── pkg │ ├── addsvc │ │ ├── endpoints │ │ ├── service │ │ └── transports │ ├── foosvc │ │ ├── endpoints │ │ │ ├── endpoints.go │ │ │ ├── middleware.go │ │ │ ├── requests.go │ │ │ └── responses.go │ │ ├── service │ │ │ ├── logging.go │ │ │ └── service.go │ │ └── transports │ │ ├── errors.go │ │ ├── grpc.go │ │ └── http.go │ └── router │ └── transports ├── makefile └── skaffold.yaml
  • 18. ## gateway sum $ curl -X "POST" "http://34.80.152.38:8080/api/addsvc/sum" -H 'Content-Type: application/json; charset=utf-8' -d '{ "a": 3, "b": 34}' {"rs":37,"err":null} ## gateway concat $ curl -X "POST" "http://34.80.152.38:8080/api/addsvc/concat" -H 'Content-Type: application/json; charset=utf-8' -d '{ "a": "3", "b": "34"}' {"rs":"334","err":null} ## gateway foo $ curl -X "POST" "http://34.80.152.38:8080/api/foosvc/foo" -H 'Content-Type: application/json; charset=utf-8' -d '{"s": "3ddd"}' {"res":"3dddbar","err":null} ## grpc sum $ grpcurl -plaintext -proto ./pb/addsvc/addsvc.proto -d '{"a": 3, "b":5}' 35.221.190.225:8081 pb.Addsvc.Sum { "rs": "8" } ## grpc concat $ grpcurl -plaintext -proto ./pb/addsvc/addsvc.proto -d '{"a": "3", "b":"5"}' 35.221.190.225:8081 pb.Addsvc.Concat { "rs": "35" } ## grpc foo $ grpcurl -plaintext -proto ./pb/foosvc/foosvc.proto -d '{"s": "foo"}' 35.221.190.225:8081 pb.Foosvc.Foo { "res": "foobar" }
  • 22. Problem solved 1. Team are blocked on other teams, can’t make progress 2. Product velocity stalled
  • 23. Problem cause 1. Testing becomes really hard 2. Build pipelines 3. Requires dev/ops culture: devs deploy and operate their work 4. Monitoring and instrumentation - tailing logs? 5. Distributed tracing 6. Security
  • 24. Go-kit goals 1. Make Go a first-class citizen for business logic 2. Microservice architecture 3. RPC as the messaging pattern 4. Provide best practices, idioms, examples and patterns Golang UK Conference 2015 - Peter Bourgon - Go Kit A Toolkit for Microservices - https://www.youtube.com/watch?v=aL6sd4d4hxk
  • 25. Go-kit non-goals 1. Be a turnkey solution 2. Require any specific infrastructure 3. Have opinions about orchestration, configuration, etc. Golang UK Conference 2015 - Peter Bourgon - Go Kit A Toolkit for Microservices - https://www.youtube.com/watch?v=aL6sd4d4hxk
  • 26. Go HTTP Servers package main import ( "fmt" "net/http" ) func hello(w http.ResponseWriter, req *http.Request) { fmt.Fprintf(w, "Hello Devfest Taipei 2019") } func main() { http.HandleFunc("/", hello) http.ListenAndServe(":8888", nil) }
  • 27. type Addsvc interface { sum(a, b int64) (int64, error) } type SumRequest struct { A int64 `json:"a"` B int64 `json:"b"` } Add service: service and implement func (s *addService) sum(a, b int64) (int64, error) { return a + b, nil } type addService struct{}
  • 28. Transports: Implement HTTP handler func (s *addService) ServeHTTP(w http.ResponseWriter, r *http.Request) { switch r.Method { case http.MethodPost: var req SumRequest if err := json.NewDecoder(r.Body).Decode(&req); err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } if res, err := s.sum(req.A, req.B); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } else { fmt.Fprint(w, res) } } }
  • 29. main func main() { http.ListenAndServe(":8888", &addService{}) } $ go run main.go $ curl -X "POST" "http://localhost:8888" -d '{ "a": 3, "b": 34}' 37 Addservice an HTTP handler, we can pass it to ListenAndServe
  • 30. Logging: try to add logging func (s *addService) ServeHTTP(w http.ResponseWriter, r *http.Request) { switch r.Method { case http.MethodPost: var req SumRequest if err := json.NewDecoder(r.Body).Decode(&req); err != nil { code := http.StatusBadRequest http.Error(w, err.Error(), code) log.Printf("%s: %s %s %d", r.RemoteAddr, r.Method, r.URL, code) return } if res, err := s.sum(req.A, req.B); err != nil { code := http.StatusInternalServerError http.Error(w, err.Error(), code) log.Printf("%s: %s %s %d", r.RemoteAddr, r.Method, r.URL, code) return } else { log.Printf("%s: %s %s %d", r.RemoteAddr, r.Method, r.URL, 200) fmt.Fprint(w, res) } }
  • 31. Logging func main() { log.Printf("listening on :8888") log.Fatal(http.ListenAndServe(":8888", &addService{})) } $ go run main.go 2019/11/29 15:24:29 listening on :8888 2019/11/29 15:24:32 [::1]:52200: POST / 200 $ curl -X "POST" "http://localhost:8888" -d '{ "a": 3, "b": 34}' 37
  • 32. Endpoint type Endpoint func(request) (response) Endpoint is the fundamental building block of servers and clients.It represents a single RPC method. type Endpoint func(ctx context.Context, request interface{}) (response interface{}, err error)
  • 33. Add service endpoint func MakePostSumEndpoint(s addService) endpoint.Endpoint { return func(_ context.Context, request interface{}) (response interface{}, err error) { p := request.(SumRequest) return s.sum(p.A, p.B) } } Create endpoint by add service constructor and keep add service pure
  • 34. Endpoint middleware Middleware is a chainable behavior modifier for endpoints. type Middleware func(Endpoint) Endpoint
  • 35. Logging middleware func loggingMiddleware(next endpoint.Endpoint) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (response interface{}, err error) { begin := time.Now() defer func() { log.Printf("request took %s", time.Since(begin)) }() return next(ctx, request) } } s := addService{} var e endpoint.Endpoint e = MakePostSumEndpoint(s) e = loggingMiddleware(e) Create endpoint by add service constructor and keep add service pure
  • 36. Http transport func NewServer( e endpoint.Endpoint, dec DecodeRequestFunc, enc EncodeResponseFunc, options ...ServerOption, ) *Server { ... } postSum := httptransport.NewServer(e, decodeHTTPSumRequest, httptransport.EncodeJSONResponse) r := mux.NewRouter() r.Methods(http.MethodPost).Handler(postSum) log.Printf("listening on :8888") log.Fatal(http.ListenAndServe(":8888", r)) Go kit comes with handy HTTP transport. NewServer constructs a new server, which implements http.Handler and wraps the provided endpoint.
  • 37. Design — How is a Go kit microservice modeled? https://gokit.io/faq/#design-mdash-how-is-a-go-kit-microservice-modeled Transport Endpoint Service
  • 38. Go + microservices = Go kit - Speaker Deck - https://speakerdeck.com/peterbourgon/go-plus-microservices-equals-go-kit?slide=78
  • 39. Golang UK Conference 2015 - Peter Bourgon - Go Kit A Toolkit for Microservices - https://youtu.be/aL6sd4d4hxk?t=1022
  • 40. ● Authentication: Basic, casbin, JWT. ● Circuit Breaker: Hystrix, GoBreaker, and HandyBreaker. ● Logging: Provide an interface for structured logging. Recognizes that logs are data. They need context and semantics to be useful for analysis. Supported formats are logfmt and JSON. ● Metrics: Provides uniform interfaces for service instrumentation. Comes with counters, gauges, and histograms. Has adapters for CloudWatch, Prometheus, Graphite, DogStatsD, StatsD, expvar, and more. ● Rate Limit: Uses Go's token bucket implementation. ● Service Discovery: Consul, DNS SRV, etcd, Eureka, ZooKeeper, and more. ● Tracing: OpenCensus, OpenTracing, and Zipkin. ● Transport: AMQP, AWS Lambda, gRPC, HTTP, NATS, Thrift. . ├── auth ├── circuitbreaker ├── cmd ├── endpoint ├── examples ├── log ├── metrics ├── ratelimit ├── sd ├── tracing ├── transport ├── util ├── .build.yml ├── .gitignore ├── .travis.yml
  • 43. Microservice cause technical problems ~ Service Mesh solve technical problems
  • 44. What Is a Service Mesh? By NGINX 1. Container orchestration framework 2. Services and instances (Kubernetes pods). 3. Sidecar proxy 4. Service discovery 5. Load balancing 6. Encryption 7. Authentication and authorization 8. Support for the circuit breaker pattern What Is a Service Mesh? - NGINX - https://www.nginx.com/blog/what-is-a-service-mesh/
  • 45. The control plane in a service mesh distributes configuration across the sidecar proxies in the data plane What Is a Service Mesh? - NGINX - https://www.nginx.com/blog/what-is-a-service-mesh/
  • 46. Consul by HashiCorp - https://www.consul.io/
  • 48. addsvc.yaml apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: app: addsvc name: addsvc spec: replicas: 1 strategy: {} template: metadata: creationTimestamp: null labels: app: addsvc annotations: "consul.hashicorp.com/connect-inject": "true" "consul.hashicorp.com/connect-service": "addsvc" "consul.hashicorp.com/connect-service-port": "8021" "consul.hashicorp.com/connect-service-protocol": "grpc" "consul.hashicorp.com/connect-service-upstreams": "zipkin:9411"
  • 49. Consul vs. Istio Consul Service Mesh实战【转】 - 简书 - https://www.jianshu.com/p/ad970554403d
  • 50. Reference 1. Go + Microservices = Go Kit [I] - Peter Bourgon, Go Kit 2. Go kit 3. https://gokit.io/faq/ 4. cage1016/gokitconsulk8s 5. cage1016/gk 6. What Is a Service Mesh?
  • 52. Q & A