diff --git a/README.md b/README.md index f921297..483c600 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# metadata-proxy +# metad -`metadata-proxy` is a metadata server support the following features: +`metad` is a metadata server support the following features: -* **self** semantic support. metadata-proxy keep a mapping of IP and metadata, client direct request "/self", will get the metadata of this node. mapping settings is store to backend (etcd). +* **self** semantic support. metad keep a mapping of IP and metadata, client direct request "/self", will get the metadata of this node. mapping settings is store to backend (etcd). * metadata backend support [etcd](https://github.com/coreos/etcd) (TODO support more). * support metadata local cache, so it can be used as a proxy to reducing the request pressure of backend (etcd). * api out format support json/yaml/text,and is metadata/developer friendly data structure. @@ -17,16 +17,16 @@ Go 1.6 is required to build confd, which uses the new vendor directory. ``` $ mkdir -p $GOPATH/src/github.com/yunify -$ git clone https://github.com/yunify/metadata-proxy.git $GOPATH/src/github.com/yunify/metadata-proxy -$ cd $GOPATH/src/github.com/yunify/metadata-proxy +$ git clone https://github.com/yunify/metad.git $GOPATH/src/github.com/yunify/metad +$ cd $GOPATH/src/github.com/yunify/metad $ ./build ``` -You should now have metadata-proxy in your `bin/` directory: +You should now have metad in your `bin/` directory: ``` $ ls bin/ -metadata-proxy +metad ``` ## Manage API @@ -53,10 +53,10 @@ Manage API default port is 127.0.0.1:8112 etcd ``` -* start metadata-proxy +* start metad ``` -bin/metadata-proxy --backend etcdv3 --nodes 127.0.0.1:2379 --log_level debug --listen :8080 --xff true +bin/metad --backend etcdv3 --nodes 127.0.0.1:2379 --log_level debug --listen :8080 --xff true ``` * set etcd version @@ -75,7 +75,7 @@ do done ``` -* fill data by metadata-proxy +* fill data by metad ``` curl -X POST -H "Content-Type: application/json" http://127.0.0.1:8112/v1/data -d '{"nodes":{"1":{"ip":"192.168.1.1","name":"node1"},"2":{"ip":"192.168.1.2","name":"node2"},"3":{"ip":"192.168.1.3","name":"node3"},"4":{"ip":"192.168.1.4","name":"node4"},"5":{"ip":"192.168.1.5","name":"node5"}}}' @@ -142,7 +142,7 @@ node5 ``` -by metadata-proxy text output +by metad text output ``` curl http://127.0.0.1:8080/ @@ -150,7 +150,7 @@ curl http://127.0.0.1:8080/ nodes/ ``` -by metadata-proxy json output +by metad json output ``` curl -H "Accept: application/json" http://127.0.0.1:8080/ @@ -181,7 +181,7 @@ curl -H "Accept: application/json" http://127.0.0.1:8080/ } ``` -by metadata-proxy yaml output +by metad yaml output ``` curl -H "Accept: application/yaml" http://127.0.0.1:8080/ diff --git a/README_zh.md b/README_zh.md index 6afa217..da08223 100644 --- a/README_zh.md +++ b/README_zh.md @@ -1,29 +1,10 @@ -# metadata-proxy +# metad -`metadata-proxy` 是一个元数据服务,主要提供以下功能: +`metad` 是一个元数据服务,主要提供以下功能: * **self** 语义支持,在服务器端对 IP 和元数据做映射,客户端直接通过 /self 请求和本节点相关的元数据.映射设置会保存到后端存储服务进行持久化. * 元数据后端存储支持 [etcd](https://github.com/coreos/etcd) (TODO 支持更多后端). * 元数据缓存,可以降低对后端(etcd)的请求压力. * 输出格式支持json/yaml/text,对配置以及开发更友好. * 支持作为 [confd](https://github.com/kelseyhightower/confd) 的后端服务(TODO). - - -## Building - -需要 Go 1.6 , 依赖通过 vendor 管理. - -``` -$ mkdir -p $GOPATH/src/github.com/yunify -$ git clone https://github.com/yunify/metadata-proxy.git $GOPATH/src/github.com/yunify/metadata-proxy -$ cd $GOPATH/src/github.com/yunify/metadata-proxy -$ ./build -``` - -编译后的 metadata-proxy 在 `bin/` 目录下: - -``` -$ ls bin/ -metadata-proxy -``` diff --git a/backends/client.go b/backends/client.go index 38d84f0..de13e44 100644 --- a/backends/client.go +++ b/backends/client.go @@ -2,10 +2,10 @@ package backends import ( "errors" - "github.com/yunify/metadata-proxy/backends/etcd" - "github.com/yunify/metadata-proxy/backends/etcdv3" - "github.com/yunify/metadata-proxy/log" - "github.com/yunify/metadata-proxy/store" + "github.com/yunify/metad/backends/etcd" + "github.com/yunify/metad/backends/etcdv3" + "github.com/yunify/metad/log" + "github.com/yunify/metad/store" "strings" ) diff --git a/backends/client_test.go b/backends/client_test.go index 5a00d05..b970c44 100644 --- a/backends/client_test.go +++ b/backends/client_test.go @@ -4,9 +4,9 @@ import ( "encoding/json" "fmt" "github.com/stretchr/testify/assert" - "github.com/yunify/metadata-proxy/log" - "github.com/yunify/metadata-proxy/store" - "github.com/yunify/metadata-proxy/util/flatmap" + "github.com/yunify/metad/log" + "github.com/yunify/metad/store" + "github.com/yunify/metad/util/flatmap" "math/rand" "testing" "time" diff --git a/backends/etcd/client.go b/backends/etcd/client.go index f1bdee4..8b96157 100644 --- a/backends/etcd/client.go +++ b/backends/etcd/client.go @@ -5,10 +5,10 @@ import ( "crypto/x509" "fmt" "github.com/coreos/etcd/client" - "github.com/yunify/metadata-proxy/log" - "github.com/yunify/metadata-proxy/store" - "github.com/yunify/metadata-proxy/util" - "github.com/yunify/metadata-proxy/util/flatmap" + "github.com/yunify/metad/log" + "github.com/yunify/metad/store" + "github.com/yunify/metad/util" + "github.com/yunify/metad/util/flatmap" "golang.org/x/net/context" "io/ioutil" "net" @@ -18,7 +18,7 @@ import ( "time" ) -const SELF_MAPPING_PATH = "/_metadata-proxy/mapping" +const SELF_MAPPING_PATH = "/_metad/mapping" // Client is a wrapper around the etcd client type Client struct { diff --git a/backends/etcd/client_test.go b/backends/etcd/client_test.go index eb9a162..c5e374a 100644 --- a/backends/etcd/client_test.go +++ b/backends/etcd/client_test.go @@ -3,8 +3,8 @@ package etcd import ( "fmt" "github.com/stretchr/testify/assert" - "github.com/yunify/metadata-proxy/log" - "github.com/yunify/metadata-proxy/store" + "github.com/yunify/metad/log" + "github.com/yunify/metad/store" "math/rand" "testing" "time" diff --git a/backends/etcdv3/client.go b/backends/etcdv3/client.go index ee3021b..f5c6c7b 100644 --- a/backends/etcdv3/client.go +++ b/backends/etcdv3/client.go @@ -6,10 +6,10 @@ import ( "fmt" client "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/mvcc/mvccpb" - "github.com/yunify/metadata-proxy/log" - "github.com/yunify/metadata-proxy/store" - "github.com/yunify/metadata-proxy/util" - "github.com/yunify/metadata-proxy/util/flatmap" + "github.com/yunify/metad/log" + "github.com/yunify/metad/store" + "github.com/yunify/metad/util" + "github.com/yunify/metad/util/flatmap" "golang.org/x/net/context" "io/ioutil" "path" @@ -17,7 +17,7 @@ import ( "time" ) -const SELF_MAPPING_PATH = "/_metadata-proxy/mapping" +const SELF_MAPPING_PATH = "/_metad/mapping" var ( //see github.com/coreos/etcd/etcdserver/api/v3rpc/key.go diff --git a/backends/etcdv3/client_test.go b/backends/etcdv3/client_test.go index 783fb98..c669eed 100644 --- a/backends/etcdv3/client_test.go +++ b/backends/etcdv3/client_test.go @@ -3,8 +3,8 @@ package etcdv3 import ( "fmt" "github.com/stretchr/testify/assert" - "github.com/yunify/metadata-proxy/log" - "github.com/yunify/metadata-proxy/store" + "github.com/yunify/metad/log" + "github.com/yunify/metad/store" "math/rand" "testing" "time" diff --git a/build b/build index 7f64b97..0c92ec1 100755 --- a/build +++ b/build @@ -1,5 +1,5 @@ #!/usr/bin/env bash -echo "Building metadata-proxy..." +echo "Building metad ..." mkdir -p bin -go build -o bin/metadata-proxy . +go build -o bin/metad . diff --git a/config.go b/config.go index 2430d13..442ed7d 100644 --- a/config.go +++ b/config.go @@ -3,9 +3,9 @@ package main import ( "flag" "fmt" - "github.com/yunify/metadata-proxy/backends" - "github.com/yunify/metadata-proxy/log" - "github.com/yunify/metadata-proxy/metadata" + "github.com/yunify/metad/backends" + "github.com/yunify/metad/log" + "github.com/yunify/metad/metadata" "gopkg.in/yaml.v2" "io/ioutil" "os" diff --git a/example/config.yml b/example/config.yml index ea8113e..14e80eb 100644 --- a/example/config.yml +++ b/example/config.yml @@ -2,7 +2,7 @@ backend: etcd # Set log level: debug|info|warning log_level: debug -pid_file: /var/run/metadata-proxy.pid +pid_file: /var/run/metad.pid # X-Forwarded-For header support" xff: true # Default backend key prefix @@ -16,11 +16,11 @@ listen_manage: 127.0.0.1:8112 # Use Basic Auth to authenticate (only used with -backend=etcd) basic_auth: true # The client ca keys -client_ca_keys: /opt/metadata-proxy/client_ca_keys +client_ca_keys: /opt/metad/client_ca_keys # The client cert -client_cert: /opt/metadata-proxy/client_cert +client_cert: /opt/metad/client_cert # The client key -client_key: /opt/metadata-proxy/client_key +client_key: /opt/metad/client_key # List of backend nodes nodes: - 192.168.11.1:2379 diff --git a/example/etcdv2.md b/example/etcdv2.md index 3e8b0fa..1d3b4c0 100644 --- a/example/etcdv2.md +++ b/example/etcdv2.md @@ -1,4 +1,4 @@ -# etcd v2 metadata-proxy demo +# etcd v2 metad demo * start etcd @@ -6,10 +6,10 @@ etcd ``` -* start metadata-proxy +* start metad ``` -bin/metadata-proxy --backend etcd --nodes 127.0.0.1:2379 --log_level debug --listen :8080 --xff true +bin/metad --backend etcd --nodes 127.0.0.1:2379 --log_level debug --listen :8080 --xff true ``` * fill data to etcd @@ -170,7 +170,7 @@ curl "http://127.0.0.1:2379/v2/keys/?recursive=true" } ``` -by metadata-proxy text output +by metad text output ``` curl http://127.0.0.1:8080/ @@ -178,7 +178,7 @@ curl http://127.0.0.1:8080/ nodes/ ``` -by metadata-proxy json output +by metad json output ``` curl -H "Accept: application/json" http://127.0.0.1:8080/ @@ -209,7 +209,7 @@ curl -H "Accept: application/json" http://127.0.0.1:8080/ } ``` -by metadata-proxy yaml output +by metad yaml output ``` curl -H "Accept: application/yaml" http://127.0.0.1:8080/ diff --git a/main.go b/main.go index 92825fd..8aee12f 100644 --- a/main.go +++ b/main.go @@ -6,9 +6,9 @@ import ( "fmt" "github.com/golang/gddo/httputil" "github.com/gorilla/mux" - "github.com/yunify/metadata-proxy/backends" - "github.com/yunify/metadata-proxy/log" - "github.com/yunify/metadata-proxy/metadata" + "github.com/yunify/metad/backends" + "github.com/yunify/metad/log" + "github.com/yunify/metad/metadata" yaml "gopkg.in/yaml.v2" "io" "net" @@ -56,7 +56,7 @@ func main() { os.Exit(-1) } - log.Info("Starting metadata-proxy %s", VERSION) + log.Info("Starting metad %s", VERSION) var err error storeClient, err = backends.New(backendsConfig) if err != nil { diff --git a/main_test.go b/main_test.go index 3b38a81..d3a3a16 100644 --- a/main_test.go +++ b/main_test.go @@ -12,16 +12,16 @@ func TestConfigFile(t *testing.T) { config := Config{ Backend: "etcd", LogLevel: "debug", - PIDFile: "/var/run/metadata-proxy.pid", + PIDFile: "/var/run/metad.pid", EnableXff: true, Prefix: "/users/uid1", OnlySelf: true, Listen: ":8080", ListenManage: "127.0.0.1:8112", BasicAuth: true, - ClientCaKeys: "/opt/metadata-proxy/client_ca_keys", - ClientCert: "/opt/metadata-proxy/client_cert", - ClientKey: "/opt/metadata-proxy/client_key", + ClientCaKeys: "/opt/metad/client_ca_keys", + ClientCert: "/opt/metad/client_cert", + ClientKey: "/opt/metad/client_key", BackendNodes: []string{"192.168.11.1:2379", "192.168.11.2:2379"}, Username: "username", Password: "password", @@ -29,7 +29,7 @@ func TestConfigFile(t *testing.T) { data, err := yaml.Marshal(config) assert.NoError(t, err) - configFile, fileErr := ioutil.TempFile("/tmp", "metadata-proxy") + configFile, fileErr := ioutil.TempFile("/tmp", "metad") fmt.Printf("configFile: %v \n", configFile.Name()) diff --git a/metadata/metarepo.go b/metadata/metarepo.go index 5825c8d..7870db2 100644 --- a/metadata/metarepo.go +++ b/metadata/metarepo.go @@ -2,9 +2,9 @@ package metadata import ( "errors" - "github.com/yunify/metadata-proxy/backends" - "github.com/yunify/metadata-proxy/log" - "github.com/yunify/metadata-proxy/store" + "github.com/yunify/metad/backends" + "github.com/yunify/metad/log" + "github.com/yunify/metad/store" "net" "path" "reflect" diff --git a/metadata/metarepo_test.go b/metadata/metarepo_test.go index dac90e0..e440b6d 100644 --- a/metadata/metarepo_test.go +++ b/metadata/metarepo_test.go @@ -3,10 +3,10 @@ package metadata import ( "fmt" "github.com/stretchr/testify/assert" - "github.com/yunify/metadata-proxy/backends" - "github.com/yunify/metadata-proxy/log" - "github.com/yunify/metadata-proxy/store" - "github.com/yunify/metadata-proxy/util/flatmap" + "github.com/yunify/metad/backends" + "github.com/yunify/metad/log" + "github.com/yunify/metad/store" + "github.com/yunify/metad/util/flatmap" "math/rand" "testing" "time" diff --git a/store/store.go b/store/store.go index b5113ed..e3c9a24 100644 --- a/store/store.go +++ b/store/store.go @@ -2,8 +2,8 @@ package store import ( "fmt" - "github.com/yunify/metadata-proxy/util" - "github.com/yunify/metadata-proxy/util/flatmap" + "github.com/yunify/metad/util" + "github.com/yunify/metad/util/flatmap" "path" "reflect" "strings" diff --git a/util/flatmap/expand.go b/util/flatmap/expand.go index d4a3641..16b4ae3 100644 --- a/util/flatmap/expand.go +++ b/util/flatmap/expand.go @@ -1,7 +1,7 @@ package flatmap import ( - "github.com/yunify/metadata-proxy/log" + "github.com/yunify/metad/log" "path" "strings" ) diff --git a/util/flatmap/flatten.go b/util/flatmap/flatten.go index 445196a..dd14877 100644 --- a/util/flatmap/flatten.go +++ b/util/flatmap/flatten.go @@ -7,7 +7,7 @@ package flatmap import ( "errors" "fmt" - "github.com/yunify/metadata-proxy/log" + "github.com/yunify/metad/log" "reflect" ) diff --git a/util/flatmap/flatten_test.go b/util/flatmap/flatten_test.go index 029617b..61add22 100644 --- a/util/flatmap/flatten_test.go +++ b/util/flatmap/flatten_test.go @@ -3,7 +3,7 @@ package flatmap import ( "encoding/json" "github.com/stretchr/testify/assert" - "github.com/yunify/metadata-proxy/log" + "github.com/yunify/metad/log" "reflect" "testing" )