k8s-router

command module
v0.0.0-...-b3a5541 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

README

k8s-router

Simple HTTP router for Kubernetes

描述

这是一个简单基于Kubernetes运行pod的http路由,功能类似kube-proxy(但是没有它那么强大) 目前只能转发http请求(暂不支持tcp和udp) 实现原理是 从etcd中读取kubernetes中指定serverName的endpoint ip地址(watcher 改变),然后自己监听一个端口给外部做负载

使用它的好处是可以根据具体的场合去灵活的自定义负载方案(例如:往往容器启动后需要一些时间才能正常提供服务此时 k8s默认方案会负载过来这时候可能就会有类似504的错误),而且有一个简单的日志能看到请求具体负载到哪一个节点上

目前未在生产环境进行测试仅供学习参考

如何使用
$ ./k8s-router -h
NAME:
   k8s-router - Simple HTTP router for Kubernetes

USAGE:
   k8s-router [global options] command [command options] [arguments...]

VERSION:
   0.0.1

COMMANDS:
   help, h      Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --port, -p "8888"                            proxy listen port
   --service_name, -s                           proxy kubernetes serviceName
   --service_port, --sp "8080"                  proxy kubernetes service port
   --etcd_service, --es "http://master:4001"    kubernetes etcd service
   --log, -l "router.log"                       logs
   --help, -h                                   show help
   --version, -v                                print the version
手动编译

得有个go lang环境然后clone 这个项目

$ GOPATH=`godep path`:$GOPATH
$ go build
参考项目

[0] https://github.com/vulcand/oxy

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Godeps
_workspace/src/github.com/codahale/hdrhistogram
Package hdrhistogram provides an implementation of Gil Tene's HDR Histogram data structure.
Package hdrhistogram provides an implementation of Gil Tene's HDR Histogram data structure.
_workspace/src/github.com/codegangsta/cli
Package cli provides a minimal framework for creating and organizing command line Go applications.
Package cli provides a minimal framework for creating and organizing command line Go applications.
_workspace/src/github.com/coreos/etcd/client
Package client provides bindings for the etcd APIs.
Package client provides bindings for the etcd APIs.
_workspace/src/github.com/coreos/etcd/pkg/pathutil
Package pathutil implements utility functions for handling slash-separated paths.
Package pathutil implements utility functions for handling slash-separated paths.
_workspace/src/github.com/coreos/etcd/pkg/types
Package types declares various data types and implements type-checking functions.
Package types declares various data types and implements type-checking functions.
_workspace/src/github.com/ugorji/go/codec
High Performance, Feature-Rich Idiomatic Go codec/encoding library for binc, msgpack, cbor, json.
High Performance, Feature-Rich Idiomatic Go codec/encoding library for binc, msgpack, cbor, json.
_workspace/src/github.com/ugorji/go/codec/codecgen
codecgen generates codec.Selfer implementations for a set of types.
codecgen generates codec.Selfer implementations for a set of types.
_workspace/src/github.com/vulcand/oxy/forward
package forwarder implements http handler that forwards requests to remote server and serves back the response
package forwarder implements http handler that forwards requests to remote server and serves back the response
_workspace/src/github.com/vulcand/oxy/roundrobin
package roundrobin implements dynamic weighted round robin load balancer http handler
package roundrobin implements dynamic weighted round robin load balancer http handler
_workspace/src/golang.org/x/net/context
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
_workspace/src/golang.org/x/net/context/ctxhttp
Package ctxhttp provides helper functions for performing context-aware HTTP requests.
Package ctxhttp provides helper functions for performing context-aware HTTP requests.
_workspace/src/gopkg.in/mgo.v2/bson
Package bson is an implementation of the BSON specification for Go: http://bsonspec.org It was created as part of the mgo MongoDB driver for Go, but is standalone and may be used on its own without the driver.
Package bson is an implementation of the BSON specification for Go: http://bsonspec.org It was created as part of the mgo MongoDB driver for Go, but is standalone and may be used on its own without the driver.

Jump to

Keyboard shortcuts

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