├── jupiter
├── 3-源码概览.md
├── imgs
│ └── 1.png
├── example
│ └── quickstart
│ │ └── main.go
├── 2-部署和使用.md
└── 1-整体介绍.md
├── README.md
├── istio
├── samples
│ ├── rawvm
│ │ ├── .gitignore
│ │ ├── k8cli.yaml.in
│ │ ├── Makefile
│ │ └── k8services.yaml.in
│ ├── bookinfo
│ │ ├── src
│ │ │ ├── reviews
│ │ │ │ ├── reviews-wlpcfg
│ │ │ │ │ ├── shared
│ │ │ │ │ │ └── .gitkeep
│ │ │ │ │ ├── build.gradle
│ │ │ │ │ ├── src
│ │ │ │ │ │ └── test
│ │ │ │ │ │ │ └── java
│ │ │ │ │ │ │ └── it
│ │ │ │ │ │ │ ├── TestApplication.java
│ │ │ │ │ │ │ └── rest
│ │ │ │ │ │ │ └── LibertyRestEndpointTest.java
│ │ │ │ │ ├── Dockerfile
│ │ │ │ │ └── servers
│ │ │ │ │ │ └── LibertyProjectServer
│ │ │ │ │ │ └── server.xml
│ │ │ │ ├── .gitignore
│ │ │ │ ├── settings.gradle
│ │ │ │ ├── build.gradle
│ │ │ │ └── reviews-application
│ │ │ │ │ ├── src
│ │ │ │ │ ├── main
│ │ │ │ │ │ ├── java
│ │ │ │ │ │ │ └── application
│ │ │ │ │ │ │ │ └── ReviewsApplication.java
│ │ │ │ │ │ └── webapp
│ │ │ │ │ │ │ └── WEB-INF
│ │ │ │ │ │ │ ├── web.xml
│ │ │ │ │ │ │ └── ibm-web-ext.xml
│ │ │ │ │ └── test
│ │ │ │ │ │ └── java
│ │ │ │ │ │ └── test
│ │ │ │ │ │ └── TestApplication.java
│ │ │ │ │ └── build.gradle
│ │ │ ├── mongodb
│ │ │ │ ├── ratings_data.json
│ │ │ │ ├── script.sh
│ │ │ │ └── Dockerfile
│ │ │ ├── productpage
│ │ │ │ ├── test-requirements.txt
│ │ │ │ ├── static
│ │ │ │ │ └── bootstrap
│ │ │ │ │ │ ├── fonts
│ │ │ │ │ │ ├── glyphicons-halflings-regular.eot
│ │ │ │ │ │ ├── glyphicons-halflings-regular.ttf
│ │ │ │ │ │ ├── glyphicons-halflings-regular.woff
│ │ │ │ │ │ └── glyphicons-halflings-regular.woff2
│ │ │ │ │ │ └── js
│ │ │ │ │ │ └── npm.js
│ │ │ │ ├── requirements.txt
│ │ │ │ ├── Dockerfile
│ │ │ │ └── templates
│ │ │ │ │ └── index.html
│ │ │ ├── ratings
│ │ │ │ ├── package.json
│ │ │ │ └── Dockerfile
│ │ │ ├── mysql
│ │ │ │ ├── mysqldb-init.sql
│ │ │ │ └── Dockerfile
│ │ │ └── details
│ │ │ │ └── Dockerfile
│ │ ├── platform
│ │ │ └── kube
│ │ │ │ ├── README.md
│ │ │ │ ├── bookinfo-certificate.yaml
│ │ │ │ ├── bookinfo-ratings-discovery.yaml
│ │ │ │ ├── productpage-nodeport.yaml
│ │ │ │ ├── bookinfo-details-v2.yaml
│ │ │ │ ├── bookinfo-db.yaml
│ │ │ │ ├── bookinfo-ingress.yaml
│ │ │ │ ├── bookinfo-details.yaml
│ │ │ │ └── bookinfo-ratings.yaml
│ │ ├── networking
│ │ │ ├── virtual-service-details-v2.yaml
│ │ │ ├── virtual-service-reviews-v3.yaml
│ │ │ ├── virtual-service-reviews-50-v3.yaml
│ │ │ ├── virtual-service-reviews-80-20.yaml
│ │ │ ├── virtual-service-reviews-90-10.yaml
│ │ │ ├── virtual-service-reviews-v2-v3.yaml
│ │ │ ├── destination-rule-reviews.yaml
│ │ │ ├── virtual-service-reviews-jason-v2-v3.yaml
│ │ │ ├── virtual-service-reviews-test-v2.yaml
│ │ │ ├── virtual-service-ratings-db.yaml
│ │ │ ├── virtual-service-ratings-mysql.yaml
│ │ │ ├── virtual-service-ratings-mysql-vm.yaml
│ │ │ ├── virtual-service-ratings-test-abort.yaml
│ │ │ ├── virtual-service-ratings-test-delay.yaml
│ │ │ ├── fault-injection-details-v1.yaml
│ │ │ ├── certmanager-gateway.yaml
│ │ │ ├── bookinfo-gateway.yaml
│ │ │ ├── virtual-service-all-v1.yaml
│ │ │ ├── egress-rule-google-apis.yaml
│ │ │ ├── destination-rule-all.yaml
│ │ │ └── destination-rule-all-mtls.yaml
│ │ └── README.md
│ ├── README.md
│ ├── helloworld
│ │ ├── src
│ │ │ ├── requirements.txt
│ │ │ ├── Dockerfile
│ │ │ ├── build_service.sh
│ │ │ └── app.py
│ │ ├── helloworld-gateway.yaml
│ │ ├── loadgen.sh
│ │ └── helloworld.yaml
│ ├── https
│ │ ├── default.conf
│ │ └── nginx-app.yaml
│ ├── multicluster
│ │ ├── expose-services.yaml
│ │ ├── expose-istiod.yaml
│ │ └── README.md
│ ├── custom-bootstrap
│ │ ├── custom-bootstrap.yaml
│ │ └── example-app.yaml
│ ├── httpbin
│ │ ├── httpbin-gateway.yaml
│ │ ├── sample-client
│ │ │ └── fortio-deploy.yaml
│ │ ├── httpbin-nodeport.yaml
│ │ ├── httpbin-vault.yaml
│ │ └── httpbin.yaml
│ ├── websockets
│ │ ├── route.yaml
│ │ └── app.yaml
│ ├── external
│ │ ├── aptget.yaml
│ │ ├── pypi.yaml
│ │ └── github.yaml
│ ├── health-check
│ │ ├── liveness-http-same-port.yaml
│ │ ├── server.go
│ │ └── liveness-command.yaml
│ ├── security
│ │ └── psp
│ │ │ └── sidecar-psp.yaml
│ ├── certs
│ │ ├── README.md
│ │ ├── ca-cert.pem
│ │ ├── cert-chain.pem
│ │ ├── root-cert.pem
│ │ └── ca-key.pem
│ ├── tcp-echo
│ │ ├── tcp-echo-20-v2.yaml
│ │ ├── README.md
│ │ └── tcp-echo-all-v1.yaml
│ ├── addons
│ │ └── extras
│ │ │ ├── zipkin.yaml
│ │ │ └── prometheus-operator.yaml
│ ├── kubernetes-blog
│ │ ├── bookinfo-reviews-v2.yaml
│ │ └── bookinfo-ratings.yaml
│ └── sleep
│ │ ├── README.md
│ │ └── sleep-vault.yaml
└── ReadMe.md
├── kratosV2
├── helloworld
│ ├── internal
│ │ ├── biz
│ │ │ ├── README.md
│ │ │ ├── biz.go
│ │ │ └── greeter.go
│ │ ├── data
│ │ │ ├── README.md
│ │ │ ├── data.go
│ │ │ └── greeter.go
│ │ ├── service
│ │ │ ├── README.md
│ │ │ ├── service.go
│ │ │ ├── greeter.go
│ │ │ └── helloworld.go
│ │ ├── server
│ │ │ ├── server.go
│ │ │ ├── grpc.go
│ │ │ └── http.go
│ │ └── conf
│ │ │ └── conf.proto
│ ├── generate.go
│ ├── configs
│ │ └── config.yaml
│ ├── cmd
│ │ └── helloworld
│ │ │ ├── wire.go
│ │ │ └── wire_gen.go
│ ├── api
│ │ └── helloworld
│ │ │ ├── v1
│ │ │ ├── error_reason.proto
│ │ │ ├── greeter.proto
│ │ │ └── error_reason.swagger.json
│ │ │ └── helloworld.proto
│ ├── Dockerfile
│ ├── .gitignore
│ ├── README.md
│ ├── LICENSE
│ └── go.mod
└── ReadMe.md
├── grafana
├── auth
│ ├── htpasswd
│ └── grafana.ini
└── ReadMe.md
├── micro
└── 640.jpg
├── kong
├── imgs
│ └── 1.JPG
└── docker-compose.yaml
├── go-zero
├── greet
│ ├── etc
│ │ └── greet-api.yaml
│ ├── internal
│ │ ├── config
│ │ │ └── config.go
│ │ ├── types
│ │ │ └── types.go
│ │ ├── svc
│ │ │ └── servicecontext.go
│ │ ├── handler
│ │ │ ├── routes.go
│ │ │ └── greethandler.go
│ │ └── logic
│ │ │ └── greetlogic.go
│ ├── .idea
│ │ ├── vcs.xml
│ │ ├── modules.xml
│ │ └── greet.iml
│ ├── greet.api
│ ├── client
│ │ └── ts
│ │ │ └── greet.ts
│ ├── greet.go
│ └── ReadMe.md
└── ReadMe.md
├── gopher-lua
├── module
│ ├── main.lua
│ ├── mymain.go
│ └── mymodule
│ │ └── mymodule.go
├── go_call_lua
│ └── set.lua
├── lua_call_go
│ ├── lua_call_go
│ └── main.go
├── fib
│ ├── fib.lua
│ └── main.go
├── ReadMe.md
├── helloworld
│ └── main.go
├── context
│ └── main.go
├── channel
│ └── main.go
└── user_defined_types
│ └── main.go
├── tars
├── imgs
│ ├── tars.png
│ └── tars_tuopu.png
└── ReadMe.md
├── gokit
├── shipping
│ ├── shipping
│ ├── routing
│ │ └── routing.go
│ ├── location
│ │ ├── location.go
│ │ └── sample_locations.go
│ ├── tracking
│ │ ├── logging.go
│ │ ├── endpoint.go
│ │ └── instrumenting.go
│ ├── ReadMe.md
│ ├── handling
│ │ ├── endpoint.go
│ │ ├── logging.go
│ │ └── instrumenting.go
│ ├── voyage
│ │ ├── voyage.go
│ │ └── sample_voyages.go
│ └── inspection
│ │ └── inspection.go
├── ReadMe.md
├── ss2
│ ├── service.go
│ ├── logging.go
│ └── instrumenting.go
├── ss3
│ ├── service.go
│ ├── logging.go
│ └── instrumenting.go
└── profilesvc
│ └── cmd
│ └── profilesvc
│ └── main.go
├── .vscode
└── settings.json
├── discovery
├── demos
│ ├── go.mod
│ └── main.go
└── ReadMe.md
├── etcd
├── raft
│ ├── raft.md
│ └── src
│ │ ├── raft
│ │ ├── Procfile
│ │ ├── doc.go
│ │ ├── kvstore_test.go
│ │ ├── main.go
│ │ └── listener.go
│ │ └── .vscode
│ │ └── launch.json
└── etcd.md
├── ci
└── ReadMe.md
├── restful
└── README.md
├── kubeval
└── ReadMe.md
├── gochassis
└── ReadMe.md
├── dubbo
└── docker-compose.yaml
├── grpc
└── examples
│ ├── grpc-gateway
│ ├── proto
│ │ └── gateway.proto
│ ├── ReadMe.md
│ └── service.go
│ └── README.md
├── go.mod
├── traefik
├── docker-compose.yaml
├── ReadMe.md
└── docker-compose.yml
├── minio
└── ReadMe.md
├── clickhouse
└── ReadMe.md
├── redis
└── Redis学习路线整理.md
├── tyk
└── ReadMe.md
├── tunnel
└── ReadMe.md
├── prometheus
└── client
│ └── vendor
│ └── vendor.json
├── kubevela
└── ReadMe.md
├── elasticsearch
└── ReadMe.md
├── opentracing
└── ReadMe.md
├── googleapi
└── ReadMe.md
├── juiceFS
└── ReadMe.md
└── openfire
└── ReadMe.md
/jupiter/3-源码概览.md:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # learning
2 | 学习资料整理
3 |
--------------------------------------------------------------------------------
/istio/samples/rawvm/.gitignore:
--------------------------------------------------------------------------------
1 | *.yaml
2 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/internal/biz/README.md:
--------------------------------------------------------------------------------
1 | # Biz
2 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/internal/data/README.md:
--------------------------------------------------------------------------------
1 | # Data
2 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/internal/service/README.md:
--------------------------------------------------------------------------------
1 | # Service
2 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/reviews/reviews-wlpcfg/shared/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/grafana/auth/htpasswd:
--------------------------------------------------------------------------------
1 | frank:$apr1$Yr2z4Kmi$rfxPX0WtfrYcE0Lc9naJK1
2 |
--------------------------------------------------------------------------------
/micro/640.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feixiao/service/HEAD/micro/640.jpg
--------------------------------------------------------------------------------
/kong/imgs/1.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feixiao/service/HEAD/kong/imgs/1.JPG
--------------------------------------------------------------------------------
/go-zero/greet/etc/greet-api.yaml:
--------------------------------------------------------------------------------
1 | Name: greet-api
2 | Host: 0.0.0.0
3 | Port: 18888
4 |
--------------------------------------------------------------------------------
/gopher-lua/module/main.lua:
--------------------------------------------------------------------------------
1 | local m = require("mymodule")
2 | m.myfunc()
3 | print(m.name)
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/mongodb/ratings_data.json:
--------------------------------------------------------------------------------
1 | {rating: 5}
2 | {rating: 4}
3 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/productpage/test-requirements.txt:
--------------------------------------------------------------------------------
1 | requests-mock==1.5.2
2 |
--------------------------------------------------------------------------------
/jupiter/imgs/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feixiao/service/HEAD/jupiter/imgs/1.png
--------------------------------------------------------------------------------
/tars/imgs/tars.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feixiao/service/HEAD/tars/imgs/tars.png
--------------------------------------------------------------------------------
/gokit/shipping/shipping:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feixiao/service/HEAD/gokit/shipping/shipping
--------------------------------------------------------------------------------
/kratosV2/helloworld/generate.go:
--------------------------------------------------------------------------------
1 | package generate
2 |
3 | //go:generate kratos proto client .
4 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "C_Cpp.default.configurationProvider": "go2sh.cmake-integration"
3 | }
--------------------------------------------------------------------------------
/tars/imgs/tars_tuopu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feixiao/service/HEAD/tars/imgs/tars_tuopu.png
--------------------------------------------------------------------------------
/gopher-lua/go_call_lua/set.lua:
--------------------------------------------------------------------------------
1 | function setPerson(n)
2 | n.Name = "Hi Frank!"
3 | return n
4 | end
--------------------------------------------------------------------------------
/discovery/demos/go.mod:
--------------------------------------------------------------------------------
1 | module discovery
2 |
3 | go 1.12
4 |
5 | require github.com/bilibili/discovery v1.1.0
6 |
--------------------------------------------------------------------------------
/gopher-lua/lua_call_go/lua_call_go:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feixiao/service/HEAD/gopher-lua/lua_call_go/lua_call_go
--------------------------------------------------------------------------------
/istio/samples/README.md:
--------------------------------------------------------------------------------
1 | # Istio Samples
2 |
3 | This directory contains sample applications highlighting various Istio features.
4 |
--------------------------------------------------------------------------------
/gopher-lua/fib/fib.lua:
--------------------------------------------------------------------------------
1 | function fib(n)
2 | if n < 2 then
3 | return 1
4 | end
5 | return fib(n-1) + fib(n-2)
6 | end
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/reviews/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | reviews-application/build/
3 | reviews-wlpcfg/servers/LibertyProjectServer/apps/
4 |
--------------------------------------------------------------------------------
/istio/samples/helloworld/src/requirements.txt:
--------------------------------------------------------------------------------
1 | requests
2 | flask
3 | flask_json
4 | flask_bootstrap
5 | json2html
6 | simplejson
7 | gevent
8 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/reviews/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'reviews'
2 |
3 | include 'reviews-application'
4 | include 'reviews-wlpcfg'
5 |
--------------------------------------------------------------------------------
/go-zero/greet/internal/config/config.go:
--------------------------------------------------------------------------------
1 | package config
2 |
3 | import "github.com/tal-tech/go-zero/rest"
4 |
5 | type Config struct {
6 | rest.RestConf
7 | }
8 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/reviews/build.gradle:
--------------------------------------------------------------------------------
1 | allprojects {
2 | group = 'org.istio'
3 | version = '1.0'
4 | repositories {
5 | mavenCentral()
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/etcd/raft/raft.md:
--------------------------------------------------------------------------------
1 | # Raft 一致性算法
2 |
3 | [《Raft一致性算法论文》](https://github.com/maemual/raft-zh_cn)
4 |
5 | [Etcd中raft的实现](https://github.com/coreos/etcd/tree/v3.2.10/raft)
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/platform/kube/README.md:
--------------------------------------------------------------------------------
1 | See the [Bookinfo guide](https://istio.io/docs/guides/bookinfo.html) in Istio
2 | docs for instructions on how to run this demo application.
3 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/internal/biz/biz.go:
--------------------------------------------------------------------------------
1 | package biz
2 |
3 | import "github.com/google/wire"
4 |
5 | // ProviderSet is biz providers.
6 | var ProviderSet = wire.NewSet(NewGreeterUsecase)
7 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/internal/service/service.go:
--------------------------------------------------------------------------------
1 | package service
2 |
3 | import "github.com/google/wire"
4 |
5 | // ProviderSet is service providers.
6 | var ProviderSet = wire.NewSet(NewGreeterService)
7 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/internal/server/server.go:
--------------------------------------------------------------------------------
1 | package server
2 |
3 | import (
4 | "github.com/google/wire"
5 | )
6 |
7 | // ProviderSet is server providers.
8 | var ProviderSet = wire.NewSet(NewHTTPServer, NewGRPCServer)
9 |
--------------------------------------------------------------------------------
/go-zero/greet/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/productpage/static/bootstrap/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feixiao/service/HEAD/istio/samples/bookinfo/src/productpage/static/bootstrap/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/productpage/static/bootstrap/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feixiao/service/HEAD/istio/samples/bookinfo/src/productpage/static/bootstrap/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/productpage/static/bootstrap/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feixiao/service/HEAD/istio/samples/bookinfo/src/productpage/static/bootstrap/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/productpage/static/bootstrap/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feixiao/service/HEAD/istio/samples/bookinfo/src/productpage/static/bootstrap/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/grafana/auth/grafana.ini:
--------------------------------------------------------------------------------
1 | [users]
2 | allow_sign_up = false
3 | auto_assign_org = true
4 | auto_assign_org_role = Editor
5 |
6 | [auth.proxy]
7 | enabled = true
8 | header_name = X-WEBAUTH-USER
9 | header_property = username
10 | auto_sign_up = true
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/ratings/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "start": "node ratings.js"
4 | },
5 | "dependencies": {
6 | "httpdispatcher": "1.0.0",
7 | "mongodb": "^3.6.0",
8 | "mysql": "^2.15.0"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/gopher-lua/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## Golang使用Lua
2 |
3 | [项目地址](https://github.com/yuin/gopher-lua)
4 |
5 |
6 |
7 | #### 参考资料
8 |
9 | + [《Golang中使用lua进行扩展》](https://segmentfault.com/a/1190000011527968)
10 | + [《GopherLua基础入门》](https://www.jianshu.com/p/70ac208a5869)
11 |
12 |
--------------------------------------------------------------------------------
/gopher-lua/helloworld/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | lua "github.com/yuin/gopher-lua"
5 | )
6 |
7 |
8 | func main() {
9 | l := lua.NewState()
10 | defer l.Close()
11 | if err:= l.DoString(`print("hello")`); err != nil {
12 | panic(err)
13 | }
14 | return;
15 | }
--------------------------------------------------------------------------------
/go-zero/greet/internal/types/types.go:
--------------------------------------------------------------------------------
1 | // Code generated by goctl. DO NOT EDIT.
2 | package types
3 |
4 | type Request struct {
5 | Name string `path:"name,options=you|me"`
6 | }
7 |
8 | type Response struct {
9 | Code int `json:"code"`
10 | Message string `json:"message"`
11 | }
12 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/reviews/reviews-application/src/main/java/application/ReviewsApplication.java:
--------------------------------------------------------------------------------
1 | package application;
2 | import javax.ws.rs.ApplicationPath;
3 | import javax.ws.rs.core.Application;
4 |
5 | @ApplicationPath("/")
6 | public class ReviewsApplication extends Application {
7 | }
8 |
--------------------------------------------------------------------------------
/istio/samples/https/default.conf:
--------------------------------------------------------------------------------
1 | server {
2 | listen 443 ssl;
3 |
4 | root /usr/share/nginx/html;
5 | index index.html;
6 |
7 | server_name localhost;
8 | ssl_certificate /etc/nginx/ssl/tls.crt;
9 | ssl_certificate_key /etc/nginx/ssl/tls.key;
10 | }
11 |
--------------------------------------------------------------------------------
/go-zero/greet/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/virtual-service-details-v2.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: details
5 | spec:
6 | hosts:
7 | - details
8 | http:
9 | - route:
10 | - destination:
11 | host: details
12 | subset: v2
13 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/virtual-service-reviews-v3.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: reviews
5 | spec:
6 | hosts:
7 | - reviews
8 | http:
9 | - route:
10 | - destination:
11 | host: reviews
12 | subset: v3
13 |
--------------------------------------------------------------------------------
/go-zero/greet/greet.api:
--------------------------------------------------------------------------------
1 | type Request struct {
2 | Name string `path:"name,options=you|me"`
3 | }
4 |
5 | type Response struct {
6 | Code int `json:"code"`
7 |
8 | Message string `json:"message"`
9 | }
10 |
11 | service greet-api {
12 | @handler GreetHandler
13 | get /greet/from/:name(Request) returns (Response);
14 | }
--------------------------------------------------------------------------------
/ci/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## 持续集成
2 |
3 | #### 参考资料
4 |
5 | + [《持续交付》](https://book.douban.com/subject/6862062/)
6 | + [《持续集成的最佳实践》](http://feixiao.github.io/2017/08/18/%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90%E7%9A%84%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5/)
7 | + [《持续递交Golang项目》](http://feixiao.github.io/2017/08/17/BuildGolangProjectInJenkins/)
8 |
9 |
--------------------------------------------------------------------------------
/go-zero/greet/internal/svc/servicecontext.go:
--------------------------------------------------------------------------------
1 | package svc
2 |
3 | import (
4 | "github.com/feixiao/learning/go-zero/greet/internal/config"
5 | )
6 |
7 | type ServiceContext struct {
8 | Config config.Config
9 | }
10 |
11 | func NewServiceContext(c config.Config) *ServiceContext {
12 | return &ServiceContext{
13 | Config: c,
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/restful/README.md:
--------------------------------------------------------------------------------
1 | # RESTful
2 | RESTful API学习整理。
3 |
4 | ### RESTful介绍
5 |
6 |
7 | + [《RESTful API 设计指南》](http://www.ruanyifeng.com/blog/2014/05/restful_api.html)
8 | + [《RESTful API 设计最佳实践》](http://blog.jobbole.com/41233/)
9 | + [《10个有关RESTful API良好设计的最佳实践》](http://www.jdon.com/soa/10-best-practices-for-better-restful-api.html)
10 |
11 | ### 框架
--------------------------------------------------------------------------------
/go-zero/greet/.idea/greet.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/configs/config.yaml:
--------------------------------------------------------------------------------
1 | server:
2 | http:
3 | addr: 0.0.0.0:8000
4 | timeout: 1s
5 | grpc:
6 | addr: 0.0.0.0:9000
7 | timeout: 1s
8 | data:
9 | database:
10 | driver: mysql
11 | source: root:root@tcp(127.0.0.1:3306)/test
12 | redis:
13 | addr: 127.0.0.1:6379
14 | read_timeout: 0.2s
15 | write_timeout: 0.2s
16 |
--------------------------------------------------------------------------------
/gopher-lua/module/mymain.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/feixiao/learning/gopher-lua/module/mymodule"
5 | "github.com/yuin/gopher-lua"
6 | )
7 |
8 | func main() {
9 | L := lua.NewState()
10 | defer L.Close()
11 | L.PreloadModule("mymodule", mymodule.Loader)
12 | if err := L.DoFile("main.lua"); err != nil {
13 | panic(err)
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/kubeval/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## Kubeval 快速入门
2 |
3 | #### 下载和安装
4 | ```shell
5 | wget https://github.com/instrumenta/kubeval/releases/latest/download/kubeval-linux-amd64.tar.gz
6 | tar xf kubeval-linux-amd64.tar.gz
7 | sudo cp kubeval /usr/local/bin
8 |
9 | # 查看版本
10 | kubeval --version
11 | Version: 0.15.0
12 | Commit: df50ea7fd4fd202458002a40a6a39ffbb3125bad
13 | Date: 2020-04-14T09:32:29Z
14 |
15 | ```
--------------------------------------------------------------------------------
/kratosV2/helloworld/cmd/helloworld/wire.go:
--------------------------------------------------------------------------------
1 | // +build wireinject
2 |
3 | // The build tag makes sure the stub is not built in the final build.
4 |
5 | package main
6 |
7 | // initApp init kratos application.
8 | func initApp(*conf.Server, *conf.Data, log.Logger) (*kratos.App, func(), error) {
9 | panic(wire.Build(server.ProviderSet, data.ProviderSet, biz.ProviderSet, service.ProviderSet, newApp))
10 | }
11 |
--------------------------------------------------------------------------------
/go-zero/greet/client/ts/greet.ts:
--------------------------------------------------------------------------------
1 |
2 |
3 | export interface Request {
4 | }
5 |
6 | export interface RequestParams {
7 | name: string
8 | }
9 |
10 | export interface Response {
11 | code: number
12 | message: string
13 | }
14 |
15 | /**
16 | * @description
17 | * @param params
18 | */
19 | export function greet(params: RequestParams) {
20 | return webapi.get("/greet/from/:name", params)
21 | }
22 |
--------------------------------------------------------------------------------
/gochassis/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## go-chassis
2 |
3 | ### 环境部署
4 |
5 | + [最小化安装](https://go.huaweicse.com/gai-shu/an-zhuang-ben-di-kai-fa-huan-jing/install.html)
6 |
7 |
8 |
9 | ### 参考资料
10 |
11 | + [使用ServiceComb Go-chassis构建微服务](http://www.infoq.com/cn/articles/ServiceComb-Go-chassis-micro-service)
12 | + [go-chassis](https://github.com/ServiceComb/go-chassis)
13 | + [go.huaweicse.com](https://go.huaweicse.com/)
14 |
15 |
16 |
--------------------------------------------------------------------------------
/dubbo/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | zookeeper:
4 | image: zookeeper
5 | ports:
6 | - 2181:2181
7 | admin:
8 | image: chenchuxin/dubbo-admin
9 | depends_on:
10 | - zookeeper
11 | ports:
12 | - 8080:8080
13 | environment:
14 | - dubbo.registry.address=zookeeper://zookeeper:2181
15 | - dubbo.admin.root.password=root
16 | - dubbo.admin.guest.password=guest
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/virtual-service-reviews-50-v3.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: reviews
5 | spec:
6 | hosts:
7 | - reviews
8 | http:
9 | - route:
10 | - destination:
11 | host: reviews
12 | subset: v1
13 | weight: 50
14 | - destination:
15 | host: reviews
16 | subset: v3
17 | weight: 50
18 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/virtual-service-reviews-80-20.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: reviews
5 | spec:
6 | hosts:
7 | - reviews
8 | http:
9 | - route:
10 | - destination:
11 | host: reviews
12 | subset: v1
13 | weight: 80
14 | - destination:
15 | host: reviews
16 | subset: v2
17 | weight: 20
18 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/virtual-service-reviews-90-10.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: reviews
5 | spec:
6 | hosts:
7 | - reviews
8 | http:
9 | - route:
10 | - destination:
11 | host: reviews
12 | subset: v1
13 | weight: 90
14 | - destination:
15 | host: reviews
16 | subset: v2
17 | weight: 10
18 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/virtual-service-reviews-v2-v3.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: reviews
5 | spec:
6 | hosts:
7 | - reviews
8 | http:
9 | - route:
10 | - destination:
11 | host: reviews
12 | subset: v2
13 | weight: 50
14 | - destination:
15 | host: reviews
16 | subset: v3
17 | weight: 50
18 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/api/helloworld/v1/error_reason.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package helloworld.v1;
4 |
5 | option go_package = "helloworld/helloworld/v1;v1";
6 | option java_multiple_files = true;
7 | option java_package = "com.github.kratos.helloworld.errors";
8 | option objc_class_prefix = "KratosHelloworldErrors";
9 |
10 | enum ErrorReason {
11 | ERROR_REASON_UNSPECIFIED = 0;
12 |
13 | USER_NOT_FOUND = 1;
14 | }
15 |
--------------------------------------------------------------------------------
/istio/samples/multicluster/expose-services.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: Gateway
3 | metadata:
4 | name: cross-network-gateway
5 | namespace: istio-system
6 | spec:
7 | selector:
8 | istio: eastwestgateway
9 | servers:
10 | - port:
11 | number: 15443
12 | name: tls
13 | protocol: TLS
14 | tls:
15 | mode: AUTO_PASSTHROUGH
16 | hosts:
17 | - "*.local"
18 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/destination-rule-reviews.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: DestinationRule
3 | metadata:
4 | name: reviews
5 | spec:
6 | host: reviews
7 | trafficPolicy:
8 | loadBalancer:
9 | simple: RANDOM
10 | subsets:
11 | - name: v1
12 | labels:
13 | version: v1
14 | - name: v2
15 | labels:
16 | version: v2
17 | - name: v3
18 | labels:
19 | version: v3
20 |
--------------------------------------------------------------------------------
/grpc/examples/grpc-gateway/proto/gateway.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | import "google/api/annotations.proto";
4 |
5 |
6 |
7 | package gateway;
8 |
9 |
10 | message StringMessage {
11 | string value = 1;
12 | }
13 |
14 |
15 | service Gateway {
16 | rpc Echo(StringMessage) returns (StringMessage) {
17 | option (google.api.http) = {
18 | post: "/v1/example/echo"
19 | body: "*"
20 | };
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/etcd/raft/src/raft/Procfile:
--------------------------------------------------------------------------------
1 | # Use goreman to run `go get github.com/mattn/goreman`
2 | raftexample1: ./raftexample --id 1 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 12380
3 | raftexample2: ./raftexample --id 2 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 22380
4 | raftexample3: ./raftexample --id 3 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 32380
5 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/feixiao/learning
2 |
3 | go 1.12
4 |
5 | require (
6 | github.com/golang/mock v1.1.1
7 | github.com/golang/protobuf v1.3.2
8 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect
9 | golang.org/x/net v0.0.0-20191105084925-a882066a44e0
10 | golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 // indirect
11 | google.golang.org/grpc v1.25.0
12 | honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc // indirect
13 | )
14 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/mysql/mysqldb-init.sql:
--------------------------------------------------------------------------------
1 | # Initialize a mysql db with a 'test' db and be able test productpage with it.
2 | # mysql -h 127.0.0.1 -ppassword < mysqldb-init.sql
3 |
4 | CREATE DATABASE test;
5 | USE test;
6 |
7 | CREATE TABLE `ratings` (
8 | `ReviewID` INT NOT NULL,
9 | `Rating` INT,
10 | PRIMARY KEY (`ReviewID`)
11 | );
12 | INSERT INTO ratings (ReviewID, Rating) VALUES (1, 5);
13 | INSERT INTO ratings (ReviewID, Rating) VALUES (2, 4);
14 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/virtual-service-reviews-jason-v2-v3.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: reviews
5 | spec:
6 | hosts:
7 | - reviews
8 | http:
9 | - match:
10 | - headers:
11 | end-user:
12 | exact: jason
13 | route:
14 | - destination:
15 | host: reviews
16 | subset: v2
17 | - route:
18 | - destination:
19 | host: reviews
20 | subset: v3
21 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/virtual-service-reviews-test-v2.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: reviews
5 | spec:
6 | hosts:
7 | - reviews
8 | http:
9 | - match:
10 | - headers:
11 | end-user:
12 | exact: jason
13 | route:
14 | - destination:
15 | host: reviews
16 | subset: v2
17 | - route:
18 | - destination:
19 | host: reviews
20 | subset: v1
21 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/reviews/reviews-wlpcfg/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | mavenCentral()
4 | }
5 | }
6 |
7 | apply plugin: 'eclipse'
8 |
9 | task copyApplication(type: Copy) {
10 | from '../reviews-application/build/libs/reviews-application-1.0.war'
11 | into 'servers/LibertyProjectServer/apps/'
12 | }
13 |
14 | task build(dependsOn: ['copyApplication']){
15 | }
16 |
17 | task clean {
18 | delete "servers/LibertyProjectServer/apps"
19 | }
20 |
--------------------------------------------------------------------------------
/gokit/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## Go kit 介绍
2 |
3 | ### 例子
4 |
5 | [examples](http://gokit.io/examples/)
6 | +
7 |
8 | ### 参考资料
9 | + [go-kit入门(一)](http://blog.chunshengster.me/2016/05/26/go_kit_ru_men_yi/)
10 | + [go-kit入门(二) 第一个 Go kit 程序](http://blog.chunshengster.me/2016/05/28/go_kit_ru_men_er_di_yi_ge_go_kit_cheng_xu/)
11 | + [go-kit入门(三)日志和仪表化](http://blog.chunshengster.me/2016/06/01/go_kit_ru_men_san_ri_zhi_he_yi_biao_hua/)
12 | + [Go-kit入门(四)服务调用](http://blog.chunshengster.me/2016/06/16/go_kit_ru_men_si_fu_wu_diao_yong/)
13 |
14 |
--------------------------------------------------------------------------------
/gopher-lua/module/mymodule/mymodule.go:
--------------------------------------------------------------------------------
1 | package mymodule
2 |
3 | import (
4 | lua "github.com/yuin/gopher-lua"
5 | )
6 |
7 | var exports = map[string]lua.LGFunction{
8 | "myfunc": myfunc,
9 | }
10 |
11 | func myfunc(L *lua.LState) int {
12 | return 0 // 函数返回值个数
13 | }
14 |
15 | func Loader(L *lua.LState) int {
16 | // 注册函数
17 | mod := L.SetFuncs(L.NewTable(), exports)
18 | // register other stuff
19 | L.SetField(mod, "name", lua.LString("value"))
20 |
21 | // returns the module
22 | L.Push(mod)
23 | return 1
24 | }
--------------------------------------------------------------------------------
/istio/samples/custom-bootstrap/custom-bootstrap.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ConfigMap
3 | metadata:
4 | name: istio-custom-bootstrap-config
5 | namespace: default
6 | data:
7 | custom_bootstrap.json: |
8 | {
9 | "tracing": {
10 | "http": {
11 | "name": "envoy.zipkin",
12 | "config": {
13 | "collector_cluster": "zipkin",
14 | "collector_endpoint": "/api/v1/spans/custom",
15 | "trace_id_128bit": "true"
16 | }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/go-zero/greet/internal/handler/routes.go:
--------------------------------------------------------------------------------
1 | // Code generated by goctl. DO NOT EDIT.
2 | package handler
3 |
4 | import (
5 | "net/http"
6 |
7 | "github.com/feixiao/learning/go-zero/greet/internal/svc"
8 |
9 | "github.com/tal-tech/go-zero/rest"
10 | )
11 |
12 | func RegisterHandlers(engine *rest.Server, serverCtx *svc.ServiceContext) {
13 | engine.AddRoutes(
14 | []rest.Route{
15 | {
16 | Method: http.MethodGet,
17 | Path: "/greet/from/:name",
18 | Handler: greetHandler(serverCtx),
19 | },
20 | },
21 | )
22 | }
23 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/reviews/reviews-application/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | Liberty Project
6 |
7 |
8 | index.html
9 |
10 |
--------------------------------------------------------------------------------
/traefik/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | reverse-proxy:
5 | # The official v2 Traefik docker image
6 | image: traefik:v2.2
7 | # Enables the web UI and tells Traefik to listen to docker
8 | command: --api.insecure=true --providers.docker
9 | ports:
10 | # The HTTP port
11 | - "80:80"
12 | # The Web UI (enabled by --api.insecure=true)
13 | - "8080:8080"
14 | volumes:
15 | # So that Traefik can listen to the Docker events
16 | - /var/run/docker.sock:/var/run/docker.sock
--------------------------------------------------------------------------------
/minio/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## Minio 快速入门
2 |
3 |
4 | #### 功能
5 |
6 | #### 安装
7 | ```shell
8 | # 稳定版本
9 | docker pull minio/minio
10 |
11 | docker run -p 9000:9000 minio/minio server /data
12 |
13 |
14 | docker run -p 9000:9000 --name minio \
15 | -v ~/volumes/minio/data:/data \
16 | -v ~/volumes/minio/config:/root/.minio \
17 | minio/minio server /datainio/minio server /data
18 |
19 | ```
20 |
21 |
22 |
23 |
24 | #### 参考资料
25 | + [《minio文档》](https://docs.min.io/)
26 | + [《基于 MinIO 对象存储框架的短视频点播平台设计》](https://www.163.com/dy/article/GCFV3N2H0511FQO9.html)
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/virtual-service-ratings-db.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: reviews
5 | spec:
6 | hosts:
7 | - reviews
8 | http:
9 | - route:
10 | - destination:
11 | host: reviews
12 | subset: v3
13 | ---
14 | apiVersion: networking.istio.io/v1alpha3
15 | kind: VirtualService
16 | metadata:
17 | name: ratings
18 | spec:
19 | hosts:
20 | - ratings
21 | http:
22 | - route:
23 | - destination:
24 | host: ratings
25 | subset: v2
26 | ---
27 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/virtual-service-ratings-mysql.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: reviews
5 | spec:
6 | hosts:
7 | - reviews
8 | http:
9 | - route:
10 | - destination:
11 | host: reviews
12 | subset: v3
13 | ---
14 | apiVersion: networking.istio.io/v1alpha3
15 | kind: VirtualService
16 | metadata:
17 | name: ratings
18 | spec:
19 | hosts:
20 | - ratings
21 | http:
22 | - route:
23 | - destination:
24 | host: ratings
25 | subset: v2-mysql
26 | ---
27 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/virtual-service-ratings-mysql-vm.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: reviews
5 | spec:
6 | hosts:
7 | - reviews
8 | http:
9 | - route:
10 | - destination:
11 | host: reviews
12 | subset: v3
13 | ---
14 | apiVersion: networking.istio.io/v1alpha3
15 | kind: VirtualService
16 | metadata:
17 | name: ratings
18 | spec:
19 | hosts:
20 | - ratings
21 | http:
22 | - route:
23 | - destination:
24 | host: ratings
25 | subset: v2-mysql-vm
26 | ---
27 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:1.15 AS builder
2 |
3 | COPY . /src
4 | WORKDIR /src
5 |
6 | RUN GOPROXY=https://goproxy.cn make build
7 |
8 | FROM debian:stable-slim
9 |
10 | RUN apt-get update && apt-get install -y --no-install-recommends \
11 | ca-certificates \
12 | netbase \
13 | && rm -rf /var/lib/apt/lists/ \
14 | && apt-get autoremove -y && apt-get autoclean -y
15 |
16 | COPY --from=builder /src/bin /app
17 |
18 | WORKDIR /app
19 |
20 | EXPOSE 8000
21 | EXPOSE 9000
22 | VOLUME /data/conf
23 |
24 | CMD ["./server", "-conf", "/data/conf"]
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/productpage/static/bootstrap/js/npm.js:
--------------------------------------------------------------------------------
1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2 | require('../../js/transition.js')
3 | require('../../js/alert.js')
4 | require('../../js/button.js')
5 | require('../../js/carousel.js')
6 | require('../../js/collapse.js')
7 | require('../../js/dropdown.js')
8 | require('../../js/modal.js')
9 | require('../../js/tooltip.js')
10 | require('../../js/popover.js')
11 | require('../../js/scrollspy.js')
12 | require('../../js/tab.js')
13 | require('../../js/affix.js')
--------------------------------------------------------------------------------
/gopher-lua/lua_call_go/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | lua "github.com/yuin/gopher-lua"
5 | )
6 |
7 |
8 | func main() {
9 | L := lua.NewState()
10 | defer L.Close()
11 | L.SetGlobal("double", L.NewFunction(Double)) /* Original lua_setglobal uses stack... */
12 | // 在Lua中调用double(20),实际是调用Double函数
13 | if err:= L.DoString(`print(double(20))`); err != nil {
14 | panic(err)
15 | }
16 | }
17 |
18 |
19 | func Double(L *lua.LState) int {
20 | lv := L.ToInt(1) // 获取第一个参数
21 | L.Push(lua.LNumber(lv * 2)) // 写入返回值
22 | return 1 // 返回
23 | }
--------------------------------------------------------------------------------
/gokit/shipping/routing/routing.go:
--------------------------------------------------------------------------------
1 | // Package routing provides the routing domain service. It does not actually
2 | // implement the routing service but merely acts as a proxy for a separate
3 | // bounded context.
4 | package routing
5 |
6 | import (
7 | "github.com/feixiao/learning/gokit/shipping/cargo"
8 | )
9 |
10 | // Service provides access to an external routing service.
11 | type Service interface {
12 | // FetchRoutesForSpecification finds all possible routes that satisfy a
13 | // given specification.
14 | FetchRoutesForSpecification(rs cargo.RouteSpecification) []cargo.Itinerary
15 | }
16 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/virtual-service-ratings-test-abort.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: ratings
5 | spec:
6 | hosts:
7 | - ratings
8 | http:
9 | - match:
10 | - headers:
11 | end-user:
12 | exact: jason
13 | fault:
14 | abort:
15 | percentage:
16 | value: 100.0
17 | httpStatus: 500
18 | route:
19 | - destination:
20 | host: ratings
21 | subset: v1
22 | - route:
23 | - destination:
24 | host: ratings
25 | subset: v1
26 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/virtual-service-ratings-test-delay.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: ratings
5 | spec:
6 | hosts:
7 | - ratings
8 | http:
9 | - match:
10 | - headers:
11 | end-user:
12 | exact: jason
13 | fault:
14 | delay:
15 | percentage:
16 | value: 100.0
17 | fixedDelay: 7s
18 | route:
19 | - destination:
20 | host: ratings
21 | subset: v1
22 | - route:
23 | - destination:
24 | host: ratings
25 | subset: v1
26 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/internal/data/data.go:
--------------------------------------------------------------------------------
1 | package data
2 |
3 | import (
4 | "helloworld/internal/conf"
5 | "github.com/go-kratos/kratos/v2/log"
6 | "github.com/google/wire"
7 | )
8 |
9 | // ProviderSet is data providers.
10 | var ProviderSet = wire.NewSet(NewData, NewGreeterRepo)
11 |
12 | // Data .
13 | type Data struct {
14 | // TODO warpped database client
15 | }
16 |
17 | // NewData .
18 | func NewData(c *conf.Data, logger log.Logger) (*Data, func(), error) {
19 | cleanup := func() {
20 | logger.Log(log.LevelInfo, "closing the data resources")
21 | }
22 | return &Data{}, cleanup, nil
23 | }
24 |
--------------------------------------------------------------------------------
/gokit/ss2/service.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "strings"
5 | "errors"
6 | )
7 |
8 | // ErrEmpty 提示输入为空
9 | var ErrEmpty = errors.New("empty string")
10 |
11 | // 服务定义
12 |
13 | // StringService 提供了针对string的操作
14 | type StringService interface {
15 | Uppercase(string) (string, error)
16 | Count(string) int
17 | }
18 |
19 | type stringService struct{}
20 |
21 | func (stringService) Uppercase(s string )(string,error) {
22 | if s == "" {
23 | return "",ErrEmpty
24 | }
25 | return strings.ToUpper(s),nil
26 | }
27 |
28 | func (stringService) Count(s string) int {
29 | return len(s)
30 | }
31 |
--------------------------------------------------------------------------------
/kratosV2/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## Kratos V2熟悉
2 |
3 | #### 安装
4 | ```shell
5 | go env -w GO111MODULE=on
6 | go install github.com/go-kratos/kratos/cmd/kratos/v2@latest
7 |
8 | # 验证版本
9 | ➜ ~ kratos -v
10 | kratos version v2.0.0-rc1
11 | ```
12 |
13 |
14 | #### 使用
15 | ```shell
16 | # 创建项目模板
17 | kratos new helloworld
18 |
19 | cd helloworld
20 | # 拉取项目依赖
21 | go mod download
22 |
23 | # 生成proto模板
24 | kratos proto add api/helloworld/helloworld.proto
25 |
26 | # 生成proto源码
27 | kratos proto client api/helloworld/helloworld.proto
28 |
29 | # 生成server模板
30 | kratos proto server api/helloworld/helloworld.proto -t internal/service
31 | ```
--------------------------------------------------------------------------------
/gokit/shipping/location/location.go:
--------------------------------------------------------------------------------
1 | package location
2 |
3 | import "errors"
4 |
5 | // UNLocode 美国的位置编码,唯一的标示特定的位置。
6 | // http://www.unece.org/cefact/locode/
7 | // http://www.unece.org/cefact/locode/DocColumnDescription.htm#LOCODE
8 | type UNLocode string
9 |
10 | // Location 在我们的模型中表示位置(起点,终点,移动位置)
11 | type Location struct {
12 | UNLocode UNLocode
13 | Name string
14 | }
15 |
16 | // ErrUnknown 用于表示当找不到某个位置的时候
17 | var ErrUnknown = errors.New("unknown location")
18 |
19 | // Repository 提供查询地理库的接口
20 | type Repository interface {
21 | Find(locode UNLocode)(*Location, error)
22 | FindAll() []*Location
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/grpc/examples/grpc-gateway/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## grpc-gateway入门
2 |
3 | #### 生成文件
4 | ```shell
5 | // 生成grpc结构文件
6 | protoc --proto_path=./ -I/usr/local/include -I. -I$GOPATH/src -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=plugins=grpc:. gateway.proto
7 |
8 | // 生成gateway文件
9 | protoc --proto_path=../ -I/usr/local/include -I. -I$GOPATH/src -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --grpc-gateway_out=logtostderr=true:. gateway.proto
10 | ```
11 |
12 |
13 | #### 参考资料
14 | + [《Grpc-Gateway - Grpc兼容HTTP协议文档自动生成网关》](https://my.oschina.net/wenzhenxi/blog/3023874)
--------------------------------------------------------------------------------
/etcd/raft/src/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // 使用 IntelliSense 了解相关属性。
3 | // 悬停以查看现有属性的描述。
4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Launch",
9 | "type": "go",
10 | "request": "launch",
11 | "mode": "debug",
12 | "remotePath": "",
13 | "port": 2345,
14 | "host": "127.0.0.1",
15 | "program": "${fileDirname}",
16 | "env": {},
17 | "args": [],
18 | "showLog": true
19 | }
20 | ]
21 | }
--------------------------------------------------------------------------------
/istio/samples/httpbin/httpbin-gateway.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: Gateway
3 | metadata:
4 | name: httpbin-gateway
5 | spec:
6 | selector:
7 | istio: ingressgateway
8 | servers:
9 | - port:
10 | number: 80
11 | name: http
12 | protocol: HTTP
13 | hosts:
14 | - "*"
15 | ---
16 | apiVersion: networking.istio.io/v1alpha3
17 | kind: VirtualService
18 | metadata:
19 | name: httpbin
20 | spec:
21 | hosts:
22 | - "*"
23 | gateways:
24 | - httpbin-gateway
25 | http:
26 | - route:
27 | - destination:
28 | host: httpbin
29 | port:
30 | number: 8000
31 |
--------------------------------------------------------------------------------
/etcd/etcd.md:
--------------------------------------------------------------------------------
1 | ## Etcd学习整理
2 |
3 | Etcd是用于共享配置和服务发现的分布式,一致性的KV存储系统。etcd作为一个受到ZooKeeper与doozer启发而催生的项目,除了拥有与之类似的功能外,更专注于以下四点。
4 |
5 | - 简单:基于HTTP+JSON的API让你用curl就可以轻松使用。
6 | - 安全:可选SSL客户认证机制。
7 | - 快速:每个实例每秒支持一千次写操作。
8 | - 可信:使用Raft算法充分实现了分布式。
9 |
10 | ### Raft实现
11 |
12 | + [etcd/raft](https://github.com/coreos/etcd/tree/master/raft)
13 |
14 | ### 参考资料
15 |
16 | + [《ETCD系列一:简介》](https://yq.aliyun.com/articles/11035?spm=5176.8091938.0.0.v9RtUj)
17 | + [《etcd:从应用场景到实现原理的全方位解读》](http://www.infoq.com/cn/articles/etcd-interpretation-application-scenario-implement-principle)
18 | + [《CoreOS 实战:剖析 etcd》](http://www.infoq.com/cn/articles/coreos-analyse-etcd/)
--------------------------------------------------------------------------------
/gopher-lua/context/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "context"
5 | "time"
6 | lua "github.com/yuin/gopher-lua"
7 | )
8 |
9 | // 超时处理
10 | func main() {
11 | L := lua.NewState()
12 | defer L.Close()
13 | ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
14 | defer cancel()
15 | // set the context to our LState
16 | L.SetContext(ctx)
17 | err := L.DoString(`
18 | local clock = os.clock
19 | function sleep(n) -- seconds
20 | local t0 = clock()
21 | while clock() - t0 <= n do end
22 | end
23 | sleep(3)
24 | `)
25 |
26 | if err != nil {
27 | panic(err)
28 | }
29 | // <- ctx.Done()
30 |
31 | }
--------------------------------------------------------------------------------
/gokit/shipping/tracking/logging.go:
--------------------------------------------------------------------------------
1 | package tracking
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/go-kit/kit/log"
7 | )
8 |
9 | type loggingService struct {
10 | logger log.Logger
11 | Service
12 | }
13 |
14 | // NewLoggingService returns a new instance of a logging Service.
15 | func NewLoggingService(logger log.Logger, s Service) Service {
16 | return &loggingService{logger, s}
17 | }
18 |
19 | func (s *loggingService) Track(id string) (c Cargo, err error) {
20 | defer func(begin time.Time) {
21 | s.logger.Log("method", "track", "tracking_id", id, "took", time.Since(begin), "err", err)
22 | }(time.Now())
23 | return s.Service.Track(id)
24 | }
25 |
--------------------------------------------------------------------------------
/istio/samples/websockets/route.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: Gateway
3 | metadata:
4 | name: tornado-gateway
5 | spec:
6 | selector:
7 | istio: ingressgateway
8 | servers:
9 | - port:
10 | number: 80
11 | name: http
12 | protocol: HTTP
13 | hosts:
14 | - "*"
15 | ---
16 | apiVersion: networking.istio.io/v1alpha3
17 | kind: VirtualService
18 | metadata:
19 | name: tornado
20 | spec:
21 | hosts:
22 | - "*"
23 | gateways:
24 | - tornado-gateway
25 | http:
26 | - match:
27 | - uri:
28 | prefix: /
29 | route:
30 | - destination:
31 | host: tornado
32 | weight: 100
33 |
--------------------------------------------------------------------------------
/gokit/ss3/service.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "strings"
5 | "errors"
6 | )
7 |
8 | // ErrEmpty 提示输入为空
9 | var ErrEmpty = errors.New("empty string")
10 |
11 | // 服务定义
12 |
13 | // StringService 提供了针对string的操作
14 | type StringService interface {
15 | Uppercase(string) (string, error)
16 | Count(string) int
17 | }
18 |
19 | type stringService struct{}
20 |
21 | func (stringService) Uppercase(s string )(string,error) {
22 | if s == "" {
23 | return "",ErrEmpty
24 | }
25 | return strings.ToUpper(s),nil
26 | }
27 |
28 | func (stringService) Count(s string) int {
29 | return len(s)
30 | }
31 |
32 |
33 | type ServiceMiddleware func(StringService) StringService
--------------------------------------------------------------------------------
/istio/samples/external/aptget.yaml:
--------------------------------------------------------------------------------
1 | # This ServiceEntry exposes the hosts needed for installing packages with apt-get.
2 | # After applying this file, Istio-enabled pods (configured apt-get) be able to execute
3 | # `apt-get upgrade` and `apt-get install`. If this is not installed you may get
4 | # "404 Not Found"
5 |
6 | apiVersion: networking.istio.io/v1alpha3
7 | kind: ServiceEntry
8 | metadata:
9 | name: make-aptget-work
10 | spec:
11 | hosts:
12 | - deb.debian.org
13 | - cdn-fastly.deb.debian.org
14 | - security.debian.org
15 | - archive.ubuntu.com
16 | - security.ubuntu.com
17 | ports:
18 | - number: 80
19 | name: http
20 | protocol: HTTP
21 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/internal/data/greeter.go:
--------------------------------------------------------------------------------
1 | package data
2 |
3 | import (
4 | "context"
5 | "helloworld/internal/biz"
6 | "github.com/go-kratos/kratos/v2/log"
7 | )
8 |
9 | type greeterRepo struct {
10 | data *Data
11 | log *log.Helper
12 | }
13 |
14 | // NewGreeterRepo .
15 | func NewGreeterRepo(data *Data, logger log.Logger) biz.GreeterRepo {
16 | return &greeterRepo{
17 | data: data,
18 | log: log.NewHelper(logger),
19 | }
20 | }
21 |
22 | func (r *greeterRepo) CreateGreeter(ctx context.Context, g *biz.Greeter) error {
23 | return nil
24 | }
25 |
26 | func (r *greeterRepo) UpdateGreeter(ctx context.Context, g *biz.Greeter) error {
27 | return nil
28 | }
29 |
--------------------------------------------------------------------------------
/gokit/shipping/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## shipping
2 |
3 | shipping演示了一个更真实的由多个服务组成的应用程序。 程序详细情况参考书籍[《领域驱动设计》](https://book.douban.com/subject/26819666/)。
4 |
5 |
6 | ### 结构
7 |
8 | shipping由booking、handling和tracking三个服务组成。每个服务都是跟之前的例子一样独立的Gokit服务。
9 |
10 | + booking
11 |
12 | **航运公司**用来预订和规划货船。
13 |
14 | + handling
15 |
16 | **工作人员**记录货船什么时候到达、装货等等。
17 |
18 | + tracking
19 |
20 | **航运公司顾客**使用沿着路线跟踪货物。
21 |
22 | 有一些纯粹的领域包(domain pakcages),它们包含了一些复杂的业务逻辑。它们提供领域对象和领域服务,
23 |
24 | 这些领域对象和服务为每个应用程序服务使用从而为用户提供有趣的用例。
25 |
26 | + inmem 包括了 in-memory实现, 可以在领域包中找到。
27 | + route 包提供了领域服务,用于查询外部应用程序以获得可能的路由。
28 |
29 | ### 包说明
30 |
31 | + location 模拟位置信息
32 |
33 | + voyage 模拟航线信息
34 |
35 |
36 |
--------------------------------------------------------------------------------
/gokit/shipping/tracking/endpoint.go:
--------------------------------------------------------------------------------
1 | package tracking
2 |
3 | import (
4 | "context"
5 |
6 | "github.com/go-kit/kit/endpoint"
7 | )
8 |
9 | type trackCargoRequest struct {
10 | ID string
11 | }
12 |
13 | type trackCargoResponse struct {
14 | Cargo *Cargo `json:"cargo,omitempty"`
15 | Err error `json:"error,omitempty"`
16 | }
17 |
18 | func (r trackCargoResponse) error() error { return r.Err }
19 |
20 | func makeTrackCargoEndpoint(ts Service) endpoint.Endpoint {
21 | return func(ctx context.Context, request interface{}) (interface{}, error) {
22 | req := request.(trackCargoRequest)
23 | c, err := ts.Track(req.ID)
24 | return trackCargoResponse{Cargo: &c, Err: err}, nil
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/traefik/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## Traefik快速入门
2 |
3 | ### 部署基础环境
4 | #### 启动reverse-proxy
5 | ```shell
6 | docker-compose up -d reverse-proxy
7 | ```
8 |
9 | #### 启动whoami
10 | ```shell
11 | docker-compose up -d whoami
12 | ```
13 |
14 | #### 测试
15 | ```shell
16 | curl -H Host:whoami.docker.localhost http://127.0.0.1
17 | ```
18 |
19 | #### 负载均衡测试
20 | ```shell
21 | # 启动两个
22 | docker-compose up -d --scale whoami=2
23 |
24 | # 测试
25 | curl -H Host:whoami.docker.localhost http://127.0.0.1
26 | ```
27 |
28 | #### Traefik后台
29 | ```shell
30 | http://172.20.99.13:8080/dashboard/#/
31 | ```
32 |
33 | ### 参考资料
34 | + [《Traefik简易入门》](https://shanyue.tech/op/traefik.html#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B)
35 |
36 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/productpage/requirements.txt:
--------------------------------------------------------------------------------
1 | certifi==2019.3.9
2 | chardet==3.0.4
3 | Click==7.0
4 | contextlib2==0.5.5
5 | dominate==2.3.5
6 | Flask==1.0.2
7 | Flask-Bootstrap==3.3.7.1
8 | Flask-JSON==0.3.3
9 | future==0.17.1
10 | futures==3.1.1
11 | gevent==1.4.0
12 | greenlet==0.4.15
13 | idna==2.8
14 | itsdangerous==1.1.0
15 | jaeger-client==3.13.0
16 | Jinja2==2.10.1
17 | json2html==1.2.1
18 | MarkupSafe==0.23
19 | nose==1.3.7
20 | opentracing==1.2.2
21 | opentracing-instrumentation==2.4.3
22 | requests==2.21.0
23 | simplejson==3.16.0
24 | six==1.12.0
25 | threadloop==1.0.2
26 | thrift==0.11.0
27 | tornado==4.5.3
28 | urllib3==1.24.2
29 | visitor==0.1.3
30 | Werkzeug==0.15.5
31 | wrapt==1.11.1
32 |
--------------------------------------------------------------------------------
/clickhouse/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## ClickHouse 快速入门
2 |
3 | #### 安装
4 | ```shell
5 | sudo apt-get install apt-transport-https ca-certificates dirmngr
6 | sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E0C56BD4
7 |
8 | echo "deb https://repo.clickhouse.com/deb/stable/ main/" | sudo tee \
9 | /etc/apt/sources.list.d/clickhouse.list
10 | sudo apt-get update
11 |
12 | sudo apt-get install -y clickhouse-server clickhouse-client # 密码设置了123456
13 |
14 | # 服务端
15 | sudo service clickhouse-server start
16 |
17 | # 客户端
18 | clickhouse-client # or "clickhouse-client --password" if you set up a password.
19 | ```
20 |
21 |
22 | #### 参考资料
23 | + [https://clickhouse.com/#quick-start](https://clickhouse.com/#quick-start)
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/fault-injection-details-v1.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: details
5 | spec:
6 | hosts:
7 | - details
8 | http:
9 | - fault:
10 | abort:
11 | httpStatus: 555
12 | percentage:
13 | value: 100
14 | route:
15 | - destination:
16 | host: details
17 | subset: v1
18 | - route:
19 | - destination:
20 | host: details
21 | subset: v1
22 | ---
23 | apiVersion: networking.istio.io/v1alpha3
24 | kind: DestinationRule
25 | metadata:
26 | name: details
27 | spec:
28 | host: details
29 | subsets:
30 | - name: v1
31 | labels:
32 | version: v1
--------------------------------------------------------------------------------
/kratosV2/helloworld/.gitignore:
--------------------------------------------------------------------------------
1 | # Reference https://github.com/github/gitignore/blob/master/Go.gitignore
2 | # Binaries for programs and plugins
3 | *.exe
4 | *.exe~
5 | *.dll
6 | *.so
7 | *.dylib
8 |
9 | # Test binary, built with `go test -c`
10 | *.test
11 |
12 | # Output of the go coverage tool, specifically when used with LiteIDE
13 | *.out
14 |
15 | # Dependency directories (remove the comment below to include it)
16 | vendor/
17 |
18 | # Compiled Object files, Static and Dynamic libs (Shared Objects)
19 | *.o
20 | *.a
21 | *.so
22 |
23 | # OS General
24 | Thumbs.db
25 | .DS_Store
26 |
27 | # project
28 | *.cert
29 | *.key
30 | *.log
31 | bin/
32 |
33 | # Develop tools
34 | .vscode/
35 | .idea/
36 | *.swp
37 |
--------------------------------------------------------------------------------
/redis/Redis学习路线整理.md:
--------------------------------------------------------------------------------
1 | ## Redis学习路线整理
2 |
3 | ### 快速入门
4 |
5 | + [《Redis入门指南》](https://book.douban.com/subject/24522045/)
6 | + [《Redis实战》](https://book.douban.com/subject/26612779/)
7 | + [Redis几种数据结构的应用场景](http://blog.csdn.net/xiaoliuliu2050/article/details/73250708)
8 |
9 | #### 集群方案
10 |
11 | + [codis](https://github.com/CodisLabs/codis)
12 | + [twemproxy](https://github.com/twitter/twemproxy)
13 | + 自带集群方案
14 |
15 | #### 源码分析
16 |
17 | + [《Redis设计与实现》](https://book.douban.com/subject/25900156/)
18 | + [redis-3.0注解版](https://github.com/huangz1990/redis-3.0-annotated)
19 |
20 | #### 在线文档
21 |
22 | + [《Redis 命令参考》](http://redisdoc.com/)
23 |
24 |
25 | #### 工具
26 | + [Redis GUI](https://github.com/uglide/RedisDesktopManager)
27 |
28 |
--------------------------------------------------------------------------------
/istio/samples/helloworld/helloworld-gateway.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: Gateway
3 | metadata:
4 | name: helloworld-gateway
5 | spec:
6 | selector:
7 | istio: ingressgateway # use istio default controller
8 | servers:
9 | - port:
10 | number: 80
11 | name: http
12 | protocol: HTTP
13 | hosts:
14 | - "*"
15 | ---
16 | apiVersion: networking.istio.io/v1alpha3
17 | kind: VirtualService
18 | metadata:
19 | name: helloworld
20 | spec:
21 | hosts:
22 | - "*"
23 | gateways:
24 | - helloworld-gateway
25 | http:
26 | - match:
27 | - uri:
28 | exact: /hello
29 | route:
30 | - destination:
31 | host: helloworld
32 | port:
33 | number: 5000
34 |
--------------------------------------------------------------------------------
/traefik/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | reverse-proxy:
5 | # The official v2 Traefik docker image
6 | image: traefik:v2.2
7 | # Enables the web UI and tells Traefik to listen to docker
8 | command: --api.insecure=true --providers.docker
9 | ports:
10 | # The HTTP port
11 | - "80:80"
12 | # The Web UI (enabled by --api.insecure=true)
13 | - "8080:8080"
14 | volumes:
15 | # So that Traefik can listen to the Docker events
16 | - /var/run/docker.sock:/var/run/docker.sock
17 | whoami:
18 | # A container that exposes an API to show its IP address
19 | image: containous/whoami
20 | labels:
21 | - "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"
--------------------------------------------------------------------------------
/gopher-lua/fib/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | lua "github.com/yuin/gopher-lua"
6 | )
7 |
8 | func main() {
9 | L := lua.NewState()
10 | defer L.Close()
11 | // 加载fib.lua
12 | if err := L.DoFile("fib.lua"); err != nil {
13 | panic(err)
14 | }
15 | // 调用fib(n)
16 | err := L.CallByParam( lua.P{
17 | Fn: L.GetGlobal("fib"), // 获取fib函数引用
18 | NRet: 1, // 指定返回值数量
19 | Protect: true, // 如果出现异常,是panic还是返回err
20 | }, lua.LNumber(3)) // 传递输入参数 n=3
21 | if err != nil {
22 | panic(err)
23 | }
24 | // 获取返回结果
25 | ret := L.Get(-1)
26 | // 从堆栈中扔掉返回结果
27 | L.Pop(0)
28 |
29 | res, ok := ret.(lua.LNumber)
30 | if ok {
31 | fmt.Println(int(res))
32 | }else {
33 | fmt.Println("unexpected result ")
34 | }
35 |
36 | }
--------------------------------------------------------------------------------
/tyk/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## tyk快速入门
2 |
3 | ### 编译
4 |
5 | + 下载tyk源代码 **tyk-2.5.1.zip**
6 |
7 | + 解压到$GOPATH/src/github.com/TykTechnologies/tyk
8 |
9 | + 编译
10 |
11 | ```
12 | govendor sync
13 | go build
14 | ```
15 |
16 | ### 安装
17 |
18 | ```
19 | sudo apt-get install redis-server
20 | ./tyk # 启动程序
21 | ```
22 |
23 |
24 |
25 |
26 | ### 参考资料
27 |
28 | + [《谈API网关的背景、架构以及落地方案 》](https://mp.weixin.qq.com/s?__biz=MzIwMzg1ODcwMw==&mid=2247486461&idx=1&sn=4f238a1f8046d652f0a05db2bdf55cd7&source=41#wechat_redirect)
29 | + [《深入浅出聊聊企业级API网关》](https://mp.weixin.qq.com/s?__biz=MzIwMzg1ODcwMw==&mid=2247486230&idx=1&sn=f8d9bba498cb0cebe98e61eb2b7678ba&source=41#wechat_redirect)
30 | + [《API网关规划与实施细则》](https://www.jianshu.com/p/34cfe5d12793)
31 |
32 |
--------------------------------------------------------------------------------
/etcd/raft/src/raft/doc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The etcd Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // raftexample is a simple KV store using the raft and rafthttp libraries.
16 | package main
17 |
--------------------------------------------------------------------------------
/istio/samples/helloworld/loadgen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright Istio Authors
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | while true; do curl -s -o /dev/null "http://$GATEWAY_URL/hello"; done
18 |
--------------------------------------------------------------------------------
/istio/samples/websockets/app.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | name: tornado
5 | labels:
6 | app: tornado
7 | service: tornado
8 | spec:
9 | ports:
10 | - port: 8888
11 | name: http
12 | selector:
13 | app: tornado
14 | ---
15 | apiVersion: apps/v1
16 | kind: Deployment
17 | metadata:
18 | name: tornado
19 | spec:
20 | replicas: 1
21 | selector:
22 | matchLabels:
23 | app: tornado
24 | version: v1
25 | template:
26 | metadata:
27 | labels:
28 | app: tornado
29 | version: v1
30 | spec:
31 | containers:
32 | - name: tornado
33 | image: hiroakis/tornado-websocket-example
34 | imagePullPolicy: IfNotPresent
35 | ports:
36 | - containerPort: 8888
37 | ---
38 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/mongodb/script.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright Istio Authors
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -e
18 | mongoimport --host localhost --db test --collection ratings --drop --file /app/data/ratings_data.json
19 |
--------------------------------------------------------------------------------
/grpc/examples/grpc-gateway/service.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "log"
5 | "net"
6 |
7 | pb "grpc-gateway"
8 | "google.golang.org/grpc"
9 | "golang.org/x/net/context"
10 | )
11 |
12 | const (
13 | PORT = ":9192"
14 | )
15 |
16 | type server struct {}
17 |
18 | func (s *server) Echo(ctx context.Context, in *pb.StringMessage) (*pb.StringMessage, error) {
19 | log.Println("request: ", in.Value)
20 | return &pb.StringMessage{Value: "Hello " + in.Value}, nil
21 | }
22 |
23 | func main() {
24 | lis, err := net.Listen("tcp", PORT)
25 |
26 | if err != nil {
27 | log.Fatalf("failed to listen: %v", err)
28 | }
29 |
30 | s := grpc.NewServer()
31 | pb.RegisterGatewayServer(s, &server{})
32 | log.Println("rpc服务已经开启")
33 | s.Serve(lis)
34 | }
--------------------------------------------------------------------------------
/go-zero/greet/internal/logic/greetlogic.go:
--------------------------------------------------------------------------------
1 | package logic
2 |
3 | import (
4 | "context"
5 |
6 | "github.com/feixiao/learning/go-zero/greet/internal/svc"
7 | "github.com/feixiao/learning/go-zero/greet/internal/types"
8 |
9 | "github.com/tal-tech/go-zero/core/logx"
10 | )
11 |
12 | type GreetLogic struct {
13 | logx.Logger
14 | ctx context.Context
15 | svcCtx *svc.ServiceContext
16 | }
17 |
18 | func NewGreetLogic(ctx context.Context, svcCtx *svc.ServiceContext) GreetLogic {
19 | return GreetLogic{
20 | Logger: logx.WithContext(ctx),
21 | ctx: ctx,
22 | svcCtx: svcCtx,
23 | }
24 | }
25 |
26 | func (l *GreetLogic) Greet(req types.Request) (*types.Response, error) {
27 | // todo: add your logic here and delete this line
28 |
29 | return &types.Response{Message: "just test"}, nil
30 | }
31 |
--------------------------------------------------------------------------------
/go-zero/greet/internal/handler/greethandler.go:
--------------------------------------------------------------------------------
1 | package handler
2 |
3 | import (
4 | "net/http"
5 |
6 | "github.com/feixiao/learning/go-zero/greet/internal/logic"
7 | "github.com/feixiao/learning/go-zero/greet/internal/svc"
8 | "github.com/feixiao/learning/go-zero/greet/internal/types"
9 |
10 | "github.com/tal-tech/go-zero/rest/httpx"
11 | )
12 |
13 | func greetHandler(ctx *svc.ServiceContext) http.HandlerFunc {
14 | return func(w http.ResponseWriter, r *http.Request) {
15 | var req types.Request
16 | if err := httpx.Parse(r, &req); err != nil {
17 | httpx.Error(w, err)
18 | return
19 | }
20 |
21 | l := logic.NewGreetLogic(r.Context(), ctx)
22 | resp, err := l.Greet(req)
23 |
24 | if err != nil {
25 | httpx.Error(w, err)
26 | } else {
27 | httpx.OkJson(w, resp)
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/mysql/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM mysql:8.0.20
16 | # MYSQL_ROOT_PASSWORD must be supplied as an env var
17 |
18 | COPY ./mysqldb-init.sql /docker-entrypoint-initdb.d
19 |
--------------------------------------------------------------------------------
/istio/samples/custom-bootstrap/example-app.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1
2 | kind: Deployment
3 | metadata:
4 | name: helloworld-v1
5 | labels:
6 | app: helloworld
7 | version: v1
8 | spec:
9 | replicas: 1
10 | selector:
11 | matchLabels:
12 | app: helloworld
13 | version: v1
14 | template:
15 | metadata:
16 | annotations:
17 | sidecar.istio.io/bootstrapOverride: "istio-custom-bootstrap-config"
18 | labels:
19 | app: helloworld
20 | version: v1
21 | spec:
22 | containers:
23 | - name: helloworld
24 | image: docker.io/istio/examples-helloworld-v1
25 | resources:
26 | requests:
27 | cpu: "100m"
28 | imagePullPolicy: IfNotPresent
29 | ports:
30 | - containerPort: 5000
31 |
--------------------------------------------------------------------------------
/go-zero/greet/greet.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 |
7 | "github.com/feixiao/learning/go-zero/greet/internal/config"
8 | "github.com/feixiao/learning/go-zero/greet/internal/handler"
9 | "github.com/feixiao/learning/go-zero/greet/internal/svc"
10 |
11 | "github.com/tal-tech/go-zero/core/conf"
12 | "github.com/tal-tech/go-zero/rest"
13 | )
14 |
15 | var configFile = flag.String("f", "etc/greet-api.yaml", "the config file")
16 |
17 | func main() {
18 | flag.Parse()
19 |
20 | var c config.Config
21 | conf.MustLoad(*configFile, &c)
22 |
23 | ctx := svc.NewServiceContext(c)
24 | server := rest.MustNewServer(c.RestConf)
25 | defer server.Stop()
26 |
27 | handler.RegisterHandlers(server, ctx)
28 |
29 | fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
30 | server.Start()
31 | }
32 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/certmanager-gateway.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: Gateway
3 | metadata:
4 | name: cert-manager-gateway
5 | namespace: istio-system
6 | spec:
7 | selector:
8 | istio: ingressgateway
9 | servers:
10 | - port:
11 | number: 80
12 | name: http
13 | protocol: HTTP
14 | hosts:
15 | - "*"
16 | ---
17 | apiVersion: networking.istio.io/v1alpha3
18 | kind: VirtualService
19 | metadata:
20 | name: cert-manager
21 | namespace: istio-system
22 | spec:
23 | hosts:
24 | - "*"
25 | gateways:
26 | - cert-manager-gateway
27 | http:
28 | - match:
29 | - uri:
30 | prefix: /.well-known/acme-challenge/
31 | route:
32 | - destination:
33 | host: cert-manager-resolver
34 | port:
35 | number: 8089
36 |
--------------------------------------------------------------------------------
/gokit/shipping/location/sample_locations.go:
--------------------------------------------------------------------------------
1 | package location
2 |
3 | // Sample UN locodes.
4 | var (
5 | SESTO UNLocode = "SESTO"
6 | AUMEL UNLocode = "AUMEL"
7 | CNHKG UNLocode = "CNHKG"
8 | USNYC UNLocode = "USNYC"
9 | USCHI UNLocode = "USCHI"
10 | JNTKO UNLocode = "JNTKO"
11 | DEHAM UNLocode = "DEHAM"
12 | NLRTM UNLocode = "NLRTM"
13 | FIHEL UNLocode = "FIHEL"
14 | )
15 |
16 | // Sample locations.
17 | var (
18 | Stockholm = &Location{SESTO, "Stockholm"}
19 | Melbourne = &Location{AUMEL, "Melbourne"}
20 | Hongkong = &Location{CNHKG, "Hongkong"}
21 | NewYork = &Location{USNYC, "New York"}
22 | Chicago = &Location{USCHI, "Chicago"}
23 | Tokyo = &Location{JNTKO, "Tokyo"}
24 | Hamburg = &Location{DEHAM, "Hamburg"}
25 | Rotterdam = &Location{NLRTM, "Rotterdam"}
26 | Helsinki = &Location{FIHEL, "Helsinki"}
27 | )
--------------------------------------------------------------------------------
/gokit/ss2/logging.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/go-kit/kit/log"
5 | "time"
6 | )
7 |
8 | type loggingMiddleware struct {
9 | logger log.Logger
10 | next StringService
11 | }
12 |
13 | func (mw loggingMiddleware) Uppercase(s string)(output string,err error) {
14 | defer func(begin time.Time) {
15 | _ = mw.logger.Log(
16 | "method","uppercase","input",s,"output",output,
17 | "err", err,"took", time.Since(begin),
18 | )
19 | }(time.Now())
20 |
21 | output, err = mw.next.Uppercase(s)
22 | return
23 | }
24 |
25 | func (mw loggingMiddleware) Count(s string) (n int) {
26 | defer func(begin time.Time) {
27 | _ = mw.logger.Log(
28 | "method", "count",
29 | "input", s,
30 | "n", n,
31 | "took", time.Since(begin),
32 | )
33 | }(time.Now())
34 |
35 | n = mw.next.Count(s)
36 | return
37 | }
--------------------------------------------------------------------------------
/gokit/ss3/logging.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/go-kit/kit/log"
5 | "time"
6 | )
7 |
8 | type loggingMiddleware struct {
9 | logger log.Logger
10 | next StringService
11 | }
12 |
13 | func (mw loggingMiddleware) Uppercase(s string)(output string,err error) {
14 | defer func(begin time.Time) {
15 | _ = mw.logger.Log(
16 | "method","uppercase","input",s,"output",output,
17 | "err", err,"took", time.Since(begin),
18 | )
19 | }(time.Now())
20 |
21 | output, err = mw.next.Uppercase(s)
22 | return
23 | }
24 |
25 | func (mw loggingMiddleware) Count(s string) (n int) {
26 | defer func(begin time.Time) {
27 | _ = mw.logger.Log(
28 | "method", "count",
29 | "input", s,
30 | "n", n,
31 | "took", time.Since(begin),
32 | )
33 | }(time.Now())
34 |
35 | n = mw.next.Count(s)
36 | return
37 | }
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/reviews/reviews-application/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'war'
2 |
3 | sourceCompatibility = 1.8
4 |
5 | repositories {
6 | mavenCentral()
7 | }
8 |
9 | dependencies {
10 | providedCompile group:'javax.websocket', name:'javax.websocket-api', version:'1.1'
11 | providedCompile group:'javax.ws.rs', name:'javax.ws.rs-api', version:'2.0'
12 | providedCompile group:'javax.json', name:'javax.json-api', version:'1.0'
13 | providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
14 | providedCompile 'javax.annotation:javax.annotation-api:1.2'
15 | providedCompile 'javax.inject:javax.inject:1'
16 | providedCompile 'javax.enterprise.concurrent:javax.enterprise.concurrent-api:1.0'
17 | providedCompile 'javax.enterprise:cdi-api:1.2'
18 | providedCompile 'io.swagger:swagger-annotations:1.5.0'
19 | }
20 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/internal/biz/greeter.go:
--------------------------------------------------------------------------------
1 | package biz
2 |
3 | import (
4 | "context"
5 | "github.com/go-kratos/kratos/v2/log"
6 | )
7 |
8 | type Greeter struct {
9 | Hello string
10 | }
11 |
12 | type GreeterRepo interface {
13 | CreateGreeter(context.Context, *Greeter) error
14 | UpdateGreeter(context.Context, *Greeter) error
15 | }
16 |
17 | type GreeterUsecase struct {
18 | repo GreeterRepo
19 | log *log.Helper
20 | }
21 |
22 | func NewGreeterUsecase(repo GreeterRepo, logger log.Logger) *GreeterUsecase {
23 | return &GreeterUsecase{repo: repo, log: log.NewHelper(logger)}
24 | }
25 |
26 | func (uc *GreeterUsecase) Create(ctx context.Context, g *Greeter) error {
27 | return uc.repo.CreateGreeter(ctx, g)
28 | }
29 |
30 | func (uc *GreeterUsecase) Update(ctx context.Context, g *Greeter) error {
31 | return uc.repo.UpdateGreeter(ctx, g)
32 | }
33 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/api/helloworld/v1/greeter.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package helloworld.v1;
4 |
5 | import "google/api/annotations.proto";
6 |
7 | option go_package = "helloworld/api/helloworld/v1;v1";
8 | option java_multiple_files = true;
9 | option java_package = "dev.kratos.api.helloworld.v1";
10 | option java_outer_classname = "HelloWorldProtoV1";
11 |
12 | // The greeting service definition.
13 | service Greeter {
14 | // Sends a greeting
15 | rpc SayHello (HelloRequest) returns (HelloReply) {
16 | option (google.api.http) = {
17 | get: "/helloworld/{name}"
18 | };
19 | }
20 | }
21 |
22 | // The request message containing the user's name.
23 | message HelloRequest {
24 | string name = 1;
25 | }
26 |
27 | // The response message containing the greetings
28 | message HelloReply {
29 | string message = 1;
30 | }
31 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/mongodb/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM mongo:4.0.19-xenial
16 | WORKDIR /app/data/
17 | COPY ratings_data.json /app/data/
18 | COPY script.sh /docker-entrypoint-initdb.d/
19 | RUN chmod +x /docker-entrypoint-initdb.d/script.sh
20 |
--------------------------------------------------------------------------------
/jupiter/example/quickstart/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/douyu/jupiter"
5 | "github.com/douyu/jupiter/pkg/server/xecho"
6 | "github.com/douyu/jupiter/pkg/xlog"
7 | "github.com/labstack/echo/v4"
8 | )
9 |
10 | func main() {
11 | eng := NewEngine()
12 | if err := eng.Run(); err != nil {
13 | xlog.Error(err.Error())
14 | }
15 | }
16 |
17 | type Engine struct {
18 | jupiter.Application
19 | }
20 |
21 | func NewEngine() *Engine {
22 | eng := &Engine{}
23 | if err := eng.Startup(
24 | eng.serveHTTP,
25 | ); err != nil {
26 | xlog.Panic("startup", xlog.Any("err", err))
27 | }
28 | return eng
29 | }
30 |
31 | // HTTP地址
32 | func (eng *Engine) serveHTTP() error {
33 | server := xecho.StdConfig("http").Build()
34 | server.GET("/hello", func(ctx echo.Context) error {
35 | return ctx.JSON(200, "Gopher Wuhan")
36 | })
37 | return eng.Serve(server)
38 | }
39 |
--------------------------------------------------------------------------------
/go-zero/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## Go-Zero 快速入门
2 |
3 | #### 视频和 PPT
4 |
5 | - [《go-zero ppt》](https://docs.google.com/presentation/d/1eRAO2pAjHztrQTpK_2A1CixelFI9Oupht0TkxLTKFG8/edit#slide=id.g8bf5e94d15_1_20)
6 |
7 | - [B 站视频介绍 go-zero](https://www.bilibili.com/video/BV1rD4y127PD/)
8 |
9 | #### 文档
10 |
11 | https://www.yuque.com/tal-tech/go-zero
12 |
13 | #### 快速使用
14 |
15 | ```shell
16 | # 创建和启动服务
17 | goctl api new greet
18 | cd greet
19 | go run greet.go -f etc/greet-api.yaml
20 |
21 | # 访问接口
22 | curl -i http://localhost:8888/greet/from/you
23 | ```
24 |
25 | ##### 目录结构
26 |
27 | - [great/ReadMe.md](./greet/ReadMe.md) 目录结构、操作流程、以及客户端代码的生成。
28 |
29 | #### 官方完整的 Demo
30 |
31 | - [bookstore](https://gitee.com/frank2020/go-zero/tree/master/example/bookstore) BookStore 运行和分析。
32 | - [文档](https://www.yuque.com/tal-tech/go-zero/rm435c)
33 |
34 | #### 源码分析
35 |
36 | https://gitee.com/frank2020/go-zero
37 |
--------------------------------------------------------------------------------
/gokit/shipping/tracking/instrumenting.go:
--------------------------------------------------------------------------------
1 | package tracking
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/go-kit/kit/metrics"
7 | )
8 |
9 | type instrumentingService struct {
10 | requestCount metrics.Counter
11 | requestLatency metrics.Histogram
12 | Service
13 | }
14 |
15 | // NewInstrumentingService returns an instance of an instrumenting Service.
16 | func NewInstrumentingService(counter metrics.Counter, latency metrics.Histogram, s Service) Service {
17 | return &instrumentingService{
18 | requestCount: counter,
19 | requestLatency: latency,
20 | Service: s,
21 | }
22 | }
23 |
24 | func (s *instrumentingService) Track(id string) (Cargo, error) {
25 | defer func(begin time.Time) {
26 | s.requestCount.With("method", "track").Add(1)
27 | s.requestLatency.With("method", "track").Observe(time.Since(begin).Seconds())
28 | }(time.Now())
29 |
30 | return s.Service.Track(id)
31 | }
32 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/bookinfo-gateway.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: Gateway
3 | metadata:
4 | name: bookinfo-gateway
5 | spec:
6 | selector:
7 | istio: ingressgateway # use istio default controller
8 | servers:
9 | - port:
10 | number: 80
11 | name: http
12 | protocol: HTTP
13 | hosts:
14 | - "*"
15 | ---
16 | apiVersion: networking.istio.io/v1alpha3
17 | kind: VirtualService
18 | metadata:
19 | name: bookinfo
20 | spec:
21 | hosts:
22 | - "*"
23 | gateways:
24 | - bookinfo-gateway
25 | http:
26 | - match:
27 | - uri:
28 | exact: /productpage
29 | - uri:
30 | prefix: /static
31 | - uri:
32 | exact: /login
33 | - uri:
34 | exact: /logout
35 | - uri:
36 | prefix: /api/v1/products
37 | route:
38 | - destination:
39 | host: productpage
40 | port:
41 | number: 9080
42 |
--------------------------------------------------------------------------------
/istio/samples/helloworld/src/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM python:2-onbuild
16 |
17 | WORKDIR /opt/microservices
18 | COPY app.py /opt/microservices/
19 |
20 | EXPOSE 5000
21 |
22 | ARG service_version
23 | ENV SERVICE_VERSION ${service_version:-v1}
24 |
25 | WORKDIR /opt/microservices
26 | CMD ["python", "app.py"]
27 |
--------------------------------------------------------------------------------
/istio/samples/health-check/liveness-http-same-port.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | name: liveness-http
5 | labels:
6 | app: liveness-http
7 | service: liveness-http
8 | spec:
9 | ports:
10 | - name: http
11 | port: 8001
12 | selector:
13 | app: liveness-http
14 | ---
15 | apiVersion: apps/v1
16 | kind: Deployment
17 | metadata:
18 | name: liveness-http
19 | spec:
20 | selector:
21 | matchLabels:
22 | app: liveness-http
23 | version: v1
24 | template:
25 | metadata:
26 | labels:
27 | app: liveness-http
28 | version: v1
29 | spec:
30 | containers:
31 | - name: liveness-http
32 | image: docker.io/istio/health:example
33 | ports:
34 | - containerPort: 8001
35 | livenessProbe:
36 | httpGet:
37 | path: /foo
38 | port: 8001
39 | initialDelaySeconds: 5
40 | periodSeconds: 5
41 |
--------------------------------------------------------------------------------
/tunnel/ReadMe.md:
--------------------------------------------------------------------------------
1 | # HTTP 隧道代理原理和实现
2 |
3 | ### 服务端
4 | + [《ngx_http_proxy_connect_module》](https://github.com/chobits/ngx_http_proxy_connect_module)
5 | + [charlesproxy](https://www.charlesproxy.com/)
6 | + [mitmproxy](https://mitmproxy.org/)
7 | + [HTTPTunnel](https://github.com/larsbrinkhoff/httptunnel)
8 | + [HTTPTunnel Package Description](https://tools.kali.org/maintaining-access/httptunnel)
9 | ```
10 | # 172.17.229.3
11 | nc -l 10000
12 | # 转发数据(20000端口到数据转发到172.17.229.3:10000)
13 | hts -w -F localhost:10000 20000
14 |
15 | # 172.17.229.2
16 | # 本地端口 8090 转发到 172.17.229.3:10000
17 | htc -T 30000 -k 20000 -w -F 8090 172.17.229.3:20000
18 |
19 | telnet localhost 8090 // 正常情况应该转发到172.17.229.3:10000
20 | ```
21 | ### 参考资料
22 | + [《HTTP 隧道代理原理和实现》](https://cizixs.com/2017/03/22/http-tunnel-proxy-and-golang-implementation/)
23 | + [《什么是HTTP隧道,怎么理解HTTP隧道呢?》](https://www.zhihu.com/question/21955083)
24 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/reviews/reviews-application/src/test/java/test/TestApplication.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 Istio Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *******************************************************************************/
16 | package test;
17 |
18 | public class TestApplication {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/internal/conf/conf.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package kratos.api;
3 |
4 | option go_package = "helloworld/internal/conf;conf";
5 |
6 | import "google/protobuf/duration.proto";
7 |
8 | message Bootstrap {
9 | Server server = 1;
10 | Data data = 2;
11 | }
12 |
13 | message Server {
14 | message HTTP {
15 | string network = 1;
16 | string addr = 2;
17 | google.protobuf.Duration timeout = 3;
18 | }
19 | message GRPC {
20 | string network = 1;
21 | string addr = 2;
22 | google.protobuf.Duration timeout = 3;
23 | }
24 | HTTP http = 1;
25 | GRPC grpc = 2;
26 | }
27 |
28 | message Data {
29 | message Database {
30 | string driver = 1;
31 | string source = 2;
32 | }
33 | message Redis {
34 | string network = 1;
35 | string addr = 2;
36 | google.protobuf.Duration read_timeout = 3;
37 | google.protobuf.Duration write_timeout = 4;
38 | }
39 | Database database = 1;
40 | Redis redis = 2;
41 | }
42 |
--------------------------------------------------------------------------------
/istio/samples/helloworld/src/build_service.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright Istio Authors
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -o errexit
18 |
19 | SCRIPTDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
20 |
21 | docker build -t istio/examples-helloworld-v1 --build-arg service_version=v1 "${SCRIPTDIR}"
22 | docker build -t istio/examples-helloworld-v2 --build-arg service_version=v2 "${SCRIPTDIR}"
23 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/README.md:
--------------------------------------------------------------------------------
1 | # Kratos Project Template
2 |
3 | ## Install Kratos
4 | ```
5 | go get -u github.com/go-kratos/kratos/cmd/kratos/v2@latest
6 | ```
7 | ## Create a service
8 | ```
9 | # create a template project
10 | kratos new helloworld
11 |
12 | cd helloworld
13 | # Add a proto template
14 | kratos proto add api/helloworld/helloworld.proto
15 | # Generate the source code of service by proto file
16 | kratos proto server api/helloworld/helloworld.proto -t internal/service
17 |
18 | go generate ./...
19 | go build -o ./bin/ ./...
20 | ./bin/helloworld -conf ./configs
21 | ```
22 | ## Automated Initialization (wire)
23 | ```
24 | # install wire
25 | go get github.com/google/wire/cmd/wire
26 |
27 | # generate wire
28 | cd cmd/server
29 | wire
30 | ```
31 |
32 | ## Docker
33 | ```bash
34 | # build
35 | docker build -t .
36 |
37 | # run
38 | docker run --rm -p 8000:8000 -p 9000:9000 -v :/data/conf
39 | ```
40 |
41 |
--------------------------------------------------------------------------------
/prometheus/client/vendor/vendor.json:
--------------------------------------------------------------------------------
1 | {
2 | "comment": "",
3 | "ignore": "test",
4 | "package": [
5 | {
6 | "checksumSHA1": "KkB+77Ziom7N6RzSbyUwYGrmDeU=",
7 | "path": "github.com/prometheus/client_golang/prometheus",
8 | "revision": "c5b7fccd204277076155f10851dad72b76a49317",
9 | "revisionTime": "2016-08-17T15:48:24Z",
10 | "version": "v0.8.0",
11 | "versionExact": "v0.8.0"
12 | },
13 | {
14 | "checksumSHA1": "lG3//eDlwqA4IOuAPrNtLh9G0TA=",
15 | "path": "github.com/prometheus/client_golang/prometheus/promhttp",
16 | "revision": "c5b7fccd204277076155f10851dad72b76a49317",
17 | "revisionTime": "2016-08-17T15:48:24Z",
18 | "version": "v0.8.0",
19 | "versionExact": "v0.8.0"
20 | },
21 | {
22 | "checksumSHA1": "vfMEr0lFwwocFKikCZS+1uHPoS4=",
23 | "path": "github.com/prometheus/node_exporter/collector",
24 | "revision": "v0.15.2",
25 | "version": "v0.15.2"
26 | }
27 | ],
28 | "rootPath": "github.com/feixiao/learning/prometheus/client"
29 | }
30 |
--------------------------------------------------------------------------------
/discovery/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## discovery快速入门
2 | ### 简介
3 | discovery是B站参考Eureka自研的服务注册发现系统。其前期使用Zookeeper为主,但是由于遇到如下一系列问题,从而自研discovery。
4 |
5 | + 用好难,维护难,二次开发难
6 | + 服务规模太大(3W+节点),一套zk集群很难满足大量的连接和写请求,但如果拆分服务类型维护多套集群又破坏了连通性
7 | + CP系统,对于微服务的服务注册发现,其实不如一套AP系统更可用
8 |
9 | ### 安装部署
10 | + WSL 不能编译运行(无法采集系统基础信息)
11 | + Windows上使用Docker
12 | ```
13 | docker pull golang:1.12.7
14 | docker run -it --name gobuild -v D:\volumes\golang:/go golang
15 |
16 | # 配置golang变量
17 | export GOPROXY=https://goproxy.io
18 | export GO111MODULE=on
19 | ```
20 | + 编译运行
21 | ```
22 | cd discovery/cmd/discovery
23 | go build
24 | ./discovery -conf discovery-example.toml
25 | ```
26 |
27 | ### 客户端接入(参考demo)
28 |
29 | ### 参考资料
30 | + [discovery介绍](https://github.com/bilibili/discovery/blob/master/doc/intro.md)
31 | + [设计概述](https://github.com/bilibili/discovery/blob/master/doc/arch.md)
32 | + [最佳事件](https://github.com/bilibili/discovery/blob/master/doc/practice.md)
--------------------------------------------------------------------------------
/gokit/ss2/instrumenting.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "time"
5 | "github.com/go-kit/kit/metrics"
6 | "fmt"
7 | )
8 |
9 | type instrumentingMiddleware struct {
10 | requestCount metrics.Counter
11 | requestLatency metrics.Histogram
12 | countResult metrics.Histogram
13 | next StringService
14 | }
15 |
16 | func (mw instrumentingMiddleware) Uppercase(s string)(output string, err error) {
17 | defer func(begin time.Time) {
18 | lvs :=[]string{"method","uppercase","error",fmt.Sprint(err!=nil)}
19 | mw.requestCount.With(lvs...).Add(1)
20 | mw.requestLatency.With(lvs...).Observe(time.Since(begin).Seconds())
21 | }(time.Now())
22 | output, err = mw.next.Uppercase(s)
23 | return
24 | }
25 |
26 | func (mw instrumentingMiddleware) Count(s string)(n int) {
27 | defer func(begin time.Time) {
28 | lvs :=[]string{"method","count","error","false"}
29 | mw.requestCount.With(lvs...).Add(1)
30 | mw.requestLatency.With(lvs...).Observe(time.Since(begin).Seconds())
31 | }(time.Now())
32 | n = mw.next.Count(s)
33 | return
34 | }
--------------------------------------------------------------------------------
/gokit/ss3/instrumenting.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "time"
5 | "github.com/go-kit/kit/metrics"
6 | "fmt"
7 | )
8 |
9 | type instrumentingMiddleware struct {
10 | requestCount metrics.Counter
11 | requestLatency metrics.Histogram
12 | countResult metrics.Histogram
13 | next StringService
14 | }
15 |
16 | func (mw instrumentingMiddleware) Uppercase(s string)(output string, err error) {
17 | defer func(begin time.Time) {
18 | lvs :=[]string{"method","uppercase","error",fmt.Sprint(err!=nil)}
19 | mw.requestCount.With(lvs...).Add(1)
20 | mw.requestLatency.With(lvs...).Observe(time.Since(begin).Seconds())
21 | }(time.Now())
22 | output, err = mw.next.Uppercase(s)
23 | return
24 | }
25 |
26 | func (mw instrumentingMiddleware) Count(s string)(n int) {
27 | defer func(begin time.Time) {
28 | lvs :=[]string{"method","count","error","false"}
29 | mw.requestCount.With(lvs...).Add(1)
30 | mw.requestLatency.With(lvs...).Observe(time.Since(begin).Seconds())
31 | }(time.Now())
32 | n = mw.next.Count(s)
33 | return
34 | }
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/details/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM ruby:2.7.1-slim
16 |
17 | COPY details.rb /opt/microservices/
18 |
19 | ARG service_version
20 | ENV SERVICE_VERSION ${service_version:-v1}
21 | ARG enable_external_book_service
22 | ENV ENABLE_EXTERNAL_BOOK_SERVICE ${enable_external_book_service:-false}
23 |
24 | EXPOSE 9080
25 | WORKDIR /opt/microservices
26 |
27 | CMD ["ruby", "details.rb", "9080"]
28 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/reviews/reviews-application/src/main/webapp/WEB-INF/ibm-web-ext.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/istio/samples/https/nginx-app.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | name: my-nginx
5 | labels:
6 | app: nginx
7 | service: nginx
8 | spec:
9 | type: NodePort
10 | ports:
11 | - port: 443
12 | name: https
13 | selector:
14 | app: nginx
15 | ---
16 | apiVersion: v1
17 | kind: ReplicationController
18 | metadata:
19 | name: my-nginx
20 | spec:
21 | replicas: 1
22 | template:
23 | metadata:
24 | labels:
25 | app: nginx
26 | spec:
27 | volumes:
28 | - name: secret-volume
29 | secret:
30 | secretName: nginxsecret
31 | - name: configmap-volume
32 | configMap:
33 | name: nginxconfigmap
34 | containers:
35 | - name: nginxhttps
36 | image: ymqytw/nginxhttps:1.5
37 | command: ["/home/auto-reload-nginx.sh"]
38 | ports:
39 | - containerPort: 443
40 | volumeMounts:
41 | - mountPath: /etc/nginx/ssl
42 | name: secret-volume
43 | - mountPath: /etc/nginx/conf.d
44 | name: configmap-volume
45 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/internal/service/greeter.go:
--------------------------------------------------------------------------------
1 | package service
2 |
3 | import (
4 | "context"
5 |
6 | v1 "helloworld/api/helloworld/v1"
7 | "helloworld/internal/biz"
8 | "github.com/go-kratos/kratos/v2/errors"
9 | "github.com/go-kratos/kratos/v2/log"
10 | )
11 |
12 | // GreeterService is a greeter service.
13 | type GreeterService struct {
14 | v1.UnimplementedGreeterServer
15 |
16 | uc *biz.GreeterUsecase
17 | log *log.Helper
18 | }
19 |
20 | // NewGreeterService new a greeter service.
21 | func NewGreeterService(uc *biz.GreeterUsecase, logger log.Logger) *GreeterService {
22 | return &GreeterService{uc: uc, log: log.NewHelper(logger)}
23 | }
24 |
25 | // SayHello implements helloworld.GreeterServer
26 | func (s *GreeterService) SayHello(ctx context.Context, in *v1.HelloRequest) (*v1.HelloReply, error) {
27 | s.log.Infof("SayHello Received: %v", in.GetName())
28 | if in.GetName() == "error" {
29 | return nil, errors.NotFound(v1.ErrorReason_USER_NOT_FOUND.String(), in.GetName())
30 | }
31 | return &v1.HelloReply{Message: "Hello " + in.GetName()}, nil
32 | }
33 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/virtual-service-all-v1.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: VirtualService
3 | metadata:
4 | name: productpage
5 | spec:
6 | hosts:
7 | - productpage
8 | http:
9 | - route:
10 | - destination:
11 | host: productpage
12 | subset: v1
13 | ---
14 | apiVersion: networking.istio.io/v1alpha3
15 | kind: VirtualService
16 | metadata:
17 | name: reviews
18 | spec:
19 | hosts:
20 | - reviews
21 | http:
22 | - route:
23 | - destination:
24 | host: reviews
25 | subset: v1
26 | ---
27 | apiVersion: networking.istio.io/v1alpha3
28 | kind: VirtualService
29 | metadata:
30 | name: ratings
31 | spec:
32 | hosts:
33 | - ratings
34 | http:
35 | - route:
36 | - destination:
37 | host: ratings
38 | subset: v1
39 | ---
40 | apiVersion: networking.istio.io/v1alpha3
41 | kind: VirtualService
42 | metadata:
43 | name: details
44 | spec:
45 | hosts:
46 | - details
47 | http:
48 | - route:
49 | - destination:
50 | host: details
51 | subset: v1
52 | ---
53 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/api/helloworld/v1/error_reason.swagger.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "api/helloworld/v1/error_reason.proto",
5 | "version": "version not set"
6 | },
7 | "consumes": [
8 | "application/json"
9 | ],
10 | "produces": [
11 | "application/json"
12 | ],
13 | "paths": {},
14 | "definitions": {
15 | "protobufAny": {
16 | "type": "object",
17 | "properties": {
18 | "typeUrl": {
19 | "type": "string"
20 | },
21 | "value": {
22 | "type": "string",
23 | "format": "byte"
24 | }
25 | }
26 | },
27 | "rpcStatus": {
28 | "type": "object",
29 | "properties": {
30 | "code": {
31 | "type": "integer",
32 | "format": "int32"
33 | },
34 | "message": {
35 | "type": "string"
36 | },
37 | "details": {
38 | "type": "array",
39 | "items": {
40 | "$ref": "#/definitions/protobufAny"
41 | }
42 | }
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/gokit/shipping/handling/endpoint.go:
--------------------------------------------------------------------------------
1 | package handling
2 |
3 | import (
4 | "context"
5 | "time"
6 |
7 | "github.com/go-kit/kit/endpoint"
8 |
9 | "github.com/feixiao/learning/gokit/shipping/cargo"
10 | "github.com/feixiao/learning/gokit/shipping/location"
11 | "github.com/feixiao/learning/gokit/shipping/voyage"
12 | )
13 |
14 | type registerIncidentRequest struct {
15 | ID cargo.TrackingID
16 | Location location.UNLocode
17 | Voyage voyage.Number
18 | EventType cargo.HandlingEventType
19 | CompletionTime time.Time
20 | }
21 |
22 | type registerIncidentResponse struct {
23 | Err error `json:"error,omitempty"`
24 | }
25 |
26 | func (r registerIncidentResponse) error() error { return r.Err }
27 |
28 | func makeRegisterIncidentEndpoint(hs Service) endpoint.Endpoint {
29 | return func(ctx context.Context, request interface{}) (interface{}, error) {
30 | req := request.(registerIncidentRequest)
31 | err := hs.RegisterHandlingEvent(req.CompletionTime, req.ID, req.Voyage, req.Location, req.EventType)
32 | return registerIncidentResponse{Err: err}, nil
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/api/helloworld/helloworld.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package api.helloworld;
4 |
5 | option go_package = "helloworld/api/helloworld;helloworld";
6 | option java_multiple_files = true;
7 | option java_package = "api.helloworld";
8 |
9 | service Helloworld {
10 | rpc CreateHelloworld (CreateHelloworldRequest) returns (CreateHelloworldReply);
11 | rpc UpdateHelloworld (UpdateHelloworldRequest) returns (UpdateHelloworldReply);
12 | rpc DeleteHelloworld (DeleteHelloworldRequest) returns (DeleteHelloworldReply);
13 | rpc GetHelloworld (GetHelloworldRequest) returns (GetHelloworldReply);
14 | rpc ListHelloworld (ListHelloworldRequest) returns (ListHelloworldReply);
15 | }
16 |
17 | message CreateHelloworldRequest {}
18 | message CreateHelloworldReply {}
19 |
20 | message UpdateHelloworldRequest {}
21 | message UpdateHelloworldReply {}
22 |
23 | message DeleteHelloworldRequest {}
24 | message DeleteHelloworldReply {}
25 |
26 | message GetHelloworldRequest {}
27 | message GetHelloworldReply {}
28 |
29 | message ListHelloworldRequest {}
30 | message ListHelloworldReply {}
--------------------------------------------------------------------------------
/grafana/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## Grafana使用记录
2 |
3 |
4 | #### Auth Proxy
5 | + 运行
6 | ```shell
7 | # 准备配置grafana.ini,运行grafana
8 | docker run --rm -i -p 3000:3000 -v $(pwd)/auth/grafana.ini:/etc/grafana/grafana.ini --name grafana grafana/grafana:7.2.0-ubuntu
9 | ```
10 | + 获取用户信息
11 | ```shell
12 | curl -H "X-WEBAUTH-USER: admin" http://localhost:3000/api/users
13 | [{
14 | "id": 1,
15 | "name": "",
16 | "login": "admin",
17 | "email": "admin@localhost",
18 | "avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56",
19 | "isAdmin": true,
20 | "isDisabled": false,
21 | "lastSeenAt": "2020-10-14T02:07:04Z",
22 | "lastSeenAtAge": "\u003c 1m",
23 | "authLabels": ["OAuth"]
24 | }]
25 | ```
26 | + 运行httpd
27 | ```shell
28 | # 准备配置httpd.conf
29 | # 添加用户名 frank 密码 1
30 | sudo apt-get install apache2-utils
31 | htpasswd -bc htpasswd frank 1
32 | # link到grafana,所以配置文件里面的hostname grafana可以被解析
33 | docker run --rm -i -p 80:80 --link grafana:grafana -v $(pwd)/auth/httpd.conf:/usr/local/apache2/conf/httpd.conf -v $(pwd)/auth/htpasswd:/tmp/htpasswd httpd:2.4
34 |
35 | # 浏览器访问
36 | http://{ip}
37 |
38 | # 输入密码, 我们既可以访问grafana
39 | ```
--------------------------------------------------------------------------------
/kubevela/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## 本地搭建 kubeVela 环境
2 |
3 | [https://kubevela.io/](https://kubevela.io/)
4 | ### Minikube
5 |
6 | #### 安装
7 |
8 | ```shell
9 | curl -Lo minikube http://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.16.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
10 | ```
11 |
12 | #### 启动
13 |
14 | ```shell
15 | # --insecure-registry="172.18.0.57:5000"
16 | minikube start --vm-driver=docker --registry-mirror=https://registry.docker-cn.com --image-mirror-country='cn' --image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers' --kubernetes-version v1.18.0 --cpus=4 --memory=8192
17 | ```
18 |
19 | #### kubectl
20 |
21 | ```shell
22 | curl -Lo kubectl http://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl && chmod +x ./kubectl && sudo mv ./kubectl /usr/local/bin/kubectl
23 |
24 | # 验证
25 | kubectl cluster-info
26 | ```
27 |
28 | #### ingress
29 |
30 | ```shell
31 | minikube addons enable ingress
32 | ```
33 |
34 | #### KubeVela
35 |
36 | ```shell
37 | curl -fsSl https://kubevela.io/install.sh | bash
38 | ```
39 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/platform/kube/bookinfo-certificate.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | apiVersion: certmanager.k8s.io/v1alpha1
3 | kind: ClusterIssuer
4 | metadata:
5 | name: letsencrypt-staging
6 | namespace: istio-system
7 | spec:
8 | acme:
9 | # The ACME server URL
10 | server: https://acme-staging-v02.api.letsencrypt.org/directory
11 | # Email address used for ACME registration
12 | email: stage@istio.io
13 | # Name of a secret used to store the ACME account private key
14 | privateKeySecretRef:
15 | name: letsencrypt-staging
16 | # Enable the HTTP-01 challenge provider
17 | http01: {}
18 | ---
19 | apiVersion: certmanager.k8s.io/v1alpha1
20 | kind: Certificate
21 | metadata:
22 | name: istio-ingressgateway-certs
23 | namespace: istio-system
24 | spec:
25 | secretName: istio-ingressgateway-certs
26 | issuerRef:
27 | name: letsencrypt-staging
28 | kind: ClusterIssuer
29 | commonName: bookinfo.example.com
30 | dnsNames:
31 | - bookinfo.example.com
32 | acme:
33 | config:
34 | - http01:
35 | ingressClass: none
36 | domains:
37 | - bookinfo.example.com
38 |
--------------------------------------------------------------------------------
/istio/samples/security/psp/sidecar-psp.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: policy/v1beta1
2 | kind: PodSecurityPolicy
3 | metadata:
4 | name: istio-sidecar
5 | spec:
6 | # Allow the istio sidecar injector to work
7 | allowedCapabilities:
8 | - NET_ADMIN
9 | - NET_RAW
10 | seLinux:
11 | rule: RunAsAny
12 | supplementalGroups:
13 | rule: RunAsAny
14 | runAsUser:
15 | rule: RunAsAny
16 | fsGroup:
17 | rule: RunAsAny
18 | volumes:
19 | - '*'
20 | ---
21 | kind: ClusterRole
22 | apiVersion: rbac.authorization.k8s.io/v1
23 | metadata:
24 | name: istio-sidecar-psp
25 | rules:
26 | - apiGroups:
27 | - extensions
28 | resources:
29 | - podsecuritypolicies
30 | resourceNames:
31 | - istio-sidecar
32 | verbs:
33 | - use
34 | ---
35 | apiVersion: rbac.authorization.k8s.io/v1
36 | kind: ClusterRoleBinding
37 | metadata:
38 | name: istio-sidecar-psp
39 | roleRef:
40 | apiGroup: rbac.authorization.k8s.io
41 | kind: ClusterRole
42 | name: istio-sidecar-psp
43 | subjects:
44 | - apiGroup: rbac.authorization.k8s.io
45 | kind: Group
46 | name: system:serviceaccounts
47 |
--------------------------------------------------------------------------------
/elasticsearch/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## elasticsearch
2 |
3 | ### 安装和运行
4 |
5 | ```shell
6 | tar -zxvf elasticsearch-6.1.1.tar.gz
7 | cd elasticsearch-6.1.1/bin
8 | ./elasticsearch -d # 不要使用root用户启动
9 |
10 | # 查看服务是否启动成功
11 | netstat -apn | grep 9200
12 |
13 | ```
14 |
15 | + [ES启用外部IP访问的启动异常](http://kael-aiur.com/elk/ES%E9%85%8D%E7%BD%AE%E7%BB%99%E5%A4%96%E9%83%A8%E6%9C%BA%E5%99%A8%E9%80%9A%E8%BF%87ip%E8%AE%BF%E9%97%AE.html)
16 |
17 | ### 加载测试数据
18 |
19 | + [Loading Sample Data](https://www.elastic.co/guide/en/kibana/current/tutorial-load-dataset.html)
20 |
21 | ### 安装**elasticsearch-sql**
22 |
23 | ```sh
24 | ./bin/elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/6.1.1.0/elasticsearch-sql-6.1.1.0.zip
25 | ```
26 |
27 | 访问
28 |
29 | ```
30 | http://172.17.228.97:9200/_plugin/sql/
31 | ```
32 |
33 | ### elasticsearch-head
34 |
35 | ```
36 | sudo apt-get install nodejs-legacy
37 | npm install
38 | git clone git://github.com/mobz/elasticsearch-head.git
39 | cd elasticsearch-head
40 | npm install
41 | npm run start
42 | ```
43 |
44 | 访问
45 |
46 | ```
47 | http://172.17.228.97:9100
48 | ```
49 |
50 |
--------------------------------------------------------------------------------
/gokit/shipping/voyage/voyage.go:
--------------------------------------------------------------------------------
1 | package voyage
2 |
3 | import (
4 | "errors"
5 | "time"
6 |
7 | "github.com/feixiao/learning/gokit/shipping/location"
8 | )
9 |
10 | // Number 唯一标识一个特定的航行
11 | type Number string
12 |
13 | // Voyage 表示一系列的货物移动
14 | type Voyage struct {
15 | Number Number
16 | Schedule Schedule
17 | }
18 |
19 | // New creates a voyage with a voyage number and a provided schedule.
20 | func New(n Number, s Schedule) *Voyage {
21 | return &Voyage{Number: n, Schedule: s}
22 | }
23 |
24 | // Schedule 表示 航线规划
25 | type Schedule struct {
26 | CarrierMovements []CarrierMovement // 由一系列满足Specification(规格) 的CarrierMovement(运输动作) 来完成运送目标。
27 | }
28 |
29 | // CarrierMovement 表示船只从一个地方航行到另一个地方的。
30 | type CarrierMovement struct {
31 | DepartureLocation location.UNLocode // 离开位置
32 | ArrivalLocation location.UNLocode // 到达位置
33 | DepartureTime time.Time // 离开时间
34 | ArrivalTime time.Time // 到达时间
35 | }
36 |
37 | // ErrUnknown 表示找不到对于的航线
38 | var ErrUnknown = errors.New("unknown voyage")
39 |
40 | // Repository 提供访问航线接口。
41 | type Repository interface {
42 | Find(Number) (*Voyage, error)
43 | }
44 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/egress-rule-google-apis.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: ServiceEntry
3 | metadata:
4 | name: googleapis
5 | spec:
6 | hosts:
7 | - www.googleapis.com
8 | ports:
9 | - number: 80
10 | name: http
11 | protocol: HTTP
12 | - number: 443
13 | name: https
14 | protocol: HTTPS
15 | resolution: DNS
16 | ---
17 | apiVersion: networking.istio.io/v1alpha3
18 | kind: VirtualService
19 | metadata:
20 | name: rewrite-port-for-googleapis
21 | spec:
22 | hosts:
23 | - www.googleapis.com
24 | http:
25 | - match:
26 | - port: 80
27 | route:
28 | - destination:
29 | host: www.googleapis.com
30 | port:
31 | number: 443
32 | ---
33 | apiVersion: networking.istio.io/v1alpha3
34 | kind: DestinationRule
35 | metadata:
36 | name: originate-tls-for-googleapis
37 | spec:
38 | host: www.googleapis.com
39 | trafficPolicy:
40 | loadBalancer:
41 | simple: ROUND_ROBIN
42 | portLevelSettings:
43 | - port:
44 | number: 443
45 | tls:
46 | mode: SIMPLE # initiates HTTPS when accessing www.googleapis.com
47 |
--------------------------------------------------------------------------------
/istio/samples/certs/README.md:
--------------------------------------------------------------------------------
1 | # Istio plugin CA sample certificates
2 |
3 | This directory contains sample pre-generated certificate and keys to demonstrate how an operator could configure Citadel with an existing root certificate, signing certificates and keys. In such
4 | a deployment, Citadel acts as an intermediate certificate authority (CA), under the given root CA.
5 | Instructions are available [here](https://istio.io/docs/tasks/security/cert-management/plugin-ca-cert/).
6 |
7 | The included sample files are:
8 |
9 | - `root-cert.pem`: root CA certificate.
10 | - `ca-[cert|key].pem`: Citadel intermediate certificate and corresponding private key.
11 | - `cert-chain.pem`: certificate trust chain.
12 | - `workload-foo-[cert|key].pem`: workload certificate and key for URI SAN `spiffe://trust-domain-foo/ns/foo/sa/foo` signed by `ca-cert.key`.
13 | - `workload-bar-[cert|key].pem`: workload certificate and key for URI SAN `spiffe://trust-domain-bar/ns/bar/sa/bar` signed by `ca-cert.key`.
14 |
15 | The workload cert and key are generated by:
16 |
17 | ```shell script
18 | ./generate-workload.sh foo
19 | ./generate-workload.sh bar
20 | ```
21 |
--------------------------------------------------------------------------------
/istio/samples/rawvm/k8cli.yaml.in:
--------------------------------------------------------------------------------
1 | # Client inside the cluster, not istio injected
2 | apiVersion: apps/v1
3 | kind: Deployment
4 | metadata:
5 | name: raw-cli-deployement
6 | spec:
7 | replicas: 1
8 | selector:
9 | matchLabels:
10 | app: fortio
11 | template:
12 | metadata:
13 | labels:
14 | app: fortio
15 | spec:
16 | containers:
17 | - name: fortio
18 | # That image runs the servers (so it will run forever) but has the
19 | # fortio client
20 | image: FORTIO_IMAGE
21 | imagePullPolicy: Always
22 | ---
23 | # Extra debug / shell
24 | apiVersion: v1
25 | kind: Pod
26 | metadata:
27 | name: shell
28 | spec:
29 | containers:
30 | - image: busybox
31 | command:
32 | - sleep
33 | - "3600"
34 | imagePullPolicy: IfNotPresent
35 | name: shell
36 | ---
37 | # Mysql (client) debug
38 | apiVersion: v1
39 | kind: Pod
40 | metadata:
41 | name: mysqlclient-noistio
42 | spec:
43 | containers:
44 | - image: mysql
45 | command:
46 | - sleep
47 | - "360000"
48 | imagePullPolicy: IfNotPresent
49 | name: mysqlclient-noistio
50 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/ratings/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM node:12.18.1-slim
16 |
17 | COPY package.json /opt/microservices/
18 | COPY ratings.js /opt/microservices/
19 | WORKDIR /opt/microservices
20 | RUN npm install
21 |
22 | #hadolint ignore=DL3008
23 | RUN apt-get update \
24 | && apt-get install curl --no-install-recommends -y \
25 | && rm -rf /var/lib/apt/lists/*
26 |
27 | ARG service_version
28 | ENV SERVICE_VERSION ${service_version:-v1}
29 |
30 | EXPOSE 9080
31 | CMD ["node", "/opt/microservices/ratings.js", "9080"]
32 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 go-kratos
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/platform/kube/bookinfo-ratings-discovery.yaml:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | ##################################################################################################
16 | # Ratings service
17 | ##################################################################################################
18 | apiVersion: v1
19 | kind: Service
20 | metadata:
21 | name: ratings
22 | labels:
23 | app: ratings
24 | service: ratings
25 | spec:
26 | ports:
27 | - port: 9080
28 | name: http
29 | selector:
30 | app: ratings
31 | ---
32 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/reviews/reviews-wlpcfg/src/test/java/it/TestApplication.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 Istio Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *******************************************************************************/
16 | package it;
17 |
18 | import org.junit.Test;
19 |
20 | public class TestApplication extends EndpointTest {
21 |
22 | @Test
23 | public void testDeployment() {
24 | testEndpoint("/index.html", "Welcome to your Liberty Application
");
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/istio/samples/external/pypi.yaml:
--------------------------------------------------------------------------------
1 | # This ServiceEntry exposes the hosts needed for Python `pip`.
2 | # After applying this file, Istio-enabled pods will be able to execute
3 | # `pip search istio`.
4 |
5 | # HTTP and TLS, the host must be specified
6 | # See https://istio.io/docs/tasks/traffic-management/egress/
7 |
8 | apiVersion: networking.istio.io/v1alpha3
9 | kind: ServiceEntry
10 | metadata:
11 | name: python-https
12 | spec:
13 | hosts:
14 | - pypi.python.org
15 | ports:
16 | - number: 443
17 | name: https
18 | protocol: HTTPS
19 | ---
20 | # pypi.python.org may 301 redirect to pypi.org, so we need this too.
21 | apiVersion: networking.istio.io/v1alpha3
22 | kind: ServiceEntry
23 | metadata:
24 | name: pypi-https
25 | spec:
26 | hosts:
27 | - pypi.org
28 | ports:
29 | - number: 443
30 | name: https
31 | protocol: HTTPS
32 | ---
33 | # pip install may fetch files from files.pythonhosted.org
34 | apiVersion: networking.istio.io/v1alpha3
35 | kind: ServiceEntry
36 | metadata:
37 | name: pythonhosted-https
38 | spec:
39 | hosts:
40 | - files.pythonhosted.org
41 | ports:
42 | - number: 443
43 | name: https
44 | protocol: HTTPS
45 |
--------------------------------------------------------------------------------
/istio/samples/rawvm/Makefile:
--------------------------------------------------------------------------------
1 |
2 | FORTIO_IMAGE:='fortio/fortio:latest'
3 | VERBOSITY:=2
4 | NAMESPACE:=fortio
5 |
6 | YAMLS:=k8services-istio.yaml k8services.yaml k8cli.yaml
7 | # Was needed when images were missing (#553)
8 | #PATCH_HUB:='| sed -e "s!docker.io/istio!gcr.io/istio-io!g"'
9 |
10 | deploy: k8services-istio client
11 |
12 | client: k8cli.yaml
13 | kubectl apply -n $(NAMESPACE) -f $<
14 |
15 | k8services-istio: k8services-istio.yaml
16 | kubectl apply -n $(NAMESPACE) -f $<
17 |
18 | k8services-istio.yaml: k8services.yaml
19 | istioctl kube-inject -n $(NAMESPACE) --hub $(PILOT_HUB) --tag $(PILOT_TAG) --verbosity $(VERBOSITY) -f $< $(PATCH_HUB) > $@
20 |
21 | k8services: k8services.yaml
22 | kubectl apply -n $(NAMESPACE) -f $<
23 |
24 | %.yaml: %.yaml.in
25 | sed -e "s!FORTIO_IMAGE!$(FORTIO_IMAGE)!g" < $< > $@
26 |
27 | dump-images:
28 | kubectl get pods --all-namespaces -o jsonpath="{..image}" | \
29 | tr -s '[[:space:]]' '\n' | sort | uniq -c
30 |
31 | clean:
32 | -kubectl delete -n $(NAMESPACE) -f k8services-istio.yaml
33 | -kubectl delete -n $(NAMESPACE) -f k8services.yaml
34 | $(RM) $(YAMLS)
35 |
36 | .PHONY: clean k8services k8services-istio dump-images client deploy
37 |
--------------------------------------------------------------------------------
/opentracing/ReadMe.md:
--------------------------------------------------------------------------------
1 | # **OpenTracing**
2 |
3 | ### OpenTracing
4 |
5 | OpenTracing通过提供平台无关、厂商无关的API,使得开发人员能够方便的添加(或更换)追踪系统的实现。
6 |
7 | + [appdash](https://github.com/sourcegraph/appdash)
8 | + [zipkin](https://zipkin.io/)
9 | + [lightstep](https://lightstep.com/)
10 |
11 | #### OpenTracing快速入门
12 |
13 | + [《opentracing文档中文版》](https://www.gitbook.com/book/wu-sheng/opentracing-io/details)
14 |
15 | ### Go工具包
16 |
17 | + [go-kit/kit/tracing ](https://github.com/go-kit/kit/tree/master/tracing) `package tracing` provides [Dapper](http://research.google.com/pubs/pub36356.html)-style request tracing to services.
18 | + [《 Tracing HTTP request latency in Go with OpenTracing》](https://medium.com/opentracing/tracing-http-request-latency-in-go-with-opentracing-7cc1282a100a) 客户端使用[**net/http/httptrace**](https://golang.org/pkg/net/http/httptrace/) 集成opentracing。
19 | + [opentracing-contrib/go-stdlib](https://github.com/opentracing-contrib/go-stdlib) 服务端使用opentracing中间件。
20 |
21 | ### 参考资料
22 |
23 | + [[Zipkin快速开始](https://segmentfault.com/a/1190000012342007)](https://segmentfault.com/a/1190000012342007)
24 | + [《opentracing文档中文版》](https://www.gitbook.com/book/wu-sheng/opentracing-io/details)
25 |
26 |
27 |
--------------------------------------------------------------------------------
/go-zero/greet/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## go-zero 框架快速入门
2 |
3 | #### 目录结构
4 |
5 | ```shell
6 | .
7 | ├── etc
8 | │ └── greet-api.yaml # 配置文件
9 | ├── greet.api # api描述定义问题,如何定义查看文档https://github.com/tal-tech/zero-doc/blob/main/doc/goctl.md
10 | ├── greet.go # main函数
11 | └── internal
12 | ├── config
13 | │ └── config.go # 配置定义
14 | ├── handler
15 | │ ├── greethandler.go # 路由实现,具体的greet操作由logic包实现
16 | │ └── routes.go # 路由定义
17 | ├── logic
18 | │ └── greetlogic.go # 具体的greet内容实现
19 | ├── svc
20 | │ └── servicecontext.go # 定义ServiceContext
21 | └── types
22 | └── types.go # 定义请求体和返回结构
23 | ```
24 |
25 | #### 修改接口
26 |
27 | ```shell script
28 | # 修改接口以后,这边是greet.api文档
29 | # 使用命令行生成代码(后面尝试使用Goland插件和VSCode插件)
30 | # 受影响的目录有types、logic和handler
31 | goctl api go -api greet.api -dir ./
32 |
33 | ```
34 |
35 | #### 客户端代码生成
36 |
37 | ```shell script
38 | # 1.0.27版本支持go、java、ts(typescript)、dart、kt(kotlin)
39 | goctl api java -api greet.api -dir ./client/java
40 | goctl api ts -api greet.api -dir ./client/ts
41 |
42 | # ios 通过 https://github.com/google/j2objc 从java翻译到object-c
43 | ```
44 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/reviews/reviews-wlpcfg/src/test/java/it/rest/LibertyRestEndpointTest.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 Istio Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *******************************************************************************/
16 | package it.rest;
17 |
18 | import it.EndpointTest;
19 |
20 | import org.junit.Test;
21 |
22 | public class LibertyRestEndpointTest extends EndpointTest {
23 |
24 | @Test
25 | public void testDeployment() {
26 | testEndpoint("/rest", "Hello from the REST endpoint!");
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/gokit/shipping/handling/logging.go:
--------------------------------------------------------------------------------
1 | package handling
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/go-kit/kit/log"
7 |
8 | "github.com/feixiao/learning/gokit/shipping/cargo"
9 | "github.com/feixiao/learning/gokit/shipping/location"
10 | "github.com/feixiao/learning/gokit/shipping/voyage"
11 | )
12 |
13 | type loggingService struct {
14 | logger log.Logger
15 | Service
16 | }
17 |
18 | // NewLoggingService returns a new instance of a logging Service.
19 | func NewLoggingService(logger log.Logger, s Service) Service {
20 | return &loggingService{logger, s}
21 | }
22 |
23 | func (s *loggingService) RegisterHandlingEvent(completed time.Time, id cargo.TrackingID, voyageNumber voyage.Number,
24 | unLocode location.UNLocode, eventType cargo.HandlingEventType) (err error) {
25 | defer func(begin time.Time) {
26 | s.logger.Log(
27 | "method", "register_incident",
28 | "tracking_id", id,
29 | "location", unLocode,
30 | "voyage", voyageNumber,
31 | "event_type", eventType,
32 | "completion_time", completed,
33 | "took", time.Since(begin),
34 | "err", err,
35 | )
36 | }(time.Now())
37 | return s.Service.RegisterHandlingEvent(completed, id, voyageNumber, unLocode, eventType)
38 | }
39 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/platform/kube/productpage-nodeport.yaml:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | ##################################################################################################
16 | # Productpage services
17 | ##################################################################################################
18 | apiVersion: v1
19 | kind: Service
20 | metadata:
21 | name: productpage
22 | labels:
23 | app: productpage
24 | service: productpage
25 | spec:
26 | type: NodePort
27 | ports:
28 | - port: 9080
29 | name: http
30 | selector:
31 | app: productpage
32 | ---
33 |
--------------------------------------------------------------------------------
/istio/samples/tcp-echo/tcp-echo-20-v2.yaml:
--------------------------------------------------------------------------------
1 | # Copyright 2018 Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | apiVersion: networking.istio.io/v1alpha3
16 | kind: VirtualService
17 | metadata:
18 | name: tcp-echo
19 | spec:
20 | hosts:
21 | - "*"
22 | gateways:
23 | - tcp-echo-gateway
24 | tcp:
25 | - match:
26 | - port: 31400
27 | route:
28 | - destination:
29 | host: tcp-echo
30 | port:
31 | number: 9000
32 | subset: v1
33 | weight: 80
34 | - destination:
35 | host: tcp-echo
36 | port:
37 | number: 9000
38 | subset: v2
39 | weight: 20
40 |
--------------------------------------------------------------------------------
/gokit/profilesvc/cmd/profilesvc/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "net/http"
7 | "os"
8 | "os/signal"
9 | "syscall"
10 |
11 | "github.com/feixiao/learning/gokit/profilesvc"
12 | "github.com/go-kit/kit/log"
13 | )
14 |
15 | func main() {
16 | var (
17 | httpAddr = flag.String("http.addr", ":8080", "HTTP listen address")
18 | )
19 | flag.Parse()
20 |
21 | var logger log.Logger
22 | {
23 | logger = log.NewLogfmtLogger(os.Stderr)
24 | logger = log.With(logger, "ts", log.DefaultTimestampUTC)
25 | logger = log.With(logger, "caller", log.DefaultCaller)
26 | }
27 |
28 | var s profilesvc.Service
29 | {
30 | s = profilesvc.NewInmemService()
31 | //s = profilesvc.LoggingMiddleware(logger)(s)
32 | }
33 |
34 | var h http.Handler
35 | {
36 | h = profilesvc.MakeHTTPHandler(s, log.With(logger, "component", "HTTP"))
37 | }
38 |
39 | errs := make(chan error)
40 | go func() {
41 | c := make(chan os.Signal)
42 | signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
43 | errs <- fmt.Errorf("%s", <-c)
44 | }()
45 |
46 | go func() {
47 | logger.Log("transport", "HTTP", "addr", *httpAddr)
48 | errs <- http.ListenAndServe(*httpAddr, h)
49 | }()
50 |
51 | logger.Log("exit", <-errs)
52 | }
--------------------------------------------------------------------------------
/kratosV2/helloworld/cmd/helloworld/wire_gen.go:
--------------------------------------------------------------------------------
1 | // Code generated by Wire. DO NOT EDIT.
2 |
3 | //go:generate go run github.com/google/wire/cmd/wire
4 | //+build !wireinject
5 |
6 | package main
7 |
8 | import (
9 | "helloworld/internal/biz"
10 | "helloworld/internal/conf"
11 | "helloworld/internal/data"
12 | "helloworld/internal/server"
13 | "helloworld/internal/service"
14 | "github.com/go-kratos/kratos/v2"
15 | "github.com/go-kratos/kratos/v2/log"
16 | )
17 |
18 | // Injectors from wire.go:
19 |
20 | // initApp init kratos application.
21 | func initApp(confServer *conf.Server, confData *conf.Data, logger log.Logger) (*kratos.App, func(), error) {
22 | dataData, cleanup, err := data.NewData(confData, logger)
23 | if err != nil {
24 | return nil, nil, err
25 | }
26 | greeterRepo := data.NewGreeterRepo(dataData, logger)
27 | greeterUsecase := biz.NewGreeterUsecase(greeterRepo, logger)
28 | greeterService := service.NewGreeterService(greeterUsecase, logger)
29 | httpServer := server.NewHTTPServer(confServer, greeterService, logger)
30 | grpcServer := server.NewGRPCServer(confServer, greeterService, logger)
31 | app := newApp(logger, httpServer, grpcServer)
32 | return app, func() {
33 | cleanup()
34 | }, nil
35 | }
36 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/internal/server/grpc.go:
--------------------------------------------------------------------------------
1 | package server
2 |
3 | import (
4 | v1 "helloworld/api/helloworld/v1"
5 | "helloworld/internal/conf"
6 | "helloworld/internal/service"
7 | "github.com/go-kratos/kratos/v2/log"
8 | "github.com/go-kratos/kratos/v2/middleware"
9 | "github.com/go-kratos/kratos/v2/middleware/logging"
10 | "github.com/go-kratos/kratos/v2/middleware/recovery"
11 | "github.com/go-kratos/kratos/v2/middleware/tracing"
12 | "github.com/go-kratos/kratos/v2/transport/grpc"
13 | )
14 |
15 | // NewGRPCServer new a gRPC server.
16 | func NewGRPCServer(c *conf.Server, greeter *service.GreeterService, logger log.Logger) *grpc.Server {
17 | var opts = []grpc.ServerOption{
18 | grpc.Middleware(
19 | middleware.Chain(
20 | recovery.Recovery(),
21 | tracing.Server(),
22 | logging.Server(logger),
23 | ),
24 | ),
25 | }
26 | if c.Grpc.Network != "" {
27 | opts = append(opts, grpc.Network(c.Grpc.Network))
28 | }
29 | if c.Grpc.Addr != "" {
30 | opts = append(opts, grpc.Address(c.Grpc.Addr))
31 | }
32 | if c.Grpc.Timeout != nil {
33 | opts = append(opts, grpc.Timeout(c.Grpc.Timeout.AsDuration()))
34 | }
35 | srv := grpc.NewServer(opts...)
36 | v1.RegisterGreeterServer(srv, greeter)
37 | return srv
38 | }
39 |
--------------------------------------------------------------------------------
/istio/samples/httpbin/sample-client/fortio-deploy.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | name: fortio
5 | labels:
6 | app: fortio
7 | service: fortio
8 | spec:
9 | ports:
10 | - port: 8080
11 | name: http
12 | selector:
13 | app: fortio
14 | ---
15 | apiVersion: apps/v1
16 | kind: Deployment
17 | metadata:
18 | name: fortio-deploy
19 | spec:
20 | replicas: 1
21 | selector:
22 | matchLabels:
23 | app: fortio
24 | template:
25 | metadata:
26 | annotations:
27 | # This annotation causes Envoy to serve cluster.outbound statistics via 15000/stats
28 | # in addition to the stats normally served by Istio. The Circuit Breaking example task
29 | # gives an example of inspecting Envoy stats.
30 | sidecar.istio.io/statsInclusionPrefixes: cluster.outbound,cluster_manager,listener_manager,http_mixer_filter,tcp_mixer_filter,server,cluster.xds-grpc
31 | labels:
32 | app: fortio
33 | spec:
34 | containers:
35 | - name: fortio
36 | image: fortio/fortio:latest_release
37 | imagePullPolicy: Always
38 | ports:
39 | - containerPort: 8080
40 | name: http-fortio
41 | - containerPort: 8079
42 | name: grpc-ping
43 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/internal/service/helloworld.go:
--------------------------------------------------------------------------------
1 |
2 | package service
3 |
4 | import(
5 | "context"
6 |
7 | pb "helloworld/api/helloworld"
8 | )
9 |
10 | type HelloworldService struct {
11 | pb.UnimplementedHelloworldServer
12 | }
13 |
14 | func NewHelloworldService() *HelloworldService {
15 | return &HelloworldService{}
16 | }
17 |
18 | func (s *HelloworldService) CreateHelloworld(ctx context.Context, req *pb.CreateHelloworldRequest) (*pb.CreateHelloworldReply, error) {
19 | return &pb.CreateHelloworldReply{}, nil
20 | }
21 | func (s *HelloworldService) UpdateHelloworld(ctx context.Context, req *pb.UpdateHelloworldRequest) (*pb.UpdateHelloworldReply, error) {
22 | return &pb.UpdateHelloworldReply{}, nil
23 | }
24 | func (s *HelloworldService) DeleteHelloworld(ctx context.Context, req *pb.DeleteHelloworldRequest) (*pb.DeleteHelloworldReply, error) {
25 | return &pb.DeleteHelloworldReply{}, nil
26 | }
27 | func (s *HelloworldService) GetHelloworld(ctx context.Context, req *pb.GetHelloworldRequest) (*pb.GetHelloworldReply, error) {
28 | return &pb.GetHelloworldReply{}, nil
29 | }
30 | func (s *HelloworldService) ListHelloworld(ctx context.Context, req *pb.ListHelloworldRequest) (*pb.ListHelloworldReply, error) {
31 | return &pb.ListHelloworldReply{}, nil
32 | }
33 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/internal/server/http.go:
--------------------------------------------------------------------------------
1 | package server
2 |
3 | import (
4 | "github.com/go-kratos/kratos/v2/log"
5 | "github.com/go-kratos/kratos/v2/middleware"
6 | "github.com/go-kratos/kratos/v2/middleware/logging"
7 | "github.com/go-kratos/kratos/v2/middleware/recovery"
8 | "github.com/go-kratos/kratos/v2/middleware/tracing"
9 | "github.com/go-kratos/kratos/v2/transport/http"
10 | v1 "helloworld/api/helloworld/v1"
11 | "helloworld/internal/conf"
12 | "helloworld/internal/service"
13 | )
14 |
15 | // NewHTTPServer new a HTTP server.
16 | func NewHTTPServer(c *conf.Server, greeter *service.GreeterService, logger log.Logger) *http.Server {
17 | var opts = []http.ServerOption{}
18 | if c.Http.Network != "" {
19 | opts = append(opts, http.Network(c.Http.Network))
20 | }
21 | if c.Http.Addr != "" {
22 | opts = append(opts, http.Address(c.Http.Addr))
23 | }
24 | if c.Http.Timeout != nil {
25 | opts = append(opts, http.Timeout(c.Http.Timeout.AsDuration()))
26 | }
27 | srv := http.NewServer(opts...)
28 | m := http.Middleware(
29 | middleware.Chain(
30 | recovery.Recovery(),
31 | tracing.Server(),
32 | logging.Server(logger),
33 | ),
34 | )
35 | // 没有使用gin了,基于grpc转换了
36 | srv.HandlePrefix("/", v1.NewGreeterHandler(greeter, m))
37 | return srv
38 | }
39 |
--------------------------------------------------------------------------------
/googleapi/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## Google API快速入门
2 |
3 | ### 简介
4 | 使用Protocol Buffers定义RPC API, 这些API以gRPC的方式发布,同时可以通过gRPC-HTTP转换可以作为REST API使用。
5 |
6 | ### API设计规范
7 | + [《API-design-guide中文版》](https://github.com/feixiao/gitbook/tree/master/API-design-guide)
8 |
9 |
10 | ### 如何使用
11 | + [谷歌api的公共接口定义](https://github.com/googleapis/googleapis)
12 | ##### 运行例子
13 | + 获取代码
14 | ```shell
15 | git clone https://github.com/googleapis/googleapis.git
16 | ```
17 | + 安装Bazel
18 | ```
19 | # ubuntu 18.04
20 | sudo apt-get install openjdk-11-jdk
21 | sudo apt-get install curl
22 | curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
23 | echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" \
24 | | sudo tee /etc/apt/sources.list.d/bazel.list
25 |
26 | sudo apt-get update && sudo apt-get install bazel
27 | ```
28 | + 安装库()
29 | ```
30 | bazel build //google/example/library/v1/...
31 |
32 | # java
33 | bazel build //google/example/library/v1:google-cloud-library-v1-java
34 | ```
35 | + Go语言
36 | ```
37 | https://github.com/googleapis/go-genproto
38 |
39 | go get -u github.com/golang/protobuf/protoc-gen-go
40 |
41 | ```
42 | ### 参考资料
43 | + [官网](https://googleapis.github.io/)
44 |
--------------------------------------------------------------------------------
/gokit/shipping/handling/instrumenting.go:
--------------------------------------------------------------------------------
1 | package handling
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/go-kit/kit/metrics"
7 |
8 | "github.com/feixiao/learning/gokit/shipping/cargo"
9 | "github.com/feixiao/learning/gokit/shipping/location"
10 | "github.com/feixiao/learning/gokit/shipping/voyage"
11 | )
12 |
13 | type instrumentingService struct {
14 | requestCount metrics.Counter
15 | requestLatency metrics.Histogram
16 | Service
17 | }
18 |
19 | // NewInstrumentingService returns an instance of an instrumenting Service.
20 | func NewInstrumentingService(counter metrics.Counter, latency metrics.Histogram, s Service) Service {
21 | return &instrumentingService{
22 | requestCount: counter,
23 | requestLatency: latency,
24 | Service: s,
25 | }
26 | }
27 |
28 | func (s *instrumentingService) RegisterHandlingEvent(completed time.Time, id cargo.TrackingID, voyageNumber voyage.Number,
29 | loc location.UNLocode, eventType cargo.HandlingEventType) error {
30 |
31 | defer func(begin time.Time) {
32 | s.requestCount.With("method", "register_incident").Add(1)
33 | s.requestLatency.With("method", "register_incident").Observe(time.Since(begin).Seconds())
34 | }(time.Now())
35 |
36 | return s.Service.RegisterHandlingEvent(completed, id, voyageNumber, loc, eventType)
37 | }
38 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/destination-rule-all.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: DestinationRule
3 | metadata:
4 | name: productpage
5 | spec:
6 | host: productpage
7 | subsets:
8 | - name: v1
9 | labels:
10 | version: v1
11 | ---
12 | apiVersion: networking.istio.io/v1alpha3
13 | kind: DestinationRule
14 | metadata:
15 | name: reviews
16 | spec:
17 | host: reviews
18 | subsets:
19 | - name: v1
20 | labels:
21 | version: v1
22 | - name: v2
23 | labels:
24 | version: v2
25 | - name: v3
26 | labels:
27 | version: v3
28 | ---
29 | apiVersion: networking.istio.io/v1alpha3
30 | kind: DestinationRule
31 | metadata:
32 | name: ratings
33 | spec:
34 | host: ratings
35 | subsets:
36 | - name: v1
37 | labels:
38 | version: v1
39 | - name: v2
40 | labels:
41 | version: v2
42 | - name: v2-mysql
43 | labels:
44 | version: v2-mysql
45 | - name: v2-mysql-vm
46 | labels:
47 | version: v2-mysql-vm
48 | ---
49 | apiVersion: networking.istio.io/v1alpha3
50 | kind: DestinationRule
51 | metadata:
52 | name: details
53 | spec:
54 | host: details
55 | subsets:
56 | - name: v1
57 | labels:
58 | version: v1
59 | - name: v2
60 | labels:
61 | version: v2
62 | ---
63 |
--------------------------------------------------------------------------------
/istio/samples/multicluster/expose-istiod.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: Gateway
3 | metadata:
4 | name: istiod-gateway
5 | namespace: istio-system
6 | spec:
7 | selector:
8 | istio: eastwestgateway
9 | servers:
10 | - port:
11 | name: tls-istiod
12 | number: 15012
13 | protocol: tls
14 | tls:
15 | mode: PASSTHROUGH
16 | hosts:
17 | - "*"
18 | - port:
19 | name: tls-istiodwebhook
20 | number: 15017
21 | protocol: tls
22 | tls:
23 | mode: PASSTHROUGH
24 | hosts:
25 | - "*"
26 | ---
27 | apiVersion: networking.istio.io/v1alpha3
28 | kind: VirtualService
29 | metadata:
30 | name: istiod-vs
31 | namespace: istio-system
32 | spec:
33 | hosts:
34 | - "*"
35 | gateways:
36 | - istiod-gateway
37 | tls:
38 | - match:
39 | - port: 15012
40 | sniHosts:
41 | - "*"
42 | route:
43 | - destination:
44 | host: istiod.istio-system.svc.cluster.local
45 | port:
46 | number: 15012
47 | - match:
48 | - port: 15017
49 | sniHosts:
50 | - "*"
51 | route:
52 | - destination:
53 | host: istiod.istio-system.svc.cluster.local
54 | port:
55 | number: 443
56 |
57 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/reviews/reviews-wlpcfg/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM websphere-liberty:20.0.0.6-full-java8-ibmjava
16 |
17 | ENV SERVERDIRNAME reviews
18 |
19 | COPY ./servers/LibertyProjectServer /opt/ibm/wlp/usr/servers/defaultServer/
20 |
21 | RUN /opt/ibm/wlp/bin/installUtility install --acceptLicense /opt/ibm/wlp/usr/servers/defaultServer/server.xml && \
22 | chmod -R g=rwx /opt/ibm/wlp/output/defaultServer/
23 |
24 | ARG service_version
25 | ARG enable_ratings
26 | ARG star_color
27 | ENV SERVICE_VERSION ${service_version:-v1}
28 | ENV ENABLE_RATINGS ${enable_ratings:-false}
29 | ENV STAR_COLOR ${star_color:-black}
30 |
31 | CMD ["/opt/ibm/wlp/bin/server", "run", "defaultServer"]
32 |
--------------------------------------------------------------------------------
/istio/samples/helloworld/src/app.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | #
3 | # Copyright Istio Authors
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | import os
18 | import math
19 | from flask import Flask, request
20 | app = Flask(__name__)
21 |
22 |
23 | @app.route('/hello')
24 | def hello():
25 | version = os.environ.get('SERVICE_VERSION')
26 |
27 | # do some cpu intensive computation
28 | x = 0.0001
29 | for i in range(0, 1000000):
30 | x = x + math.sqrt(x)
31 |
32 | return 'Hello version: %s, instance: %s\n' % (version, os.environ.get('HOSTNAME'))
33 |
34 |
35 | @app.route('/health')
36 | def health():
37 | return 'Helloworld is healthy', 200
38 |
39 |
40 | if __name__ == "__main__":
41 | app.run(host='0.0.0.0', threaded=True)
42 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/productpage/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM python:3.7.7-slim
16 |
17 | COPY requirements.txt ./
18 | RUN pip install --no-cache-dir -r requirements.txt
19 |
20 | COPY test-requirements.txt ./
21 | RUN pip install --no-cache-dir -r test-requirements.txt
22 |
23 | COPY productpage.py /opt/microservices/
24 | COPY tests/unit/* /opt/microservices/
25 | COPY templates /opt/microservices/templates
26 | COPY static /opt/microservices/static
27 | COPY requirements.txt /opt/microservices/
28 |
29 | ARG flood_factor
30 | ENV FLOOD_FACTOR ${flood_factor:-0}
31 |
32 | EXPOSE 9080
33 | WORKDIR /opt/microservices
34 | RUN python -m unittest discover
35 |
36 | CMD ["python", "productpage.py", "9080"]
37 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/reviews/reviews-wlpcfg/servers/LibertyProjectServer/server.xml:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 |
17 | jaxrs-2.0
18 | jsonp-1.0
19 |
20 |
21 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/istio/samples/tcp-echo/README.md:
--------------------------------------------------------------------------------
1 | # TCP Echo Service
2 |
3 | This sample runs [TCP Echo Server](src/) as an Istio service. TCP Echo Server
4 | allows you to connect to it over TCP and echoes back data sent to it along with
5 | a preconfigured prefix.
6 |
7 | ## Usage
8 |
9 | To run the TCP Echo Service sample:
10 |
11 | 1. Install Istio by following the [istio install instructions](https://istio.io/docs/setup/kubernetes/quick-start.html).
12 |
13 | 1. Start the `tcp-echo-server` service inside the Istio service mesh:
14 |
15 | ```console
16 | $ kubectl apply -f <(istioctl kube-inject -f tcp-echo.yaml)
17 | service/tcp-echo created
18 | deployment.extensions/tcp-echo created
19 | ```
20 |
21 | 1. Test by running the `nc` command from a `busybox` container from within the cluster.
22 |
23 | ```console
24 | $ kubectl run -i --rm --restart=Never dummy --image=busybox -- sh -c "echo world | nc tcp-echo 9000"
25 | hello world
26 | pod "dummy" deleted
27 | ```
28 |
29 | As you observe, sending _world_ on a TCP connection to the server results in
30 | the server prepending _hello_ and echoing back with _hello world_.
31 |
32 | 1. To clean up, execute the following command:
33 |
34 | ```console
35 | $ kubectl delete -f tcp-echo.yaml
36 | service "tcp-echo" deleted
37 | deployment.extensions "tcp-echo" deleted
38 | ```
39 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/src/productpage/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends "bootstrap/base.html" %}
2 | {% block metas %}
3 |
4 |
5 |
6 | {% endblock %}
7 |
8 | {% block styles %}
9 |
10 |
11 |
12 |
13 |
14 | {% endblock %}
15 | {% block scripts %}
16 |
17 |
18 |
19 |
20 |
21 | {% endblock %}
22 | {% block title %}Simple Bookstore App{% endblock %}
23 | {% block content %}
24 |
25 |
Hello! This is a simple bookstore application consisting of three services as shown below
26 |
27 | {% autoescape false %}
28 | {{ serviceTable }}
29 | {% endautoescape %}
30 |
31 |
Click on one of the links below to auto generate a request to the backend as a real user or a tester
32 |
33 |
34 | Normal user
35 | Test user
36 | {% endblock %}
--------------------------------------------------------------------------------
/istio/samples/addons/extras/zipkin.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1
2 | kind: Deployment
3 | metadata:
4 | name: zipkin
5 | namespace: istio-system
6 | labels:
7 | app: zipkin
8 | spec:
9 | selector:
10 | matchLabels:
11 | app: zipkin
12 | template:
13 | metadata:
14 | labels:
15 | app: zipkin
16 | annotations:
17 | sidecar.istio.io/inject: "false"
18 | spec:
19 | containers:
20 | - name: zipkin
21 | image: openzipkin/zipkin-slim:2.21.0
22 | env:
23 | - name: STORAGE_METHOD
24 | value: "mem"
25 | readinessProbe:
26 | httpGet:
27 | path: /health
28 | port: 9411
29 | initialDelaySeconds: 5
30 | periodSeconds: 5
31 | ---
32 | apiVersion: v1
33 | kind: Service
34 | metadata:
35 | name: tracing
36 | namespace: istio-system
37 | labels:
38 | app: zipkin
39 | spec:
40 | type: ClusterIP
41 | ports:
42 | - name: http-query
43 | port: 80
44 | protocol: TCP
45 | targetPort: 9411
46 | selector:
47 | app: zipkin
48 | ---
49 | apiVersion: v1
50 | kind: Service
51 | metadata:
52 | labels:
53 | name: zipkin
54 | name: zipkin
55 | namespace: istio-system
56 | spec:
57 | ports:
58 | - port: 9411
59 | targetPort: 9411
60 | name: http-query
61 | selector:
62 | app: zipkin
63 |
--------------------------------------------------------------------------------
/istio/samples/certs/ca-cert.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIDnzCCAoegAwIBAgIJAON1ifrBZ2/BMA0GCSqGSIb3DQEBCwUAMIGLMQswCQYD
3 | VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTESMBAGA1UEBwwJU3Vubnl2YWxl
4 | MQ4wDAYDVQQKDAVJc3RpbzENMAsGA1UECwwEVGVzdDEQMA4GA1UEAwwHUm9vdCBD
5 | QTEiMCAGCSqGSIb3DQEJARYTdGVzdHJvb3RjYUBpc3Rpby5pbzAgFw0xODAxMjQx
6 | OTE1NTFaGA8yMTE3MTIzMTE5MTU1MVowWTELMAkGA1UEBhMCVVMxEzARBgNVBAgT
7 | CkNhbGlmb3JuaWExEjAQBgNVBAcTCVN1bm55dmFsZTEOMAwGA1UEChMFSXN0aW8x
8 | ETAPBgNVBAMTCElzdGlvIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
9 | AQEAyzCxr/xu0zy5rVBiso9ffgl00bRKvB/HF4AX9/ytmZ6Hqsy13XIQk8/u/By9
10 | iCvVwXIMvyT0CbiJq/aPEj5mJUy0lzbrUs13oneXqrPXf7ir3HzdRw+SBhXlsh9z
11 | APZJXcF93DJU3GabPKwBvGJ0IVMJPIFCuDIPwW4kFAI7R/8A5LSdPrFx6EyMXl7K
12 | M8jekC0y9DnTj83/fY72WcWX7YTpgZeBHAeeQOPTZ2KYbFal2gLsar69PgFS0Tom
13 | ESO9M14Yit7mzB1WDK2z9g3r+zLxENdJ5JG/ZskKe+TO4Diqi5OJt/h8yspS1ck8
14 | LJtCole9919umByg5oruflqIlQIDAQABozUwMzALBgNVHQ8EBAMCAgQwDAYDVR0T
15 | BAUwAwEB/zAWBgNVHREEDzANggtjYS5pc3Rpby5pbzANBgkqhkiG9w0BAQsFAAOC
16 | AQEAltHEhhyAsve4K4bLgBXtHwWzo6SpFzdAfXpLShpOJNtQNERb3qg6iUGQdY+w
17 | A2BpmSkKr3Rw/6ClP5+cCG7fGocPaZh+c+4Nxm9suMuZBZCtNOeYOMIfvCPcCS+8
18 | PQ/0hC4/0J3WJKzGBssaaMufJxzgFPPtDJ998kY8rlROghdSaVt423/jXIAYnP3Y
19 | 05n8TGERBj7TLdtIVbtUIx3JHAo3PWJywA6mEDovFMJhJERp9sDHIr1BbhXK1TFN
20 | Z6HNH6gInkSSMtvC4Ptejb749PTaePRPF7ID//eq/3AH8UK50F3TQcLjEqWUsJUn
21 | aFKltOc+RAjzDklcUPeG4Y6eMA==
22 | -----END CERTIFICATE-----
23 |
--------------------------------------------------------------------------------
/istio/samples/certs/cert-chain.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIDnzCCAoegAwIBAgIJAON1ifrBZ2/BMA0GCSqGSIb3DQEBCwUAMIGLMQswCQYD
3 | VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTESMBAGA1UEBwwJU3Vubnl2YWxl
4 | MQ4wDAYDVQQKDAVJc3RpbzENMAsGA1UECwwEVGVzdDEQMA4GA1UEAwwHUm9vdCBD
5 | QTEiMCAGCSqGSIb3DQEJARYTdGVzdHJvb3RjYUBpc3Rpby5pbzAgFw0xODAxMjQx
6 | OTE1NTFaGA8yMTE3MTIzMTE5MTU1MVowWTELMAkGA1UEBhMCVVMxEzARBgNVBAgT
7 | CkNhbGlmb3JuaWExEjAQBgNVBAcTCVN1bm55dmFsZTEOMAwGA1UEChMFSXN0aW8x
8 | ETAPBgNVBAMTCElzdGlvIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
9 | AQEAyzCxr/xu0zy5rVBiso9ffgl00bRKvB/HF4AX9/ytmZ6Hqsy13XIQk8/u/By9
10 | iCvVwXIMvyT0CbiJq/aPEj5mJUy0lzbrUs13oneXqrPXf7ir3HzdRw+SBhXlsh9z
11 | APZJXcF93DJU3GabPKwBvGJ0IVMJPIFCuDIPwW4kFAI7R/8A5LSdPrFx6EyMXl7K
12 | M8jekC0y9DnTj83/fY72WcWX7YTpgZeBHAeeQOPTZ2KYbFal2gLsar69PgFS0Tom
13 | ESO9M14Yit7mzB1WDK2z9g3r+zLxENdJ5JG/ZskKe+TO4Diqi5OJt/h8yspS1ck8
14 | LJtCole9919umByg5oruflqIlQIDAQABozUwMzALBgNVHQ8EBAMCAgQwDAYDVR0T
15 | BAUwAwEB/zAWBgNVHREEDzANggtjYS5pc3Rpby5pbzANBgkqhkiG9w0BAQsFAAOC
16 | AQEAltHEhhyAsve4K4bLgBXtHwWzo6SpFzdAfXpLShpOJNtQNERb3qg6iUGQdY+w
17 | A2BpmSkKr3Rw/6ClP5+cCG7fGocPaZh+c+4Nxm9suMuZBZCtNOeYOMIfvCPcCS+8
18 | PQ/0hC4/0J3WJKzGBssaaMufJxzgFPPtDJ998kY8rlROghdSaVt423/jXIAYnP3Y
19 | 05n8TGERBj7TLdtIVbtUIx3JHAo3PWJywA6mEDovFMJhJERp9sDHIr1BbhXK1TFN
20 | Z6HNH6gInkSSMtvC4Ptejb749PTaePRPF7ID//eq/3AH8UK50F3TQcLjEqWUsJUn
21 | aFKltOc+RAjzDklcUPeG4Y6eMA==
22 | -----END CERTIFICATE-----
23 |
--------------------------------------------------------------------------------
/etcd/raft/src/raft/kvstore_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The etcd Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package main
16 |
17 | import (
18 | "reflect"
19 | "testing"
20 | )
21 |
22 | func Test_kvstore_snapshot(t *testing.T) {
23 | tm := map[string]string{"foo": "bar"}
24 | s := &kvstore{kvStore: tm}
25 |
26 | v, _ := s.Lookup("foo")
27 | if v != "bar" {
28 | t.Fatalf("foo has unexpected value, got %s", v)
29 | }
30 |
31 | data, err := s.getSnapshot()
32 | if err != nil {
33 | t.Fatal(err)
34 | }
35 | s.kvStore = nil
36 |
37 | if err := s.recoverFromSnapshot(data); err != nil {
38 | t.Fatal(err)
39 | }
40 | v, _ = s.Lookup("foo")
41 | if v != "bar" {
42 | t.Fatalf("foo has unexpected value, got %s", v)
43 | }
44 | if !reflect.DeepEqual(s.kvStore, tm) {
45 | t.Fatalf("store expected %+v, got %+v", tm, s.kvStore)
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/gopher-lua/channel/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "time"
5 | lua "github.com/yuin/gopher-lua"
6 | )
7 |
8 |
9 | func receiver(ch, quit chan lua.LValue) {
10 | L := lua.NewState()
11 | defer L.Close()
12 | L.SetGlobal("ch", lua.LChannel(ch))
13 | L.SetGlobal("quit", lua.LChannel(quit))
14 | if err := L.DoString(`
15 | local exit = false
16 | while not exit do
17 | channel.select(
18 | {"|<-", ch, function(ok, v)
19 | if not ok then
20 | print("channel closed")
21 | exit = true
22 | else
23 | print("received:", v)
24 | end
25 | end},
26 | {"|<-", quit, function(ok, v)
27 | print("quit")
28 | exit = true
29 | end}
30 | )
31 | end
32 | `); err != nil {
33 | panic(err)
34 | }
35 | }
36 |
37 | func sender(ch, quit chan lua.LValue) {
38 | L := lua.NewState()
39 | defer L.Close()
40 | L.SetGlobal("ch", lua.LChannel(ch))
41 | L.SetGlobal("quit", lua.LChannel(quit))
42 | if err := L.DoString(`
43 | ch:send("1")
44 | ch:send("2")
45 | `); err != nil {
46 | panic(err)
47 | }
48 | ch <- lua.LString("3")
49 | quit <- lua.LTrue
50 | }
51 |
52 | func main() {
53 | ch := make(chan lua.LValue)
54 | quit := make(chan lua.LValue)
55 | go receiver(ch, quit)
56 | go sender(ch, quit)
57 | time.Sleep(3 * time.Second)
58 | }
--------------------------------------------------------------------------------
/discovery/demos/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "time"
6 | "github.com/bilibili/discovery/naming"
7 | "os"
8 | "os/signal"
9 | "syscall"
10 | "log"
11 | )
12 |
13 |
14 | func main() {
15 | conf := &naming.Config{
16 | Nodes: []string{"127.0.0.1:10001"}, // NOTE: 配置种子节点(1个或多个),client内部可根据/discovery/nodes节点获取全部node(方便后面增减节点)
17 | Zone: "sh001", // 字段需要跟服务器匹配
18 | Env: "dev",
19 | }
20 | dis := naming.New(conf)
21 | ins := &naming.Instance{
22 | Zone: "sh001",
23 | Env: "dev",
24 | AppID: "provider",
25 | // Hostname:"", // NOTE: hostname 不需要,会优先使用discovery new时Config配置的值,如没有则从os.Hostname方法获取!!!
26 | Addrs: []string{"http://172.0.0.1:8888", "grpc://172.0.0.1:9999"},
27 | LastTs: time.Now().Unix(),
28 | Metadata: map[string]string{"weight": "10"},
29 | }
30 | cancel, _ := dis.Register(ins)
31 | defer cancel() // NOTE: 注意一般在进程退出的时候执行,会调用discovery的cancel接口,使实例从discovery移除
32 | fmt.Println("register")
33 |
34 | c := make(chan os.Signal, 1)
35 | signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
36 | for {
37 | s := <-c
38 | log.Println("discovery get a signal %s", s.String())
39 | switch s {
40 | case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
41 | cancel()
42 | time.Sleep(time.Second)
43 | log.Println("discovery exit")
44 | return
45 | case syscall.SIGHUP:
46 | default:
47 | return
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/istio/samples/bookinfo/README.md:
--------------------------------------------------------------------------------
1 | # Bookinfo Sample
2 |
3 | See
4 |
5 | ## Build docker images without pushing
6 |
7 | ```bash
8 | src/build-services.sh
9 | ```
10 |
11 | Where `` is the tag and `` is the docker registry to tag the images.
12 |
13 | For example: `src/build-services.sh 1.1.0 docker.io/istio`.
14 |
15 | The bookinfo versions are different from Istio versions since the sample should work with any version of Istio.
16 |
17 | ## Update docker images in the yaml files
18 |
19 | ```bash
20 | sed -i "s/\(istio\/examples-bookinfo-.*\):[[:digit:]]\.[[:digit:]]\.[[:digit:]]//g" */bookinfo*.yaml
21 | ```
22 |
23 | ## Push docker images to docker hub
24 |
25 | One script to build the docker images, push them to docker hub and to update the yaml files
26 |
27 | ```bash
28 | build_push_update_images.sh
29 | ```
30 |
31 | ## Tests
32 |
33 | Bookinfo is tested by istio.io integration tests. You can find them under [tests/examples](https://github.com/istio/istio.io/tree/master/tests/examples) in the [istio/istio.io](https://github.com/istio/istio.io) repository.
34 |
35 | The reference productpage HTML files are in [tests/apps/bookinfo/output](https://github.com/istio/istio/tree/master/tests/apps/bookinfo/output). If the productpage HTML produced by the app is changed, remember to regenerate the reference HTML files and commit them with the same PR.
36 |
--------------------------------------------------------------------------------
/kratosV2/helloworld/go.mod:
--------------------------------------------------------------------------------
1 | module helloworld
2 |
3 | go 1.15
4 |
5 | require (
6 | github.com/davecgh/go-spew v1.1.1 // indirect
7 | github.com/fatih/color v1.12.0 // indirect
8 | github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20210526120534-7dec80ccfd71 // indirect
9 | github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20210526120534-7dec80ccfd71 // indirect
10 | github.com/go-kratos/kratos/v2 v2.0.0-rc1
11 | github.com/golang/protobuf v1.5.2
12 | github.com/google/wire v0.5.0
13 | github.com/gorilla/mux v1.8.0
14 | github.com/kr/text v0.2.0 // indirect
15 | github.com/mattn/go-isatty v0.0.13 // indirect
16 | github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
17 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
18 | github.com/spf13/cobra v1.1.3 // indirect
19 | golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
20 | golang.org/x/mod v0.4.2 // indirect
21 | golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea // indirect
22 | golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
23 | golang.org/x/tools v0.1.0 // indirect
24 | google.golang.org/genproto v0.0.0-20210524171403-669157292da3
25 | google.golang.org/grpc v1.38.0
26 | google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 // indirect
27 | google.golang.org/protobuf v1.26.0
28 | gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
29 | gopkg.in/yaml.v2 v2.4.0
30 | gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
31 | )
32 |
--------------------------------------------------------------------------------
/istio/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## 本地搭建 Istio 环境
2 |
3 | ### Minikube
4 |
5 | #### 安装
6 |
7 | ```shell
8 | curl -Lo minikube http://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.16.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
9 | ```
10 |
11 | #### 启动
12 |
13 | ```shell
14 | # --insecure-registry="172.18.0.57:5000"
15 | minikube start --vm-driver=docker --registry-mirror=https://registry.docker-cn.com --image-mirror-country='cn' --image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers' --kubernetes-version v1.18.0 --cpus=4 --memory=8192
16 | ```
17 |
18 | #### kubectl
19 |
20 | ```shell
21 | curl -Lo kubectl http://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl && chmod +x ./kubectl && sudo mv ./kubectl /usr/local/bin/kubectl
22 |
23 | # 验证
24 | kubectl cluster-info
25 | ```
26 |
27 | ### Helm
28 |
29 | ```shell
30 | wget https://get.helm.sh/helm-v3.5.0-linux-amd64.tar.gz
31 | tar -zxvf helm-v3.5.0-linux-amd64.tar.gz
32 | sudo mv linux-amd64/helm /usr/local/bin/helm
33 | ```
34 |
35 | ### Istio
36 |
37 | ```shell
38 | # 下载页面
39 | https://github.com/istio/istio/releases/tag/1.8.2
40 | tar -zxvf istio-1.8.2-linux-amd64.tar.gz
41 | sudo mv istio-1.8.2 /opt/
42 |
43 | # 配置PATH环境变量
44 |
45 | # 然后验证
46 | istioctl install --set profile=demo -y
47 | ```
48 |
49 | #### 案例
50 |
51 | - [《Istio 服务网格进阶实战》](https://www.servicemesher.com/istio-handbook/)
52 | - [《cloud-native-istio》](https://github.com/feixiao/cloud-native-istio)
53 |
--------------------------------------------------------------------------------
/istio/samples/kubernetes-blog/bookinfo-reviews-v2.yaml:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | ##################################################################################################
16 | # Reviews service v2
17 | ##################################################################################################
18 | apiVersion: apps/v1
19 | kind: Deployment
20 | metadata:
21 | name: reviews-v2
22 | labels:
23 | app: reviews
24 | version: v2
25 | spec:
26 | replicas: 1
27 | selector:
28 | matchLabels:
29 | app: reviews
30 | version: v2
31 | template:
32 | metadata:
33 | labels:
34 | app: reviews
35 | version: v2
36 | spec:
37 | containers:
38 | - name: reviews
39 | image: docker.io/istio/examples-bookinfo-reviews-v2:0.2.3
40 | imagePullPolicy: IfNotPresent
41 | ports:
42 | - containerPort: 9080
43 | ---
44 |
--------------------------------------------------------------------------------
/grpc/examples/README.md:
--------------------------------------------------------------------------------
1 | gRPC in 3 minutes (Go)
2 | ======================
3 |
4 | BACKGROUND
5 | -------------
6 | For this sample, we've already generated the server and client stubs from [helloworld.proto](helloworld/helloworld/helloworld.proto).
7 |
8 | PREREQUISITES
9 | -------------
10 |
11 | - This requires Go 1.5 or later
12 | - Requires that [GOPATH is set](https://golang.org/doc/code.html#GOPATH)
13 |
14 | ```
15 | $ go help gopath
16 | $ # ensure the PATH contains $GOPATH/bin
17 | $ export PATH=$PATH:$GOPATH/bin
18 | ```
19 |
20 | INSTALL
21 | -------
22 |
23 | ```
24 | $ go get -u google.golang.org/grpc/examples/helloworld/greeter_client
25 | $ go get -u google.golang.org/grpc/examples/helloworld/greeter_server
26 | ```
27 |
28 | TRY IT!
29 | -------
30 |
31 | - Run the server
32 |
33 | ```
34 | $ greeter_server &
35 | ```
36 |
37 | - Run the client
38 |
39 | ```
40 | $ greeter_client
41 | ```
42 |
43 | OPTIONAL - Rebuilding the generated code
44 | ----------------------------------------
45 |
46 | 1 First [install protoc](https://github.com/google/protobuf/blob/master/README.md)
47 | - For now, this needs to be installed from source
48 | - This is will change once proto3 is officially released
49 |
50 | 2 Install the protoc Go plugin.
51 |
52 | ```
53 | $ go get -a github.com/golang/protobuf/protoc-gen-go
54 | ```
55 |
56 | 3 Rebuild the generated Go code.
57 |
58 | ```
59 | $ go generate google.golang.org/grpc/examples/helloworld/...
60 | ```
61 |
--------------------------------------------------------------------------------
/istio/samples/certs/root-cert.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIID7TCCAtWgAwIBAgIJAOIRDhOcxsx6MA0GCSqGSIb3DQEBCwUAMIGLMQswCQYD
3 | VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTESMBAGA1UEBwwJU3Vubnl2YWxl
4 | MQ4wDAYDVQQKDAVJc3RpbzENMAsGA1UECwwEVGVzdDEQMA4GA1UEAwwHUm9vdCBD
5 | QTEiMCAGCSqGSIb3DQEJARYTdGVzdHJvb3RjYUBpc3Rpby5pbzAgFw0xODAxMjQx
6 | OTE1NTFaGA8yMTE3MTIzMTE5MTU1MVowgYsxCzAJBgNVBAYTAlVTMRMwEQYDVQQI
7 | DApDYWxpZm9ybmlhMRIwEAYDVQQHDAlTdW5ueXZhbGUxDjAMBgNVBAoMBUlzdGlv
8 | MQ0wCwYDVQQLDARUZXN0MRAwDgYDVQQDDAdSb290IENBMSIwIAYJKoZIhvcNAQkB
9 | FhN0ZXN0cm9vdGNhQGlzdGlvLmlvMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
10 | CgKCAQEA38uEfAatzQYqbaLou1nxJ348VyNzumYMmDDt5pbLYRrCo2pS3ki1ZVDN
11 | 8yxIENJFkpKw9UctTGdbNGuGCiSDP7uqF6BiVn+XKAU/3pnPFBbTd0S33NqbDEQu
12 | IYraHSl/tSk5rARbC1DrQRdZ6nYD2KrapC4g0XbjY6Pu5l4y7KnFwSunnp9uqpZw
13 | uERv/BgumJ5QlSeSeCmhnDhLxooG8w5tC2yVr1yDpsOHGimP/mc8Cds4V0zfIhQv
14 | YzfIHphhE9DKjmnjBYLOdj4aycv44jHnOGc+wvA1Jqsl60t3wgms+zJTiWwABLdw
15 | zgMAa7yxLyoV0+PiVQud6k+8ZoIFcwIDAQABo1AwTjAdBgNVHQ4EFgQUOUYGtUyh
16 | euxO4lGe4Op1y8NVoagwHwYDVR0jBBgwFoAUOUYGtUyheuxO4lGe4Op1y8NVoagw
17 | DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEANXLyfAs7J9rmBamGJvPZ
18 | ltx390WxzzLFQsBRAaH6rgeipBq3dR9qEjAwb6BTF+ROmtQzX+fjstCRrJxCto9W
19 | tC8KvXTdRfIjfCCZjhtIOBKqRxE4KJV/RBfv9xD5lyjtCPCQl3Ia6MSf42N+abAK
20 | WCdU6KCojA8WB9YhSCzza3aQbPTzd26OC/JblJpVgtus5f8ILzCsz+pbMimgTkhy
21 | AuhYRppJaQ24APijsEC9+GIaVKPg5IwWroiPoj+QXNpshuvqVQQXvGaRiq4zoSnx
22 | xAJz+w8tjrDWcf826VN14IL+/Cmqlg/rIfB5CHdwVIfWwpuGB66q/UiPegZMNs8a
23 | 3g==
24 | -----END CERTIFICATE-----
25 |
--------------------------------------------------------------------------------
/jupiter/2-部署和使用.md:
--------------------------------------------------------------------------------
1 | ## Juno和Juno-agent快速入门
2 | + Jun
3 | 斗鱼的微服务管理系统,提供了对微服务进行管理的多项能力,包括应用监控、依赖分析、配置管理等。
4 |
5 | + Juno-agent
6 | Juno-Agent是一个提供服务代理、应用配置下发、应用配置解析、shell沙箱、探活、消息总线的Agent。
7 |
8 | #### 安装部署Juno
9 | + 普通
10 |
11 | ```shell
12 | # 创建数据库
13 |
14 | CREATE SCHEMA `juno` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
15 |
16 | # 下载
17 | wget https://github.com/douyu/juno/releases/download/v0.0.1/v0.0.1_linux.zip
18 | unzip v0.0.1_linux.zip
19 |
20 | # 安装数据库
21 | ./bin/install --config=./config/install.toml
22 |
23 | # 管理页面
24 | ./bin/juno --config=./config/admin.toml
25 | ```
26 |
27 | #### 安装部署Juno-agent
28 | + 普通
29 | ```shell
30 | git clone https://github.com/douyu/juno-agent.git
31 | cd juno-agent && make
32 |
33 |
34 | sudo mv release/juno-agent.tar.gz /opt/juno-agent
35 | tar -zxvf juno-agent.tar.gz
36 |
37 | # 生成默认配置
38 | ./juno-agent config > juno-agent.toml
39 |
40 | # 启动
41 | export JUNO_HOST="agent01"
42 | export REGION_CODE="1"
43 | export REGION_NAME="杭州"
44 | export ZONE_CODE="1"
45 | export ZONE_NAME="浙江"
46 | export Env="dev"
47 |
48 | 注:plugin.report.addr 填写juno的地址即可
49 |
50 | ./juno-agent --config=juno-agent.toml
51 | ```
52 |
53 | #### 资源
54 | Juno将资源分为三大类,应用、机房、节点。
55 |
56 | + 机房
57 |
58 | 定义了地区`Region`、可用区`Zone`、环境`Env`,三个值作为唯一值,确定一个机房信息。
59 |
60 | + 节点
61 |
62 | 定义了节点名称`host_name`和节点ID`node_id`作为唯一值,确定一个节点。
63 |
64 | + 应用
65 |
66 | 定义了应用名称`app_name`和应用ID`aid`作为唯一值,确定一个应用。我们可以通过这些数据查询应用。
67 |
68 | ##### 资源管理
69 |
70 | 将`agent`部署到节点上。`agent`会读取节点上环境变量里的节点和机房信息上报给`juno`。
71 |
72 |
--------------------------------------------------------------------------------
/gokit/shipping/voyage/sample_voyages.go:
--------------------------------------------------------------------------------
1 | package voyage
2 |
3 | import (
4 | location "github.com/feixiao/learning/gokit/shipping/location"
5 | )
6 |
7 | // A set of sample voyages.
8 | var (
9 | V100 = New("V100", Schedule{
10 | []CarrierMovement{
11 | {DepartureLocation: location.CNHKG, ArrivalLocation: location.JNTKO},
12 | {DepartureLocation: location.JNTKO, ArrivalLocation: location.USNYC},
13 | },
14 | })
15 |
16 | V300 = New("V300", Schedule{
17 | []CarrierMovement{
18 | {DepartureLocation: location.JNTKO, ArrivalLocation: location.NLRTM},
19 | {DepartureLocation: location.NLRTM, ArrivalLocation: location.DEHAM},
20 | {DepartureLocation: location.DEHAM, ArrivalLocation: location.AUMEL},
21 | {DepartureLocation: location.AUMEL, ArrivalLocation: location.JNTKO},
22 | },
23 | })
24 |
25 | V400 = New("V400", Schedule{
26 | []CarrierMovement{
27 | {DepartureLocation: location.DEHAM, ArrivalLocation: location.SESTO},
28 | {DepartureLocation: location.SESTO, ArrivalLocation: location.FIHEL},
29 | {DepartureLocation: location.FIHEL, ArrivalLocation: location.DEHAM},
30 | },
31 | })
32 | )
33 |
34 | // These voyages are hard-coded into the current pathfinder. Make sure
35 | // they exist.
36 | var (
37 | V0100S = New("0100S", Schedule{[]CarrierMovement{}})
38 | V0200T = New("0200T", Schedule{[]CarrierMovement{}})
39 | V0300A = New("0300A", Schedule{[]CarrierMovement{}})
40 | V0301S = New("0301S", Schedule{[]CarrierMovement{}})
41 | V0400S = New("0400S", Schedule{[]CarrierMovement{}})
42 | )
43 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/networking/destination-rule-all-mtls.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.istio.io/v1alpha3
2 | kind: DestinationRule
3 | metadata:
4 | name: productpage
5 | spec:
6 | host: productpage
7 | trafficPolicy:
8 | tls:
9 | mode: ISTIO_MUTUAL
10 | subsets:
11 | - name: v1
12 | labels:
13 | version: v1
14 | ---
15 | apiVersion: networking.istio.io/v1alpha3
16 | kind: DestinationRule
17 | metadata:
18 | name: reviews
19 | spec:
20 | host: reviews
21 | trafficPolicy:
22 | tls:
23 | mode: ISTIO_MUTUAL
24 | subsets:
25 | - name: v1
26 | labels:
27 | version: v1
28 | - name: v2
29 | labels:
30 | version: v2
31 | - name: v3
32 | labels:
33 | version: v3
34 | ---
35 | apiVersion: networking.istio.io/v1alpha3
36 | kind: DestinationRule
37 | metadata:
38 | name: ratings
39 | spec:
40 | host: ratings
41 | trafficPolicy:
42 | tls:
43 | mode: ISTIO_MUTUAL
44 | subsets:
45 | - name: v1
46 | labels:
47 | version: v1
48 | - name: v2
49 | labels:
50 | version: v2
51 | - name: v2-mysql
52 | labels:
53 | version: v2-mysql
54 | - name: v2-mysql-vm
55 | labels:
56 | version: v2-mysql-vm
57 | ---
58 | apiVersion: networking.istio.io/v1alpha3
59 | kind: DestinationRule
60 | metadata:
61 | name: details
62 | spec:
63 | host: details
64 | trafficPolicy:
65 | tls:
66 | mode: ISTIO_MUTUAL
67 | subsets:
68 | - name: v1
69 | labels:
70 | version: v1
71 | - name: v2
72 | labels:
73 | version: v2
74 | ---
75 |
--------------------------------------------------------------------------------
/jupiter/1-整体介绍.md:
--------------------------------------------------------------------------------
1 | ## Jupiter快速入门
2 | ### 简介
3 | Jupiter 是斗鱼开源的一套微服务治理框架,提供丰富的后台功能,管理应用的资源、配置,应用的性能、配置等可视化。
4 | #### 架构图
5 | 
6 | + Juno 提供了对微服务进行管理的多项能力,包括应用监控、依赖分析、配置管理等
7 | + Juno Agent管理了节点信息、注册信息、配置信息、探活信息、消息总线等功能
8 |
9 | ### 功能点
10 |
11 | ##### 协议
12 |
13 | + WEB
14 | + 基于echo封装。
15 | + 基于Gin的封装。
16 |
17 | + gRPC
18 | + 基于官方 gRPC 开发,集成流控和多数据中心方式的服务注册,支持多种 roundrobin,p2c 等负载均衡策略。
19 | + http接口和grpc如何编写,能否像kratos基于protobuf自动生成?
20 |
21 | ##### 配置
22 |
23 | + 使用 toml、yaml 方式管理配置,规范化核心配置,结合远程配置中心,实现配置版本管理和更新,查看配置依赖关系。
24 | + 支持哪些远程配置中心?
25 | + etcdv3
26 | + file
27 | + http
28 | + 新的远程配置中心接入?
29 | + 需要实现DataSource interface
30 |
31 | ##### 日志
32 | + 基于 zap 日志类库,实现高性能日志库,并对不同环境和条件,实现日志库的自动降级,并对服务端,客户端的慢日志通过配置条件,实现全部慢日志接入;
33 | + 慢日志 ??
34 | ##### 监控
35 | + 基于 prometheus go sdk 类库,实现对服务端,客户端的数据监控,并与 prometheus、cond、etcd 数据打通,实现应用自动化数据采集;
36 |
37 | ##### 数据库
38 | + 基于 gorm 的封装,将数据库的 trace,慢日志,监控进行了采集;
39 |
40 | ##### 缓存
41 | + 基于 go-redis 的封装,将数据库的 trace,慢日志,监控进行了采集,并实现了单个 redis、多从库 redis,客户端 redis 分片,服务端 redis 分片的 api;
42 |
43 | ##### 系统错误码
44 | + 区分框架和业务的错误码,将框架错误码文档自动生成,自动化的错误码 SRE 分析工具;
45 |
46 | ##### 工程化
47 | + 基于服务标准、创建、开发、运行、治理等生命周期,完成了Jupiter对项目的工程化;
48 | + 脚手架在哪里?
49 | + jupiter/tools/jupiter
50 | ```
51 | go get -u github.com/douyu/jupiter/tools/jupiter
52 | jupiter new demo
53 | ```
54 |
55 | ##### 服务治理
56 | + 基于监控,etcd,配置中心,对服务实现了良好的可观测性,可控制性;
57 | + 扩展Registry接口即可
58 |
59 | ### 参考资料
60 | + [官方文档](http://jupiter.douyu.com/jupiter/)
--------------------------------------------------------------------------------
/gokit/shipping/inspection/inspection.go:
--------------------------------------------------------------------------------
1 | // Package inspection provides means to inspect cargos.
2 | package inspection
3 |
4 | import (
5 | "github.com/feixiao/learning/gokit/shipping/cargo"
6 | )
7 |
8 | // EventHandler provides means of subscribing to inspection events.
9 | type EventHandler interface {
10 | CargoWasMisdirected(*cargo.Cargo)
11 | CargoHasArrived(*cargo.Cargo)
12 | }
13 |
14 | // Service provides cargo inspection operations.
15 | type Service interface {
16 | // InspectCargo inspects cargo and send relevant notifications to
17 | // interested parties, for example if a cargo has been misdirected, or
18 | // unloaded at the final destination.
19 | InspectCargo(id cargo.TrackingID)
20 | }
21 |
22 | type service struct {
23 | cargos cargo.Repository
24 | events cargo.HandlingEventRepository
25 | handler EventHandler
26 | }
27 |
28 | // TODO: Should be transactional
29 | func (s *service) InspectCargo(id cargo.TrackingID) {
30 | c, err := s.cargos.Find(id)
31 | if err != nil {
32 | return
33 | }
34 |
35 | h := s.events.QueryHandlingHistory(id)
36 |
37 | c.DeriveDeliveryProgress(h)
38 |
39 | if c.Delivery.IsMisdirected {
40 | s.handler.CargoWasMisdirected(c)
41 | }
42 |
43 | if c.Delivery.IsUnloadedAtDestination {
44 | s.handler.CargoHasArrived(c)
45 | }
46 |
47 | s.cargos.Store(c)
48 | }
49 |
50 | // NewService creates a inspection service with necessary dependencies.
51 | func NewService(cargos cargo.Repository, events cargo.HandlingEventRepository, handler EventHandler) Service {
52 | return &service{cargos, events, handler}
53 | }
54 |
--------------------------------------------------------------------------------
/juiceFS/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## JuiceFS快速入门
2 |
3 | #### 简介
4 | 创建JuiceFS需要三步:
5 | + Redis保存元数据
6 | + 对象存储使用minio
7 | + JuiceFS Client
8 |
9 | #### 安装
10 | ##### Redis
11 | ```shell
12 | # 打开 --appendonly yes
13 | sudo docker run -d --name redis_with_data \
14 | -v ~/volumes/redis/data:/data \
15 | -p 16379:6379 \
16 | --restart unless-stopped \
17 | redis:4.0.14 redis-server --appendonly yes
18 | ```
19 | ##### Object Storage
20 | ```shell
21 | sudo docker run -d --name minio \
22 | -v ~/volumes/minio-data:/data \
23 | -p 9000:9000 \
24 | --restart unless-stopped \
25 | minio/minio server /data
26 | ```
27 |
28 | #### 安装JuiceFS客户端
29 | ```shell
30 | wget https://github.com/juicedata/juicefs/releases/download/v0.15.2/juicefs-0.15.2-linux-amd64.tar.gz
31 |
32 | sudo cp -rf ./juicefs /usr/local/bin
33 |
34 | ```
35 |
36 |
37 | #### 创建JuiceFS文件系统
38 | ```shell
39 | juicefs format \
40 | --storage minio \
41 | --bucket http://127.0.0.1:9000/pics \
42 | --access-key minioadmin \
43 | --secret-key minioadmin \
44 | redis://127.0.0.1:16379/1 \
45 | pics
46 | ```
47 |
48 | #### 映射到本地
49 | ```shell
50 | $ sudo juicefs mount -d redis://127.0.0.1:16379/1 /mnt/jfs
51 |
52 | # 查看
53 | ➜ ~ df -Th | grep /mnt
54 | JuiceFS:pics fuse.juicefs 1.0P 64K 1.0P 1% /mnt/jfs
55 | ```
56 |
57 |
58 | #### 参考资料
59 | + [juicefs](https://github.com/juicedata/juicefs/blob/main/docs/zh_cn/README.md)
60 | + [《JuiceFS Quick Start Guide》](https://github.com/juicedata/juicefs/blob/main/docs/en/quick_start_guide.md)
61 | + [使用场景](https://github.com/juicedata/juicefs/blob/main/docs/zh_cn/case.md)
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/platform/kube/bookinfo-details-v2.yaml:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | ##################################################################################################
16 | # Details service v2
17 | ##################################################################################################
18 | apiVersion: apps/v1
19 | kind: Deployment
20 | metadata:
21 | name: details-v2
22 | labels:
23 | app: details
24 | version: v2
25 | spec:
26 | replicas: 1
27 | selector:
28 | matchLabels:
29 | app: details
30 | version: v2
31 | template:
32 | metadata:
33 | labels:
34 | app: details
35 | version: v2
36 | spec:
37 | containers:
38 | - name: details
39 | image: docker.io/istio/examples-bookinfo-details-v2:1.16.2
40 | imagePullPolicy: IfNotPresent
41 | ports:
42 | - containerPort: 9080
43 | env:
44 | - name: DO_NOT_ENCRYPT
45 | value: "true"
46 | ---
47 |
--------------------------------------------------------------------------------
/openfire/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## OpenFire快速入门
2 | #### XMPP介绍
3 |
4 | ### 服务器端
5 | + 获取镜像
6 | ```
7 | docker pull gizmotronic/openfire:4.3.2
8 | ```
9 |
10 | + Ubuntu
11 | ```
12 | docker run --name openfire -d --restart=always \
13 | --publish 9090:9090 --publish 5222:5222 --publish 7777:7777 \
14 | --volume /home/frank/docker/openfire:/var/lib/openfire \
15 | gizmotronic/openfire:4.3.2
16 | ```
17 | + Windows
18 | ```
19 | docker run --name openfire -d --restart=always --publish 9090:9090 --publish 5222:5222 --publish 7777:7777 --volume D:/docker_volume/ openfire:/var/lib/openfire gizmotronic/openfire:4.3.2
20 | ```
21 |
22 |
23 |
24 | + 管理页面 http://localhost:9090 注意修改 域
25 |
26 |
27 | ### 客户端
28 | + [go-xmpp](https://github.com/FluuxIO/go-xmpp) Golang客户端库
29 | + [gloox](https://camaya.net/gloox/) C++客户端库
30 | + [poezio](https://github.com/poezio/poezio) Python命令行客户端程序
31 | + [slixmpp](https://github.com/poezio/slixmpp) Python客户端库
32 | + [spark](https://github.com/igniterealtime/Spark) 官方客户端程序
33 |
34 |
35 | #### 参考资料
36 | + [《XMPP》](https://xmpp.org/)
37 | + [《Openfire 的安装和配置》](https://www.cnblogs.com/hoojo/archive/2012/05/17/2506769.html)
38 | + [《OpenFire深入浅出》](https://pan.baidu.com/s/1hqDxAtQ?errno=0&errmsg=Auth%20Login%20Sucess&&bduss=&ssnerror=0&traceid=)
39 |
--------------------------------------------------------------------------------
/istio/samples/sleep/README.md:
--------------------------------------------------------------------------------
1 | # Simple sleep service
2 |
3 | This sample consists of a simple service that does nothing but sleep.
4 | It's a ubuntu container with curl installed that can be used as a request source for invoking other services
5 | to experiment with Istio networking.
6 |
7 | To use it:
8 |
9 | 1. Install Istio by following the [istio install instructions](https://istio.io/docs/setup/).
10 |
11 | 1. Start the sleep service:
12 |
13 | If you have [automatic sidecar injection](https://istio.io/docs/setup/additional-setup/sidecar-injection/#automatic-sidecar-injection) enabled:
14 |
15 | ```bash
16 | kubectl apply -f sleep.yaml
17 | ```
18 |
19 | Otherwise manually inject the sidecars before applying:
20 |
21 | ```bash
22 | kubectl apply -f <(istioctl kube-inject -f sleep.yaml)
23 | ```
24 |
25 | 1. Start some other services, for example, the [Bookinfo sample](https://istio.io/docs/examples/bookinfo/).
26 |
27 | Now you can `kubectl exec` into the sleep service to experiment with Istio networking.
28 | For example, the following commands can be used to call the Bookinfo `ratings` service:
29 |
30 | ```bash
31 | export SLEEP_POD=$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})
32 | kubectl exec -it $SLEEP_POD -c sleep curl http://ratings.default.svc.cluster.local:9080/ratings/1
33 | {"id":1,"ratings":{"Reviewer1":5,"Reviewer2":4}}
34 | ```
35 |
36 | You can also use the sleep service to test accessing services outside of the mesh.
37 | See [configuring egress](https://istio.io/docs/tasks/traffic-management/egress/) for details.
38 |
--------------------------------------------------------------------------------
/istio/samples/helloworld/helloworld.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | name: helloworld
5 | labels:
6 | app: helloworld
7 | service: helloworld
8 | spec:
9 | ports:
10 | - port: 5000
11 | name: http
12 | selector:
13 | app: helloworld
14 | ---
15 | apiVersion: apps/v1
16 | kind: Deployment
17 | metadata:
18 | name: helloworld-v1
19 | labels:
20 | app: helloworld
21 | version: v1
22 | spec:
23 | replicas: 1
24 | selector:
25 | matchLabels:
26 | app: helloworld
27 | version: v1
28 | template:
29 | metadata:
30 | labels:
31 | app: helloworld
32 | version: v1
33 | spec:
34 | containers:
35 | - name: helloworld
36 | image: docker.io/istio/examples-helloworld-v1
37 | resources:
38 | requests:
39 | cpu: "100m"
40 | imagePullPolicy: IfNotPresent #Always
41 | ports:
42 | - containerPort: 5000
43 | ---
44 | apiVersion: apps/v1
45 | kind: Deployment
46 | metadata:
47 | name: helloworld-v2
48 | labels:
49 | app: helloworld
50 | version: v2
51 | spec:
52 | replicas: 1
53 | selector:
54 | matchLabels:
55 | app: helloworld
56 | version: v2
57 | template:
58 | metadata:
59 | labels:
60 | app: helloworld
61 | version: v2
62 | spec:
63 | containers:
64 | - name: helloworld
65 | image: docker.io/istio/examples-helloworld-v2
66 | resources:
67 | requests:
68 | cpu: "100m"
69 | imagePullPolicy: IfNotPresent #Always
70 | ports:
71 | - containerPort: 5000
72 |
--------------------------------------------------------------------------------
/istio/samples/tcp-echo/tcp-echo-all-v1.yaml:
--------------------------------------------------------------------------------
1 | # Copyright 2018 Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | apiVersion: networking.istio.io/v1alpha3
16 | kind: Gateway
17 | metadata:
18 | name: tcp-echo-gateway
19 | spec:
20 | selector:
21 | istio: ingressgateway
22 | servers:
23 | - port:
24 | number: 31400
25 | name: tcp
26 | protocol: TCP
27 | hosts:
28 | - "*"
29 | ---
30 | apiVersion: networking.istio.io/v1alpha3
31 | kind: DestinationRule
32 | metadata:
33 | name: tcp-echo-destination
34 | spec:
35 | host: tcp-echo
36 | subsets:
37 | - name: v1
38 | labels:
39 | version: v1
40 | - name: v2
41 | labels:
42 | version: v2
43 | ---
44 | apiVersion: networking.istio.io/v1alpha3
45 | kind: VirtualService
46 | metadata:
47 | name: tcp-echo
48 | spec:
49 | hosts:
50 | - "*"
51 | gateways:
52 | - tcp-echo-gateway
53 | tcp:
54 | - match:
55 | - port: 31400
56 | route:
57 | - destination:
58 | host: tcp-echo
59 | port:
60 | number: 9000
61 | subset: v1
62 |
--------------------------------------------------------------------------------
/tars/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## Tars快速入门
2 |
3 | #### 学习目标
4 | + Tars是什么,提供什么功能?
5 | + 跟其他方案的对比?
6 | + Tars和K8S的区别?
7 | + 如何使用Tars?
8 |
9 |
10 | #### Tars介绍
11 | + Tars是使用Tars协议的高性能**RPC开发框架**,同时配套一体化的**服务治理平台**,帮助个人或者企业快速的以微服务的方式构建自己稳定可靠的分布式应用。
12 | + 框架在腾讯内部,有100多个业务、10多万台服务器上运行使用。
13 | + 支持**C++ 、Go**、Java等(前面两个对我影响力比较大)
14 |
15 | #### 设计思路
16 |
17 | 
18 |
19 | + 统一协议
20 |
21 | 设计思路是将业务网络通信的协议进行统一,以IDL(接口定义语言)的方式,开发支持多平台、可扩展、协议代码自动生成的统一协议。
22 |
23 | + 公共组件、通讯框架、平台层
24 |
25 | + 从使用者的角度出发,封装了大量日常开发过程中经常使用的公共库代码和远程过程调用,让开发使用更简单方便;
26 | + 从分布式平台的角度出发,解决服务运营过程中,遇到的容错、负载均衡、容量管理、就近接入、灰度发布等问题,让平台更加强大。
27 |
28 | + 运营
29 |
30 | + 运维只需要关注日常的服务部署、发布、配置、监控、调度管理等操作。
31 |
32 | #### 整体架构
33 |
34 | 
35 |
36 | 整体架构的拓扑图主要分为2个部分:服务节点与公共框架节点。
37 |
38 | ##### 服务节点
39 |
40 | **服务节点**可以认为是服务所实际运行的一个具体的操作系统实例,可以是物理主机或者虚拟主机、云主机。随着服务的种类扩展和规模扩大,服务节点可能成千上万甚至数以十万计。 每台服务节点上均有一个Node服务节点和N(N>=0)个**业务服务节点**,Node服务节点会对业务服务节点进行统一管理,提供启停、发布、监控等功能,同时接收业务服务节点上报过来的心跳。
41 |
42 | ##### 公共框架节点
43 |
44 | 细分为如下几个部分
45 |
46 | + Web管理系统:在Web上可以看到服务运行的各种实时数据情况,以及对服务进行发布、启停、部署等操作;
47 |
48 | + Registry(路由+管理服务):提供服务节点的地址查询、发布、启停、管理等操作,以及对服务上报心跳的管理,通过它实现服务的注册与发现;
49 |
50 | + Patch(发布管理):提供服务的发布功能;
51 |
52 | + Config(配置中心):提供服务配置文件的统一管理功能;
53 |
54 | + Log(远程日志):提供服务打日志到远程的功能;
55 |
56 | + Stat(调用统计):统计业务服务上报的各种调用信息,比如总流量、平均耗时、超时率等,以便对服务出现异常时进行告警;
57 |
58 | + Property(业务属性):统计业务自定义上报的属性信息,比如内存使用大小、队列大小、cache命中率等,以便对服务出现异常时进行告警;
59 |
60 | + Notify(异常信息):统计业务上报的各种异常信息,比如服务状态变更信息、访问db失败信息等,以便对服务出现异常时进行告警;
61 |
62 | 注:很多都是功能跟k8s类似
63 |
64 | #### 参考资料
65 |
66 | + [《官方文档》](https://doc.tarsyun.com/adminer/start/index.html#/tarsdoc/base/tars-intro.md)
--------------------------------------------------------------------------------
/istio/samples/multicluster/README.md:
--------------------------------------------------------------------------------
1 | # Multicluster Samples
2 |
3 | The samples in this directory help to support multicluster use cases for the
4 | following configurations:
5 |
6 | * Primary-Remote
7 | * Multinetwork
8 |
9 | All of these instructions here assume that Istio has already been deployed to your primary clusters.
10 |
11 | ## Creating East-West Gateway
12 |
13 | All configurations rely on a separate gateway deployment that is dedicated to
14 | east-west traffic. This is done to avoid having east-west traffic flooding
15 | the default north-south ingress gateway.
16 |
17 | Run the following command to deploy the east-west gateway to a primary cluster:
18 |
19 | ```bash
20 | export MESH=mesh1
21 | export CLUSTER=cluster1
22 | export NETWORK=network1
23 | ./samples/multicluster/gen-eastwest-gateway.sh | \
24 | istioctl manifest generate -f - | \
25 | kubectl apply -f -
26 | ```
27 |
28 | The `CLUSTER` and `NETWORK` environment variables should match the values used to deploy the control plane
29 | in that cluster.
30 |
31 | ## Primary-Remote Configuration
32 |
33 | In order to give a remote cluster access to the control plane (istiod) in a primary cluster,
34 | we need to expose the istiod service through the east-west gateway:
35 |
36 | ```bash
37 | kubectl apply -f samples/multicluster/expose-istiod.yaml
38 | ```
39 |
40 | ## Multi-network Configuration
41 |
42 | In order to enable cross-cluster load balancing between clusters that are in different
43 | networks, we need to expose the services through the east-west gateway in each cluster:
44 |
45 | ```bash
46 | kubectl apply -f samples/multicluster/expose-services.yaml
47 | ```
48 |
--------------------------------------------------------------------------------
/kong/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | version: "3.7"
2 | services:
3 | kong:
4 | # 镜像版本,目前最新
5 | image: kong:2.1.3-centos
6 | environment:
7 | # 数据持久化方式,使用postgres数据库
8 | - "KONG_DATABASE=postgres"
9 | # 数据库容器名称,Kong连接数据时使用些名称
10 | - "KONG_PG_HOST=kong-database"
11 | # 数据库名称
12 | - "KONG_CASSANDRA_CONTACT_POINTS=kong-database"
13 | # 日志记录目录
14 | - "KONG_PROXY_ACCESS_LOG=/dev/stdout"
15 | - "KONG_ADMIN_ACCESS_LOG=/dev/stdout"
16 | - "KONG_PROXY_ERROR_LOG=/dev/stderr"
17 | - "KONG_ADMIN_ERROR_LOG=/dev/stderr"
18 | # 暴露的端口
19 | - "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl"
20 | ports:
21 | - 8000:8000
22 | - 8443:8443
23 | - 8001:8001
24 | - 8444:8444
25 | # 使用docker网络
26 | networks:
27 | - kong-net
28 | # 依赖数据库服务
29 | depends_on:
30 | - kong-database
31 | # kong 管理界面
32 | konga:
33 | image: pantsel/konga
34 | environment:
35 | - "TOKEN_SECRET=localhost"
36 | - "NODE_ENV=production"
37 | ports:
38 | - 1337:1337
39 | networks:
40 | - kong-net
41 | depends_on:
42 | - kong-database
43 | # 数据库服务
44 | kong-database:
45 | image: postgres:9.6
46 | ports:
47 | - "5432:5432"
48 | environment:
49 | # 访问数据库的用户
50 | - POSTGRES_USER=kong
51 | - POSTGRES_DB=kong
52 | - POSTGRES_PASSWORD=kong
53 | - POSTGRES_HOST_AUTH_METHOD=trust
54 | networks:
55 | - kong-net
56 | volumes:
57 | # 同步时间
58 | - /etc/localtime:/etc/localtime:ro
59 | # 数据库持久化目录
60 | - /data/data/postgresql:/var/lib/postgresql/data
61 | networks:
62 | kong-net:
63 | external: true
--------------------------------------------------------------------------------
/istio/samples/kubernetes-blog/bookinfo-ratings.yaml:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | ##################################################################################################
16 | # Ratings service
17 | ##################################################################################################
18 | apiVersion: v1
19 | kind: Service
20 | metadata:
21 | name: ratings
22 | labels:
23 | app: ratings
24 | service: ratings
25 | spec:
26 | ports:
27 | - port: 9080
28 | name: http
29 | selector:
30 | app: ratings
31 | ---
32 | apiVersion: apps/v1
33 | kind: Deployment
34 | metadata:
35 | name: ratings-v1
36 | labels:
37 | app: ratings
38 | version: v1
39 | spec:
40 | replicas: 1
41 | template:
42 | metadata:
43 | labels:
44 | app: ratings
45 | version: v1
46 | spec:
47 | containers:
48 | - name: ratings
49 | image: docker.io/istio/examples-bookinfo-ratings-v1:0.2.3
50 | imagePullPolicy: IfNotPresent
51 | ports:
52 | - containerPort: 9080
53 | ---
54 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/platform/kube/bookinfo-db.yaml:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | apiVersion: v1
16 | kind: Service
17 | metadata:
18 | name: mongodb
19 | labels:
20 | app: mongodb
21 | service: mongodb
22 | spec:
23 | ports:
24 | - port: 27017
25 | name: mongo
26 | selector:
27 | app: mongodb
28 | ---
29 | apiVersion: apps/v1
30 | kind: Deployment
31 | metadata:
32 | name: mongodb-v1
33 | labels:
34 | app: mongodb
35 | version: v1
36 | spec:
37 | replicas: 1
38 | selector:
39 | matchLabels:
40 | app: mongodb
41 | version: v1
42 | template:
43 | metadata:
44 | labels:
45 | app: mongodb
46 | version: v1
47 | spec:
48 | containers:
49 | - name: mongodb
50 | image: docker.io/istio/examples-bookinfo-mongodb:1.16.2
51 | imagePullPolicy: IfNotPresent
52 | ports:
53 | - containerPort: 27017
54 | volumeMounts:
55 | - name: data-db
56 | mountPath: /data/db
57 | volumes:
58 | - name: data-db
59 | emptyDir: {}
60 | ---
61 |
--------------------------------------------------------------------------------
/istio/samples/httpbin/httpbin-nodeport.yaml:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | ##################################################################################################
16 | # httpbin service
17 | ##################################################################################################
18 | apiVersion: v1
19 | kind: Service
20 | metadata:
21 | name: httpbin
22 | labels:
23 | app: httpbin
24 | service: httpbin
25 | spec:
26 | type: NodePort
27 | ports:
28 | - name: http
29 | port: 8000
30 | targetPort: 80
31 | selector:
32 | app: httpbin
33 | ---
34 | apiVersion: apps/v1
35 | kind: Deployment
36 | metadata:
37 | name: httpbin
38 | spec:
39 | replicas: 1
40 | selector:
41 | matchLabels:
42 | app: httpbin
43 | version: v1
44 | template:
45 | metadata:
46 | labels:
47 | app: httpbin
48 | version: v1
49 | spec:
50 | containers:
51 | - image: docker.io/kennethreitz/httpbin
52 | imagePullPolicy: IfNotPresent
53 | name: httpbin
54 | ports:
55 | - containerPort: 80
56 |
--------------------------------------------------------------------------------
/istio/samples/health-check/server.go:
--------------------------------------------------------------------------------
1 | // Copyright Istio Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package main
16 |
17 | import (
18 | "net/http"
19 | )
20 |
21 | func main() {
22 | finish := make(chan bool)
23 | server8001 := http.NewServeMux()
24 | server8001.HandleFunc("/foo", foo8001)
25 | server8001.HandleFunc("/bar", bar8001)
26 |
27 | server8002 := http.NewServeMux()
28 | server8002.HandleFunc("/foo", foo8002)
29 | server8002.HandleFunc("/bar", bar8002)
30 |
31 | go func() {
32 | http.ListenAndServe(":8001", server8001)
33 | }()
34 |
35 | go func() {
36 | http.ListenAndServe(":8002", server8002)
37 | }()
38 |
39 | <-finish
40 | }
41 |
42 | func foo8001(w http.ResponseWriter, _ *http.Request) {
43 | w.Write([]byte("Listening on 8001: foo "))
44 | }
45 |
46 | func bar8001(w http.ResponseWriter, _ *http.Request) {
47 | w.Write([]byte("Listening on 8001: bar "))
48 | }
49 |
50 | func foo8002(w http.ResponseWriter, _ *http.Request) {
51 | w.Write([]byte("Listening on 8002: foo "))
52 | }
53 |
54 | func bar8002(w http.ResponseWriter, _ *http.Request) {
55 | w.Write([]byte("Listening on 8002: bar "))
56 | }
57 |
--------------------------------------------------------------------------------
/istio/samples/sleep/sleep-vault.yaml:
--------------------------------------------------------------------------------
1 | # Copyright 2019 Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | ##################################################################################################
16 | # Sleep service
17 | ##################################################################################################
18 | apiVersion: v1
19 | kind: ServiceAccount
20 | metadata:
21 | name: sleep
22 | ---
23 | apiVersion: v1
24 | kind: Service
25 | metadata:
26 | name: sleep
27 | labels:
28 | app: sleep
29 | service: sleep
30 | spec:
31 | ports:
32 | - port: 80
33 | name: http
34 | selector:
35 | app: sleep
36 | ---
37 | apiVersion: apps/v1
38 | kind: Deployment
39 | metadata:
40 | name: sleep
41 | spec:
42 | replicas: 1
43 | selector:
44 | matchLabels:
45 | app: sleep
46 | template:
47 | metadata:
48 | labels:
49 | app: sleep
50 | spec:
51 | serviceAccountName: vault-citadel-sa
52 | containers:
53 | - name: sleep
54 | image: pstauffer/curl
55 | command: ["/bin/sleep", "3650d"]
56 | imagePullPolicy: IfNotPresent
57 | ---
58 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/platform/kube/bookinfo-ingress.yaml:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | ###########################################################################
16 | # Ingress resource (gateway)
17 | ##########################################################################
18 | apiVersion: networking.k8s.io/v1beta1
19 | kind: Ingress
20 | metadata:
21 | name: gateway
22 | annotations:
23 | kubernetes.io/ingress.class: "istio"
24 | spec:
25 | rules:
26 | - http:
27 | paths:
28 | - path: /productpage
29 | backend:
30 | serviceName: productpage
31 | servicePort: 9080
32 | - path: /static/*
33 | backend:
34 | serviceName: productpage
35 | servicePort: 9080
36 | - path: /login
37 | backend:
38 | serviceName: productpage
39 | servicePort: 9080
40 | - path: /logout
41 | backend:
42 | serviceName: productpage
43 | servicePort: 9080
44 | - path: /api/v1/products.*
45 | backend:
46 | serviceName: productpage
47 | servicePort: 9080
48 | ---
49 |
--------------------------------------------------------------------------------
/istio/samples/rawvm/k8services.yaml.in:
--------------------------------------------------------------------------------
1 | ---
2 | apiVersion: v1
3 | kind: Service
4 | metadata:
5 | name: echosrv
6 | spec:
7 | ports:
8 | - port: 8080
9 | name: http-echo
10 | - port: 8079
11 | name: grpc-ping
12 | selector:
13 | app: echosrv
14 | ---
15 | apiVersion: apps/v1
16 | # 2 pods for service inside the cluster, will get istio injected
17 | kind: Deployment
18 | metadata:
19 | name: raw-svc-deployment
20 | spec:
21 | replicas: 2 # tells deployment to run 2 pods matching the template
22 | selector:
23 | matchLabels:
24 | app: echosrv
25 | template: # create pods using pod definition in this template
26 | metadata:
27 | # a unique name is generated from the deployment name
28 | labels:
29 | app: echosrv
30 | spec:
31 | containers:
32 | - name: echosrv
33 | image: FORTIO_IMAGE
34 | ports:
35 | - containerPort: 8080
36 | ---
37 | apiVersion: v1
38 | kind: Service
39 | metadata:
40 | name: mysqlclient-istio
41 | spec:
42 | ports:
43 | - port: 3306
44 | name: mysql
45 | selector:
46 | app: mysqlclient-istio
47 | ---
48 | apiVersion: apps/v1
49 | # 1 pod, will get istio injected
50 | kind: Deployment
51 | metadata:
52 | name: mysqlclient-istio
53 | spec:
54 | replicas: 1
55 | selector:
56 | matchLabels:
57 | app: mysqlclient-istio
58 | template:
59 | metadata:
60 | labels:
61 | app: mysqlclient-istio
62 | spec:
63 | containers:
64 | - name: mysqlclient
65 | image: mysql
66 | command: # don't actually try to start mysql server, just the client
67 | - sleep
68 | - "360000"
69 | ports:
70 | - containerPort: 3306
71 |
--------------------------------------------------------------------------------
/gopher-lua/user_defined_types/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | lua "github.com/yuin/gopher-lua"
5 | )
6 |
7 | // Golang自定义结构体
8 | type Person struct {
9 | Name string
10 | }
11 |
12 | const luaPersonTypeName = "person"
13 |
14 | func registerPersonType(L *lua.LState) {
15 | // 使用名字创建
16 | mt := L.NewTypeMetatable(luaPersonTypeName)
17 | L.SetGlobal(luaPersonTypeName,mt)
18 | // Lua中的new方法,对应Golang中的newPerson
19 | L.SetField(mt,"new",L.NewFunction(newPerson))
20 | // 管理内部函数(通过map映射)
21 | L.SetField(mt,"__index",L.SetFuncs(L.NewTable(),personMethods))
22 | }
23 |
24 | func newPerson(L *lua.LState) int {
25 | person := &Person{L.CheckString(1)}
26 | ud := L.NewUserData()
27 | ud.Value = person
28 | L.SetMetatable(ud,L.GetTypeMetatable(luaPersonTypeName))
29 | L.Push(ud)
30 | return 1
31 | }
32 |
33 | var personMethods = map[string]lua.LGFunction {
34 | "name":personGetSetName, // name方法关联personGetSetName方法
35 | }
36 |
37 | func checkPerson(L *lua.LState) *Person {
38 | ud := L.CheckUserData(1)
39 | if v,ok := ud.Value.(*Person); ok {
40 | return v
41 | }
42 | L.ArgError(1,"person expected")
43 | return nil
44 | }
45 |
46 | func personGetSetName(L *lua.LState) int {
47 | p := checkPerson(L)
48 | if L.GetTop() == 2 {
49 | p.Name = L.CheckString(2)
50 | return 0
51 | }
52 | L.Push(lua.LString(p.Name))
53 | return 1
54 | }
55 |
56 |
57 | func main() {
58 | L := lua.NewState()
59 | defer L.Close()
60 | registerPersonType(L)
61 | if err := L.DoString(`
62 | p = person.new("Steeve")
63 | print(p:name()) -- "Steeve"
64 | p:name("Alice")
65 | print(p:name()) -- "Alice"
66 | `); err != nil {
67 | panic(err)
68 | }
69 | }
--------------------------------------------------------------------------------
/istio/samples/httpbin/httpbin-vault.yaml:
--------------------------------------------------------------------------------
1 | # Copyright 2019 Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | ##################################################################################################
16 | # httpbin service
17 | ##################################################################################################
18 | apiVersion: v1
19 | kind: Service
20 | metadata:
21 | name: httpbin
22 | labels:
23 | app: httpbin
24 | service: httpbin
25 | spec:
26 | ports:
27 | - name: http
28 | port: 8000
29 | targetPort: 80
30 | selector:
31 | app: httpbin
32 | ---
33 | apiVersion: apps/v1
34 | kind: Deployment
35 | metadata:
36 | name: httpbin
37 | spec:
38 | replicas: 1
39 | selector:
40 | matchLabels:
41 | app: httpbin
42 | version: v1
43 | template:
44 | metadata:
45 | labels:
46 | app: httpbin
47 | version: v1
48 | spec:
49 | serviceAccountName: vault-citadel-sa
50 | containers:
51 | - image: docker.io/kennethreitz/httpbin
52 | imagePullPolicy: IfNotPresent
53 | name: httpbin
54 | ports:
55 | - containerPort: 80
56 |
--------------------------------------------------------------------------------
/etcd/raft/src/raft/main.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The etcd Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package main
16 |
17 | import (
18 | "flag"
19 | "strings"
20 |
21 | "github.com/coreos/etcd/raft/raftpb"
22 | )
23 |
24 | func main() {
25 | cluster := flag.String("cluster", "http://127.0.0.1:9021", "comma separated cluster peers")
26 | id := flag.Int("id", 1, "node ID")
27 | kvport := flag.Int("port", 9121, "key-value server port")
28 | join := flag.Bool("join", false, "join an existing cluster")
29 | flag.Parse()
30 |
31 | proposeC := make(chan string)
32 | defer close(proposeC)
33 | confChangeC := make(chan raftpb.ConfChange)
34 | defer close(confChangeC)
35 |
36 | // raft provides a commit stream for the proposals from the http api
37 | var kvs *kvstore
38 | getSnapshot := func() ([]byte, error) { return kvs.getSnapshot() }
39 | commitC, errorC, snapshotterReady := newRaftNode(*id, strings.Split(*cluster, ","), *join, getSnapshot, proposeC, confChangeC)
40 |
41 | kvs = newKVStore(<-snapshotterReady, proposeC, commitC, errorC)
42 |
43 | // the key-value http handler will propose updates to raft
44 | serveHttpKVAPI(kvs, *kvport, confChangeC, errorC)
45 | }
46 |
--------------------------------------------------------------------------------
/istio/samples/external/github.yaml:
--------------------------------------------------------------------------------
1 | # This ServiceEntry exposes the hosts needed for github.com.
2 | # After applying this file, Istio-enabled pods will be able to execute
3 | # `git clone https://github.com/istio/api.git` and (with local identification
4 | # config and certificate) `git clone git@github.com:istio/api.git`
5 |
6 | # HTTP and TLS, the host must be specified
7 | # See https://istio.io/docs/tasks/traffic-management/egress/
8 | apiVersion: networking.istio.io/v1alpha3
9 | kind: ServiceEntry
10 | metadata:
11 | name: github-https
12 | spec:
13 | hosts:
14 | - github.com
15 | ports:
16 | - number: 443
17 | name: https
18 | protocol: HTTPS
19 | ---
20 | # For TCP services the IP ranges SHOULD be specified to avoid problems
21 | # if multiple SEs use the same port number.
22 | # See https://istio.io/blog/2018/egress-tcp/#mesh-external-service-entry-for-an-external-mysql-instance
23 | apiVersion: networking.istio.io/v1alpha3
24 | kind: ServiceEntry
25 | metadata:
26 | name: github-tcp
27 | spec:
28 | hosts:
29 | - dummy.github.com # not used
30 | addresses: # from https://help.github.com/articles/about-github-s-ip-addresses/
31 | - "13.229.188.59/32"
32 | - "13.250.177.223/32"
33 | - "140.82.112.0/20"
34 | - "18.194.104.89/32"
35 | - "18.195.85.27/32"
36 | - "185.199.108.0/22"
37 | - "185.199.108.153/32"
38 | - "185.199.109.153/32"
39 | - "185.199.110.153/32"
40 | - "185.199.111.153/32"
41 | - "192.30.252.0/22"
42 | - "192.30.252.153/32"
43 | - "192.30.252.154/32"
44 | - "23.20.92.3/32"
45 | - "35.159.8.160/32"
46 | - "52.74.223.119/32"
47 | - "54.166.52.62/32"
48 | - "54.87.5.173/32"
49 | ports:
50 | - name: tcp
51 | number: 22
52 | protocol: tcp
53 | location: MESH_EXTERNAL
54 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/platform/kube/bookinfo-details.yaml:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | ##################################################################################################
16 | # Details service
17 | ##################################################################################################
18 | apiVersion: v1
19 | kind: Service
20 | metadata:
21 | name: details
22 | labels:
23 | app: details
24 | service: details
25 | spec:
26 | ports:
27 | - port: 9080
28 | name: http
29 | selector:
30 | app: details
31 | ---
32 | apiVersion: apps/v1
33 | kind: Deployment
34 | metadata:
35 | name: details-v1
36 | labels:
37 | app: details
38 | version: v1
39 | spec:
40 | replicas: 1
41 | selector:
42 | matchLabels:
43 | app: details
44 | version: v1
45 | template:
46 | metadata:
47 | labels:
48 | app: details
49 | version: v1
50 | spec:
51 | containers:
52 | - name: details
53 | image: docker.io/istio/examples-bookinfo-details-v1:1.16.2
54 | imagePullPolicy: IfNotPresent
55 | ports:
56 | - containerPort: 9080
57 | ---
58 |
--------------------------------------------------------------------------------
/istio/samples/bookinfo/platform/kube/bookinfo-ratings.yaml:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | ##################################################################################################
16 | # Ratings service
17 | ##################################################################################################
18 | apiVersion: v1
19 | kind: Service
20 | metadata:
21 | name: ratings
22 | labels:
23 | app: ratings
24 | service: ratings
25 | spec:
26 | ports:
27 | - port: 9080
28 | name: http
29 | selector:
30 | app: ratings
31 | ---
32 | apiVersion: apps/v1
33 | kind: Deployment
34 | metadata:
35 | name: ratings-v1
36 | labels:
37 | app: ratings
38 | version: v1
39 | spec:
40 | replicas: 1
41 | selector:
42 | matchLabels:
43 | app: ratings
44 | version: v1
45 | template:
46 | metadata:
47 | labels:
48 | app: ratings
49 | version: v1
50 | spec:
51 | containers:
52 | - name: ratings
53 | image: docker.io/istio/examples-bookinfo-ratings-v1:1.16.2
54 | imagePullPolicy: IfNotPresent
55 | ports:
56 | - containerPort: 9080
57 | ---
58 |
--------------------------------------------------------------------------------
/etcd/raft/src/raft/listener.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The etcd Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package main
16 |
17 | import (
18 | "errors"
19 | "net"
20 | "time"
21 | )
22 |
23 | // stoppableListener sets TCP keep-alive timeouts on accepted
24 | // connections and waits on stopc message
25 | type stoppableListener struct {
26 | *net.TCPListener
27 | stopc <-chan struct{}
28 | }
29 |
30 | func newStoppableListener(addr string, stopc <-chan struct{}) (*stoppableListener, error) {
31 | ln, err := net.Listen("tcp", addr)
32 | if err != nil {
33 | return nil, err
34 | }
35 | return &stoppableListener{ln.(*net.TCPListener), stopc}, nil
36 | }
37 |
38 | func (ln stoppableListener) Accept() (c net.Conn, err error) {
39 | connc := make(chan *net.TCPConn, 1)
40 | errc := make(chan error, 1)
41 | go func() {
42 | tc, err := ln.AcceptTCP()
43 | if err != nil {
44 | errc <- err
45 | return
46 | }
47 | connc <- tc
48 | }()
49 | select {
50 | case <-ln.stopc:
51 | return nil, errors.New("server stopped")
52 | case err := <-errc:
53 | return nil, err
54 | case tc := <-connc:
55 | tc.SetKeepAlive(true)
56 | tc.SetKeepAlivePeriod(3 * time.Minute)
57 | return tc, nil
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/istio/samples/certs/ca-key.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIIEpAIBAAKCAQEAyzCxr/xu0zy5rVBiso9ffgl00bRKvB/HF4AX9/ytmZ6Hqsy1
3 | 3XIQk8/u/By9iCvVwXIMvyT0CbiJq/aPEj5mJUy0lzbrUs13oneXqrPXf7ir3Hzd
4 | Rw+SBhXlsh9zAPZJXcF93DJU3GabPKwBvGJ0IVMJPIFCuDIPwW4kFAI7R/8A5LSd
5 | PrFx6EyMXl7KM8jekC0y9DnTj83/fY72WcWX7YTpgZeBHAeeQOPTZ2KYbFal2gLs
6 | ar69PgFS0TomESO9M14Yit7mzB1WDK2z9g3r+zLxENdJ5JG/ZskKe+TO4Diqi5OJ
7 | t/h8yspS1ck8LJtCole9919umByg5oruflqIlQIDAQABAoIBAGZI8fnUinmd5R6B
8 | C941XG3XFs6GAuUm3hNPcUFuGnntmv/5I0gBpqSyFO0nDqYg4u8Jma8TTCIkmnFN
9 | ogIeFU+LiJFinR3GvwWzTE8rTz1FWoaY+M9P4ENd/I4pVLxUPuSKhfA2ChAVOupU
10 | 8F7D9Q/dfBXQQCT3VoUaC+FiqjL4HvIhji1zIqaqpK7fChGPraC/4WHwLMNzI0Zg
11 | oDdAanwVygettvm6KD7AeKzhK94gX1PcnsOi3KuzQYvkenQE1M6/K7YtEc5qXCYf
12 | QETj0UCzB55btgdF36BGoZXf0LwHqxys9ubfHuhwKBpY0xg2z4/4RXZNhfIDih3w
13 | J3mihcECgYEA6FtQ0cfh0Zm03OPDpBGc6sdKxTw6aBDtE3KztfI2hl26xHQoeFqp
14 | FmV/TbnExnppw+gWJtwx7IfvowUD8uRR2P0M2wGctWrMpnaEYTiLAPhXsj69HSM/
15 | CYrh54KM0YWyjwNhtUzwbOTrh1jWtT9HV5e7ay9Atk3UWljuR74CFMUCgYEA392e
16 | DVoDLE0XtbysmdlfSffhiQLP9sT8+bf/zYnr8Eq/4LWQoOtjEARbuCj3Oq7bP8IE
17 | Vz45gT1mEE3IacC9neGwuEa6icBiuQi86NW8ilY/ZbOWrRPLOhk3zLiZ+yqkt+sN
18 | cqWx0JkIh7IMKWI4dVQgk4I0jcFP7vNG/So4AZECgYEA426eSPgxHQwqcBuwn6Nt
19 | yJCRq0UsljgbFfIr3Wfb3uFXsntQMZ3r67QlS1sONIgVhmBhbmARrcfQ0+xQ1SqO
20 | wqnOL4AAd8K11iojoVXLGYP7ssieKysYxKpgPE8Yru0CveE9fkx0+OGJeM2IO5hY
21 | qHAoTt3NpaPAuz5Y3XgqaVECgYA0TONS/TeGjxA9/jFY1Cbl8gp35vdNEKKFeM5D
22 | Z7h+cAg56FE8tyFyqYIAGVoBFL7WO26mLzxiDEUfA/0Rb90c2JBfzO5hpleqIPd5
23 | cg3VR+cRzI4kK16sWR3nLy2SN1k6OqjuovVS5Z3PjfI3bOIBz0C5FY9Pmt0g1yc7
24 | mDRzcQKBgQCXWCZStbdjewaLd5u5Hhbw8tIWImMVfcfs3H1FN669LLpbARM8RtAa
25 | 8dYwDVHmWmevb/WX03LiSE+GCjCBO79fa1qc5RKAalqH/1OYxTuvYOeTUebSrg8+
26 | lQFlP2OC4GGolKrN6HVWdxtf+F+SdjwX6qGCfYkXJRLYXIFSFjFeuw==
27 | -----END RSA PRIVATE KEY-----
28 |
--------------------------------------------------------------------------------
/istio/samples/health-check/liveness-command.yaml:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | ##################################################################################################
16 | # Liveness service
17 | ##################################################################################################
18 | apiVersion: v1
19 | kind: Service
20 | metadata:
21 | name: liveness
22 | labels:
23 | app: liveness
24 | service: liveness
25 | spec:
26 | ports:
27 | - port: 80
28 | name: http
29 | selector:
30 | app: liveness
31 | ---
32 | apiVersion: apps/v1
33 | kind: Deployment
34 | metadata:
35 | name: liveness
36 | spec:
37 | selector:
38 | matchLabels:
39 | app: liveness
40 | template:
41 | metadata:
42 | labels:
43 | app: liveness
44 | spec:
45 | containers:
46 | - name: liveness
47 | image: k8s.gcr.io/busybox
48 | args:
49 | - /bin/sh
50 | - -c
51 | - touch /tmp/healthy; sleep 3600
52 | livenessProbe:
53 | exec:
54 | command:
55 | - cat
56 | - /tmp/healthy
57 | initialDelaySeconds: 5
58 | periodSeconds: 5
59 |
--------------------------------------------------------------------------------
/istio/samples/httpbin/httpbin.yaml:
--------------------------------------------------------------------------------
1 | # Copyright Istio Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | ##################################################################################################
16 | # httpbin service
17 | ##################################################################################################
18 | apiVersion: v1
19 | kind: ServiceAccount
20 | metadata:
21 | name: httpbin
22 | ---
23 | apiVersion: v1
24 | kind: Service
25 | metadata:
26 | name: httpbin
27 | labels:
28 | app: httpbin
29 | service: httpbin
30 | spec:
31 | ports:
32 | - name: http
33 | port: 8000
34 | targetPort: 80
35 | selector:
36 | app: httpbin
37 | ---
38 | apiVersion: apps/v1
39 | kind: Deployment
40 | metadata:
41 | name: httpbin
42 | spec:
43 | replicas: 1
44 | selector:
45 | matchLabels:
46 | app: httpbin
47 | version: v1
48 | template:
49 | metadata:
50 | labels:
51 | app: httpbin
52 | version: v1
53 | spec:
54 | serviceAccountName: httpbin
55 | containers:
56 | - image: docker.io/kennethreitz/httpbin
57 | imagePullPolicy: IfNotPresent
58 | name: httpbin
59 | ports:
60 | - containerPort: 80
61 |
--------------------------------------------------------------------------------
/istio/samples/addons/extras/prometheus-operator.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: monitoring.coreos.com/v1
2 | kind: PodMonitor
3 | metadata:
4 | name: envoy-stats-monitor
5 | namespace: istio-system
6 | labels:
7 | monitoring: istio-proxies
8 | release: istio
9 | spec:
10 | selector:
11 | matchExpressions:
12 | - {key: istio-prometheus-ignore, operator: DoesNotExist}
13 | namespaceSelector:
14 | any: true
15 | jobLabel: envoy-stats
16 | podMetricsEndpoints:
17 | - path: /stats/prometheus
18 | interval: 15s
19 | relabelings:
20 | - action: keep
21 | sourceLabels: [__meta_kubernetes_pod_container_name]
22 | regex: "istio-proxy"
23 | - action: keep
24 | sourceLabels: [__meta_kubernetes_pod_annotationpresent_prometheus_io_scrape]
25 | - sourceLabels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
26 | action: replace
27 | regex: ([^:]+)(?::\d+)?;(\d+)
28 | replacement: $1:$2
29 | targetLabel: __address__
30 | - action: labeldrop
31 | regex: "__meta_kubernetes_pod_label_(.+)"
32 | - sourceLabels: [__meta_kubernetes_namespace]
33 | action: replace
34 | targetLabel: namespace
35 | - sourceLabels: [__meta_kubernetes_pod_name]
36 | action: replace
37 | targetLabel: pod_name
38 | ---
39 | apiVersion: monitoring.coreos.com/v1
40 | kind: ServiceMonitor
41 | metadata:
42 | name: istio-component-monitor
43 | namespace: istio-system
44 | labels:
45 | monitoring: istio-components
46 | release: istio
47 | spec:
48 | jobLabel: istio
49 | targetLabels: [app]
50 | selector:
51 | matchExpressions:
52 | - {key: istio, operator: In, values: [pilot]}
53 | namespaceSelector:
54 | any: true
55 | endpoints:
56 | - port: http-monitoring
57 | interval: 15s
58 |
--------------------------------------------------------------------------------