From c46aa44143f9d533ca1a58787786552e3f1d16dc Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Tue, 30 Apr 2019 14:03:05 -0700 Subject: [PATCH] Documentation metadata for 3.3 branch (#10692) * Update Documentation folder Signed-off-by: lucperkins * Re-add README file Signed-off-by: lucperkins --- Documentation/_index.md | 3 + Documentation/benchmarks/README.md | 18 - Documentation/benchmarks/_index.md | 3 + .../benchmarks/etcd-2-1-0-alpha-benchmarks.md | 4 + .../benchmarks/etcd-2-2-0-benchmarks.md | 6 +- .../benchmarks/etcd-2-2-0-rc-benchmarks.md | 6 +- .../etcd-2-2-0-rc-memory-benchmarks.md | 4 + .../benchmarks/etcd-3-demo-benchmarks.md | 4 + .../etcd-3-watch-memory-benchmark.md | 4 +- .../etcd-storage-memory-benchmark.md | 4 +- Documentation/branch_management.md | 4 +- Documentation/demo.md | 4 +- Documentation/dev-guide/_index.md | 3 + .../dev-guide/api_concurrency_reference_v3.md | 6 +- Documentation/dev-guide/api_grpc_gateway.md | 95 +- Documentation/dev-guide/api_reference_v3.md | 61 +- .../apispec/swagger/rpc.swagger.json | 294 ++- .../apispec/swagger/v3election.swagger.json | 22 +- .../apispec/swagger/v3lock.swagger.json | 12 +- Documentation/dev-guide/experimental_apis.md | 6 +- Documentation/dev-guide/grpc_naming.md | 10 +- Documentation/dev-guide/interacting_v3.md | 28 +- Documentation/dev-guide/limit.md | 6 +- Documentation/dev-guide/local_cluster.md | 26 +- .../dev-internal/discovery_protocol.md | 4 +- Documentation/dev-internal/logging.md | 4 +- Documentation/dev-internal/release.md | 29 +- Documentation/dl_build.md | 35 +- Documentation/docs.md | 114 - Documentation/faq.md | 14 +- Documentation/integrations.md | 28 +- Documentation/learning/_index.md | 3 + Documentation/learning/api.md | 14 +- Documentation/learning/api_guarantees.md | 6 +- Documentation/learning/auth_design.md | 8 +- Documentation/learning/client-architecture.md | 114 + .../learning/client-feature-matrix.md | 157 ++ Documentation/learning/data_model.md | 8 +- Documentation/learning/glossary.md | 4 +- Documentation/learning/learner.md | 106 + Documentation/learning/why.md | 16 +- Documentation/metrics.md | 9 +- Documentation/op-guide/_index.md | 3 + Documentation/op-guide/authentication.md | 22 +- Documentation/op-guide/clustering.md | 36 +- Documentation/op-guide/configuration.md | 75 +- Documentation/op-guide/container.md | 4 +- Documentation/op-guide/etcd3_alert.rules | 41 - Documentation/op-guide/etcd3_alert.rules.yml | 189 +- Documentation/op-guide/failures.md | 4 +- Documentation/op-guide/gateway.md | 8 +- Documentation/op-guide/grafana.json | 2232 +++++++++-------- Documentation/op-guide/grpc_proxy.md | 10 +- Documentation/op-guide/hardware.md | 4 +- Documentation/op-guide/maintenance.md | 72 +- Documentation/op-guide/monitoring.md | 25 +- Documentation/op-guide/performance.md | 6 +- Documentation/op-guide/recovery.md | 10 +- .../op-guide/runtime-configuration.md | 6 +- .../op-guide/runtime-reconf-design.md | 16 +- Documentation/op-guide/security.md | 94 +- Documentation/op-guide/supported-platform.md | 8 +- Documentation/op-guide/v2-migration.md | 4 +- Documentation/op-guide/versioning.md | 4 +- Documentation/platforms/_index.md | 3 + Documentation/platforms/aws.md | 4 +- .../platforms/container-linux-systemd.md | 4 +- Documentation/platforms/freebsd.md | 4 +- Documentation/production-users.md | 13 +- Documentation/reporting_bugs.md | 6 +- .../{v2/rfc/v3api.md => rfc/_index.md} | 14 +- Documentation/rfc/v3api.md | 211 -- Documentation/tuning.md | 10 +- Documentation/upgrades/_index.md | 3 + Documentation/upgrades/upgrade_3_0.md | 10 +- Documentation/upgrades/upgrade_3_1.md | 6 +- Documentation/upgrades/upgrade_3_2.md | 34 +- Documentation/upgrades/upgrade_3_3.md | 57 +- Documentation/upgrades/upgrade_3_4.md | 419 +++- Documentation/upgrades/upgrade_3_5.md | 343 +++ Documentation/upgrades/upgrading-etcd.md | 9 +- .../v2/04_to_2_snapshot_migration.md | 36 - Documentation/v2/README.md | 85 - Documentation/v2/admin_guide.md | 317 --- Documentation/v2/api.md | 1155 --------- Documentation/v2/api_v3.md | 97 - Documentation/v2/auth_api.md | 516 ---- Documentation/v2/authentication.md | 185 -- Documentation/v2/backward_compatibility.md | 77 - Documentation/v2/benchmarks/README.md | 23 - .../benchmarks/etcd-2-1-0-alpha-benchmarks.md | 57 - .../v2/benchmarks/etcd-2-2-0-benchmarks.md | 77 - .../v2/benchmarks/etcd-2-2-0-rc-benchmarks.md | 77 - .../etcd-2-2-0-rc-memory-benchmarks.md | 52 - .../v2/benchmarks/etcd-3-demo-benchmarks.md | 47 - .../etcd-3-watch-memory-benchmark.md | 82 - .../etcd-storage-memory-benchmark.md | 103 - Documentation/v2/branch_management.md | 31 - Documentation/v2/clustering.md | 440 ---- Documentation/v2/configuration.md | 293 --- Documentation/v2/dev/release.md | 115 - Documentation/v2/discovery_protocol.md | 119 - Documentation/v2/docker_guide.md | 101 - Documentation/v2/errorcode.md | 47 - Documentation/v2/etcd_alert.rules | 121 - Documentation/v2/etcd_alert.rules.yml | 91 - Documentation/v2/faq.md | 89 - Documentation/v2/glossary.md | 40 - .../v2/internal-protocol-versioning.md | 66 - Documentation/v2/libraries-and-tools.md | 131 - Documentation/v2/members_api.md | 125 - Documentation/v2/metrics.md | 148 -- Documentation/v2/other_apis.md | 33 - Documentation/v2/platforms/freebsd.md | 67 - Documentation/v2/production-users.md | 56 - Documentation/v2/proxy.md | 158 -- Documentation/v2/reporting_bugs.md | 50 - Documentation/v2/runtime-configuration.md | 189 -- Documentation/v2/runtime-reconf-design.md | 55 - Documentation/v2/security.md | 199 -- Documentation/v2/tuning.md | 80 - Documentation/v2/upgrade_2_1.md | 121 - Documentation/v2/upgrade_2_2.md | 137 - Documentation/v2/upgrade_2_3.md | 126 - 124 files changed, 3369 insertions(+), 8174 deletions(-) create mode 100644 Documentation/_index.md delete mode 100644 Documentation/benchmarks/README.md create mode 100644 Documentation/benchmarks/_index.md create mode 100644 Documentation/dev-guide/_index.md delete mode 100644 Documentation/docs.md create mode 100644 Documentation/learning/_index.md create mode 100644 Documentation/learning/client-architecture.md create mode 100644 Documentation/learning/client-feature-matrix.md create mode 100644 Documentation/learning/learner.md create mode 100644 Documentation/op-guide/_index.md create mode 100644 Documentation/platforms/_index.md rename Documentation/{v2/rfc/v3api.md => rfc/_index.md} (93%) delete mode 100644 Documentation/rfc/v3api.md create mode 100644 Documentation/upgrades/_index.md create mode 100644 Documentation/upgrades/upgrade_3_5.md delete mode 100644 Documentation/v2/04_to_2_snapshot_migration.md delete mode 100644 Documentation/v2/README.md delete mode 100644 Documentation/v2/admin_guide.md delete mode 100644 Documentation/v2/api.md delete mode 100644 Documentation/v2/api_v3.md delete mode 100644 Documentation/v2/auth_api.md delete mode 100644 Documentation/v2/authentication.md delete mode 100644 Documentation/v2/backward_compatibility.md delete mode 100644 Documentation/v2/benchmarks/README.md delete mode 100644 Documentation/v2/benchmarks/etcd-2-1-0-alpha-benchmarks.md delete mode 100644 Documentation/v2/benchmarks/etcd-2-2-0-benchmarks.md delete mode 100644 Documentation/v2/benchmarks/etcd-2-2-0-rc-benchmarks.md delete mode 100644 Documentation/v2/benchmarks/etcd-2-2-0-rc-memory-benchmarks.md delete mode 100644 Documentation/v2/benchmarks/etcd-3-demo-benchmarks.md delete mode 100644 Documentation/v2/benchmarks/etcd-3-watch-memory-benchmark.md delete mode 100644 Documentation/v2/benchmarks/etcd-storage-memory-benchmark.md delete mode 100644 Documentation/v2/branch_management.md delete mode 100644 Documentation/v2/clustering.md delete mode 100644 Documentation/v2/configuration.md delete mode 100644 Documentation/v2/dev/release.md delete mode 100644 Documentation/v2/discovery_protocol.md delete mode 100644 Documentation/v2/docker_guide.md delete mode 100644 Documentation/v2/errorcode.md delete mode 100644 Documentation/v2/etcd_alert.rules delete mode 100644 Documentation/v2/etcd_alert.rules.yml delete mode 100644 Documentation/v2/faq.md delete mode 100644 Documentation/v2/glossary.md delete mode 100644 Documentation/v2/internal-protocol-versioning.md delete mode 100644 Documentation/v2/libraries-and-tools.md delete mode 100644 Documentation/v2/members_api.md delete mode 100644 Documentation/v2/metrics.md delete mode 100644 Documentation/v2/other_apis.md delete mode 100644 Documentation/v2/platforms/freebsd.md delete mode 100644 Documentation/v2/production-users.md delete mode 100644 Documentation/v2/proxy.md delete mode 100644 Documentation/v2/reporting_bugs.md delete mode 100644 Documentation/v2/runtime-configuration.md delete mode 100644 Documentation/v2/runtime-reconf-design.md delete mode 100644 Documentation/v2/security.md delete mode 100644 Documentation/v2/tuning.md delete mode 100644 Documentation/v2/upgrade_2_1.md delete mode 100644 Documentation/v2/upgrade_2_2.md delete mode 100644 Documentation/v2/upgrade_2_3.md diff --git a/Documentation/_index.md b/Documentation/_index.md new file mode 100644 index 000000000..289dd26cf --- /dev/null +++ b/Documentation/_index.md @@ -0,0 +1,3 @@ +--- +title: etcd version 3.3.12 +--- diff --git a/Documentation/benchmarks/README.md b/Documentation/benchmarks/README.md deleted file mode 100644 index 897112f32..000000000 --- a/Documentation/benchmarks/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Benchmarks - -etcd benchmarks will be published regularly and tracked for each release below: - -- [etcd v2.1.0-alpha][2.1] -- [etcd v2.2.0-rc][2.2] -- [etcd v3 demo][3.0] - -# Memory Usage Benchmarks - -It records expected memory usage in different scenarios. - -- [etcd v2.2.0-rc][2.2-mem] - -[2.1]: etcd-2-1-0-alpha-benchmarks.md -[2.2]: etcd-2-2-0-rc-benchmarks.md -[2.2-mem]: etcd-2-2-0-rc-memory-benchmarks.md -[3.0]: etcd-3-demo-benchmarks.md diff --git a/Documentation/benchmarks/_index.md b/Documentation/benchmarks/_index.md new file mode 100644 index 000000000..63610b272 --- /dev/null +++ b/Documentation/benchmarks/_index.md @@ -0,0 +1,3 @@ +--- +title: Benchmarks +--- \ No newline at end of file diff --git a/Documentation/benchmarks/etcd-2-1-0-alpha-benchmarks.md b/Documentation/benchmarks/etcd-2-1-0-alpha-benchmarks.md index c1a19bdd0..7f2e4a333 100644 --- a/Documentation/benchmarks/etcd-2-1-0-alpha-benchmarks.md +++ b/Documentation/benchmarks/etcd-2-1-0-alpha-benchmarks.md @@ -1,3 +1,7 @@ +--- +title: Benchmarking etcd v2.1.0 +--- + ## Physical machines GCE n1-highcpu-2 machine type diff --git a/Documentation/benchmarks/etcd-2-2-0-benchmarks.md b/Documentation/benchmarks/etcd-2-2-0-benchmarks.md index e9b0178df..6aae3596d 100644 --- a/Documentation/benchmarks/etcd-2-2-0-benchmarks.md +++ b/Documentation/benchmarks/etcd-2-2-0-benchmarks.md @@ -1,4 +1,6 @@ -# Benchmarking etcd v2.2.0 +--- +title: Benchmarking etcd v2.2.0 +--- ## Physical Machines @@ -26,7 +28,7 @@ Go OS/Arch: linux/amd64 Bootstrap another machine, outside of the etcd cluster, and run the [`hey` HTTP benchmark tool](https://github.com/rakyll/hey) with a connection reuse patch to send requests to each etcd cluster member. See the [benchmark instructions](../../hack/benchmark/) for the patch and the steps to reproduce our procedures. -The performance is calulated through results of 100 benchmark rounds. +The performance is calculated through results of 100 benchmark rounds. ## Performance diff --git a/Documentation/benchmarks/etcd-2-2-0-rc-benchmarks.md b/Documentation/benchmarks/etcd-2-2-0-rc-benchmarks.md index ca18f6eb8..df325103d 100644 --- a/Documentation/benchmarks/etcd-2-2-0-rc-benchmarks.md +++ b/Documentation/benchmarks/etcd-2-2-0-rc-benchmarks.md @@ -1,4 +1,8 @@ -## Physical machines +--- +title: Benchmarking etcd v2.2.0-rc +--- + +## Physical machine GCE n1-highcpu-2 machine type diff --git a/Documentation/benchmarks/etcd-2-2-0-rc-memory-benchmarks.md b/Documentation/benchmarks/etcd-2-2-0-rc-memory-benchmarks.md index ef9ed6f31..7244c6989 100644 --- a/Documentation/benchmarks/etcd-2-2-0-rc-memory-benchmarks.md +++ b/Documentation/benchmarks/etcd-2-2-0-rc-memory-benchmarks.md @@ -1,3 +1,7 @@ +--- +title: Benchmarking etcd v2.2.0-rc-memory +--- + ## Physical machine GCE n1-standard-2 machine type diff --git a/Documentation/benchmarks/etcd-3-demo-benchmarks.md b/Documentation/benchmarks/etcd-3-demo-benchmarks.md index ae78f9171..13ed2fe8d 100644 --- a/Documentation/benchmarks/etcd-3-demo-benchmarks.md +++ b/Documentation/benchmarks/etcd-3-demo-benchmarks.md @@ -1,3 +1,7 @@ +--- +title: Benchmarking etcd v3 +--- + ## Physical machines GCE n1-highcpu-2 machine type diff --git a/Documentation/benchmarks/etcd-3-watch-memory-benchmark.md b/Documentation/benchmarks/etcd-3-watch-memory-benchmark.md index c02a8d622..226e10d1e 100644 --- a/Documentation/benchmarks/etcd-3-watch-memory-benchmark.md +++ b/Documentation/benchmarks/etcd-3-watch-memory-benchmark.md @@ -1,4 +1,6 @@ -# Watch Memory Usage Benchmark +--- +title: Watch Memory Usage Benchmark +--- *NOTE*: The watch features are under active development, and their memory usage may change as that development progresses. We do not expect it to significantly increase beyond the figures stated below. diff --git a/Documentation/benchmarks/etcd-storage-memory-benchmark.md b/Documentation/benchmarks/etcd-storage-memory-benchmark.md index 3834a1922..034f622fa 100644 --- a/Documentation/benchmarks/etcd-storage-memory-benchmark.md +++ b/Documentation/benchmarks/etcd-storage-memory-benchmark.md @@ -1,4 +1,6 @@ -# Storage Memory Usage Benchmark +--- +title: Storage Memory Usage Benchmark +--- Two components of etcd storage consume physical memory. The etcd process allocates an *in-memory index* to speed key lookup. The process's *page cache*, managed by the operating system, stores recently-accessed data from disk for quick re-use. diff --git a/Documentation/branch_management.md b/Documentation/branch_management.md index e82a13e39..b236c1a2a 100644 --- a/Documentation/branch_management.md +++ b/Documentation/branch_management.md @@ -1,4 +1,6 @@ -# Branch management +--- +title: Branch management +--- ## Guide diff --git a/Documentation/demo.md b/Documentation/demo.md index 8d86f7a9f..576fa891b 100644 --- a/Documentation/demo.md +++ b/Documentation/demo.md @@ -1,4 +1,6 @@ -# Demo +--- +title: Demo +--- This series of examples shows the basic procedures for working with an etcd cluster. diff --git a/Documentation/dev-guide/_index.md b/Documentation/dev-guide/_index.md new file mode 100644 index 000000000..20cbfb091 --- /dev/null +++ b/Documentation/dev-guide/_index.md @@ -0,0 +1,3 @@ +--- +title: Developer guide +--- \ No newline at end of file diff --git a/Documentation/dev-guide/api_concurrency_reference_v3.md b/Documentation/dev-guide/api_concurrency_reference_v3.md index 9ae1dab75..01059c7c1 100644 --- a/Documentation/dev-guide/api_concurrency_reference_v3.md +++ b/Documentation/dev-guide/api_concurrency_reference_v3.md @@ -1,4 +1,6 @@ -### etcd concurrency API Reference +--- +title: etcd concurrency API Reference +--- This is a generated documentation. Please read the proto files for more. @@ -20,7 +22,7 @@ The lock service exposes client-side locking facilities as a gRPC interface. | Field | Description | Type | | ----- | ----------- | ---- | | name | name is the identifier for the distributed shared lock to be acquired. | bytes | -| lease | lease is the ID of the lease that will be attached to ownership of the lock. If the lease expires or is revoked and currently holds the lock, the lock is automatically released. Calls to Lock with the same lease will be treated as a single acquistion; locking twice with the same lease is a no-op. | int64 | +| lease | lease is the ID of the lease that will be attached to ownership of the lock. If the lease expires or is revoked and currently holds the lock, the lock is automatically released. Calls to Lock with the same lease will be treated as a single acquisition; locking twice with the same lease is a no-op. | int64 | diff --git a/Documentation/dev-guide/api_grpc_gateway.md b/Documentation/dev-guide/api_grpc_gateway.md index 6d115e699..433959d30 100644 --- a/Documentation/dev-guide/api_grpc_gateway.md +++ b/Documentation/dev-guide/api_grpc_gateway.md @@ -1,16 +1,29 @@ +--- +title: Why gRPC gateway +--- -## Why grpc-gateway +etcd v3 uses [gRPC][grpc] for its messaging protocol. The etcd project includes a gRPC-based [Go client][go-client] and a command line utility, [etcdctl][etcdctl], for communicating with an etcd cluster through gRPC. For languages with no gRPC support, etcd provides a JSON [gRPC gateway][grpc-gateway]. This gateway serves a RESTful proxy that translates HTTP/JSON requests into gRPC messages. -etcd v3 uses [gRPC][grpc] for its messaging protocol. The etcd project includes a gRPC-based [Go client][go-client] and a command line utility, [etcdctl][etcdctl], for communicating with an etcd cluster through gRPC. For languages with no gRPC support, etcd provides a JSON [grpc-gateway][grpc-gateway]. This gateway serves a RESTful proxy that translates HTTP/JSON requests into gRPC messages. - - -## Using grpc-gateway +## Using gRPC gateway The gateway accepts a [JSON mapping][json-mapping] for etcd's [protocol buffer][api-ref] message definitions. Note that `key` and `value` fields are defined as byte arrays and therefore must be base64 encoded in JSON. The following examples use `curl`, but any HTTP/JSON client should work all the same. +### Notes + +gRPC gateway endpoint has changed since etcd v3.3: + +- etcd v3.2 or before uses only `[CLIENT-URL]/v3alpha/*`. +- etcd v3.3 uses `[CLIENT-URL]/v3beta/*` while keeping `[CLIENT-URL]/v3alpha/*`. +- etcd v3.4 uses `[CLIENT-URL]/v3/*` while keeping `[CLIENT-URL]/v3beta/*`. + - **`[CLIENT-URL]/v3alpha/*` is deprecated**. +- etcd v3.5 or later uses only `[CLIENT-URL]/v3/*`. + - **`[CLIENT-URL]/v3beta/*` is deprecated**. + +gRPC-gateway does not support authentication using TLS Common Name. + ### Put and get keys -Use the `/v3beta/kv/range` and `/v3beta/kv/put` services to read and write keys: +Use the `/v3/kv/range` and `/v3/kv/put` services to read and write keys: ```bash </dev/null 2>&1 +curl -L http://localhost:2379/v3/kv/put \ + -X POST -d '{"key": "Zm9v", "value": "YmFy"}' >/dev/null 2>&1 # {"result":{"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"2","raft_term":"2"},"events":[{"kv":{"key":"Zm9v","create_revision":"2","mod_revision":"2","version":"1","value":"YmFy"}}]}} ``` ### Transactions -Issue a transaction with `/v3beta/kv/txn`: +Issue a transaction with `/v3/kv/txn`: ```bash -curl -L http://localhost:2379/v3beta/kv/txn \ - -X POST \ - -d '{"compare":[{"target":"CREATE","key":"Zm9v","createRevision":"2"}],"success":[{"requestPut":{"key":"Zm9v","value":"YmFy"}}]}' +# target CREATE +curl -L http://localhost:2379/v3/kv/txn \ + -X POST \ + -d '{"compare":[{"target":"CREATE","key":"Zm9v","createRevision":"2"}],"success":[{"requestPut":{"key":"Zm9v","value":"YmFy"}}]}' # {"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"3","raft_term":"2"},"succeeded":true,"responses":[{"response_put":{"header":{"revision":"3"}}}]} ``` +```bash +# target VERSION +curl -L http://localhost:2379/v3/kv/txn \ + -X POST \ + -d '{"compare":[{"version":"4","result":"EQUAL","target":"VERSION","key":"Zm9v"}],"success":[{"requestRange":{"key":"Zm9v"}}]}' +# {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"6","raft_term":"3"},"succeeded":true,"responses":[{"response_range":{"header":{"revision":"6"},"kvs":[{"key":"Zm9v","create_revision":"2","mod_revision":"6","version":"4","value":"YmF6"}],"count":"1"}}]} +``` + ### Authentication -Set up authentication with the `/v3beta/auth` service: +Set up authentication with the `/v3/auth` service: ```bash # create root user -curl -L http://localhost:2379/v3beta/auth/user/add \ - -X POST -d '{"name": "root", "password": "pass"}' +curl -L http://localhost:2379/v3/auth/user/add \ + -X POST -d '{"name": "root", "password": "pass"}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"}} # create root role -curl -L http://localhost:2379/v3beta/auth/role/add \ - -X POST -d '{"name": "root"}' +curl -L http://localhost:2379/v3/auth/role/add \ + -X POST -d '{"name": "root"}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"}} # grant root role -curl -L http://localhost:2379/v3beta/auth/user/grant \ - -X POST -d '{"user": "root", "role": "root"}' +curl -L http://localhost:2379/v3/auth/user/grant \ + -X POST -d '{"user": "root", "role": "root"}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"}} # enable auth -curl -L http://localhost:2379/v3beta/auth/enable -X POST -d '{}' +curl -L http://localhost:2379/v3/auth/enable -X POST -d '{}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"}} ``` -Authenticate with etcd for an authentication token using `/v3beta/auth/authenticate`: +Authenticate with etcd for an authentication token using `/v3/auth/authenticate`: ```bash # get the auth token for the root user -curl -L http://localhost:2379/v3beta/auth/authenticate \ - -X POST -d '{"name": "root", "password": "pass"}' +curl -L http://localhost:2379/v3/auth/authenticate \ + -X POST -d '{"name": "root", "password": "pass"}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"},"token":"sssvIpwfnLAcWAQH.9"} ``` Set the `Authorization` header to the authentication token to fetch a key using authentication credentials: ```bash -curl -L http://localhost:2379/v3beta/kv/put \ - -H 'Authorization : sssvIpwfnLAcWAQH.9' \ - -X POST -d '{"key": "Zm9v", "value": "YmFy"}' +curl -L http://localhost:2379/v3/kv/put \ + -H 'Authorization : sssvIpwfnLAcWAQH.9' \ + -X POST -d '{"key": "Zm9v", "value": "YmFy"}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"2","raft_term":"2"}} ``` @@ -108,9 +130,8 @@ Generated [Swagger][swagger] API definitions can be found at [rpc.swagger.json][ [api-ref]: ./api_reference_v3.md [go-client]: https://github.com/coreos/etcd/tree/master/clientv3 [etcdctl]: https://github.com/coreos/etcd/tree/master/etcdctl -[grpc]: http://www.grpc.io/ +[grpc]: https://www.grpc.io/ [grpc-gateway]: https://github.com/grpc-ecosystem/grpc-gateway [json-mapping]: https://developers.google.com/protocol-buffers/docs/proto3#json [swagger]: http://swagger.io/ [swagger-doc]: apispec/swagger/rpc.swagger.json - diff --git a/Documentation/dev-guide/api_reference_v3.md b/Documentation/dev-guide/api_reference_v3.md index cf492a182..2d2000d8a 100644 --- a/Documentation/dev-guide/api_reference_v3.md +++ b/Documentation/dev-guide/api_reference_v3.md @@ -1,4 +1,6 @@ -### etcd API Reference +--- +title: etcd API Reference +--- This is a generated documentation. Please read the proto files for more. @@ -69,8 +71,8 @@ This is a generated documentation. Please read the proto files for more. | Alarm | AlarmRequest | AlarmResponse | Alarm activates, deactivates, and queries alarms regarding cluster health. | | Status | StatusRequest | StatusResponse | Status gets the status of the member. | | Defragment | DefragmentRequest | DefragmentResponse | Defragment defragments a member's backend database to recover storage space. | -| Hash | HashRequest | HashResponse | Hash computes the hash of the KV's backend. This is designed for testing; do not use this in production when there are ongoing transactions. | -| HashKV | HashKVRequest | HashKVResponse | HashKV computes the hash of all MVCC keys up to a given revision. | +| Hash | HashRequest | HashResponse | Hash computes the hash of whole backend keyspace, including key, lease, and other buckets in storage. This is designed for testing ONLY! Do not rely on this in production with ongoing transactions, since Hash operation does not hold MVCC locks. Use "HashKV" API instead for "key" bucket consistency checks. | +| HashKV | HashKVRequest | HashKVResponse | HashKV computes the hash of all MVCC keys up to a given revision. It only iterates "key" bucket in backend storage. | | Snapshot | SnapshotRequest | SnapshotResponse | Snapshot sends a snapshot of the entire backend from a member over a stream to a client. | | MoveLeader | MoveLeaderRequest | MoveLeaderResponse | MoveLeader requests current leader node to transfer its leadership to transferee. | @@ -226,8 +228,8 @@ Empty field. | Field | Description | Type | | ----- | ----------- | ---- | | role | | string | -| key | | string | -| range_end | | string | +| key | | bytes | +| range_end | | bytes | @@ -476,6 +478,31 @@ Empty field. +##### message `LeaseCheckpoint` (etcdserver/etcdserverpb/rpc.proto) + +| Field | Description | Type | +| ----- | ----------- | ---- | +| ID | ID is the lease ID to checkpoint. | int64 | +| remaining_TTL | Remaining_TTL is the remaining time until expiry of the lease. | int64 | + + + +##### message `LeaseCheckpointRequest` (etcdserver/etcdserverpb/rpc.proto) + +| Field | Description | Type | +| ----- | ----------- | ---- | +| checkpoints | | (slice of) LeaseCheckpoint | + + + +##### message `LeaseCheckpointResponse` (etcdserver/etcdserverpb/rpc.proto) + +| Field | Description | Type | +| ----- | ----------- | ---- | +| header | | ResponseHeader | + + + ##### message `LeaseGrantRequest` (etcdserver/etcdserverpb/rpc.proto) | Field | Description | Type | @@ -706,7 +733,7 @@ Empty field. | count_only | count_only when set returns only the count of the keys in the range. | bool | | min_mod_revision | min_mod_revision is the lower bound for returned key mod revisions; all keys with lesser mod revisions will be filtered away. | int64 | | max_mod_revision | max_mod_revision is the upper bound for returned key mod revisions; all keys with greater mod revisions will be filtered away. | int64 | -| min_create_revision | min_create_revision is the lower bound for returned key create revisions; all keys with lesser create trevisions will be filtered away. | int64 | +| min_create_revision | min_create_revision is the lower bound for returned key create revisions; all keys with lesser create revisions will be filtered away. | int64 | | max_create_revision | max_create_revision is the upper bound for returned key create revisions; all keys with greater create revisions will be filtered away. | int64 | @@ -740,7 +767,7 @@ Empty field. | ----- | ----------- | ---- | | cluster_id | cluster_id is the ID of the cluster which sent the response. | uint64 | | member_id | member_id is the ID of the member which sent the response. | uint64 | -| revision | revision is the key-value store revision when the request was applied. | int64 | +| revision | revision is the key-value store revision when the request was applied. For watch progress responses, the header.revision indicates progress. All future events recieved in this stream are guaranteed to have a higher revision number than the header.revision number. | int64 | | raft_term | raft_term is the raft term when the request was applied. | uint64 | @@ -785,10 +812,13 @@ Empty field. | ----- | ----------- | ---- | | header | | ResponseHeader | | version | version is the cluster protocol version used by the responding member. | string | -| dbSize | dbSize is the size of the backend database, in bytes, of the responding member. | int64 | +| dbSize | dbSize is the size of the backend database physically allocated, in bytes, of the responding member. | int64 | | leader | leader is the member ID which the responding member believes is the current leader. | uint64 | -| raftIndex | raftIndex is the current raft index of the responding member. | uint64 | +| raftIndex | raftIndex is the current raft committed index of the responding member. | uint64 | | raftTerm | raftTerm is the current raft term of the responding member. | uint64 | +| raftAppliedIndex | raftAppliedIndex is the current raft applied index of the responding member. | uint64 | +| errors | errors contains alarm/health information and status. | (slice of) string | +| dbSizeInUse | dbSizeInUse is the size of the backend database logically in use, in bytes, of the responding member. | int64 | @@ -832,6 +862,16 @@ From google paxosdb paper: Our implementation hinges around a powerful primitive | progress_notify | progress_notify is set so that the etcd server will periodically send a WatchResponse with no events to the new watcher if there are no recent events. It is useful when clients wish to recover a disconnected watcher starting from a recent known revision. The etcd server may decide how often it will send notifications based on current load. | bool | | filters | filters filter the events at server side before it sends back to the watcher. | (slice of) FilterType | | prev_kv | If prev_kv is set, created watcher gets the previous KV before the event happens. If the previous KV is already compacted, nothing will be returned. | bool | +| watch_id | If watch_id is provided and non-zero, it will be assigned to this watcher. Since creating a watcher in etcd is not a synchronous operation, this can be used ensure that ordering is correct when creating multiple watchers on the same stream. Creating a watcher with an ID already in use on the stream will cause an error to be returned. | int64 | +| fragment | fragment enables splitting large revisions into multiple watch responses. | bool | + + + +##### message `WatchProgressRequest` (etcdserver/etcdserverpb/rpc.proto) + +Requests the a watch stream progress status be sent in the watch response stream as soon as possible. + +Empty field. @@ -842,6 +882,7 @@ From google paxosdb paper: Our implementation hinges around a powerful primitive | request_union | request_union is a request to either create a new watcher or cancel an existing watcher. | oneof | | create_request | | WatchCreateRequest | | cancel_request | | WatchCancelRequest | +| progress_request | | WatchProgressRequest | @@ -855,6 +896,7 @@ From google paxosdb paper: Our implementation hinges around a powerful primitive | canceled | canceled is set to true if the response is for a cancel watch request. No further events will be sent to the canceled watcher. | bool | | compact_revision | compact_revision is set to the minimum index if a watcher tries to watch at a compacted index. This happens when creating a watcher at a compacted revision or the watcher cannot catch up with the progress of the key-value store. The client should treat the watcher as canceled and should not try to create any watcher with the same start_revision again. | int64 | | cancel_reason | cancel_reason indicates the reason for canceling the watcher. | string | +| fragment | framgment is true if large watch response was split over multiple responses. | bool | | events | | (slice of) mvccpb.Event | @@ -888,6 +930,7 @@ From google paxosdb paper: Our implementation hinges around a powerful primitive | ----- | ----------- | ---- | | ID | | int64 | | TTL | | int64 | +| RemainingTTL | | int64 | diff --git a/Documentation/dev-guide/apispec/swagger/rpc.swagger.json b/Documentation/dev-guide/apispec/swagger/rpc.swagger.json index d3b2272a8..a76c9d3a8 100644 --- a/Documentation/dev-guide/apispec/swagger/rpc.swagger.json +++ b/Documentation/dev-guide/apispec/swagger/rpc.swagger.json @@ -15,7 +15,7 @@ "version": "version not set" }, "paths": { - "/v3beta/auth/authenticate": { + "/v3/auth/authenticate": { "post": { "tags": [ "Auth" @@ -34,7 +34,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthenticateResponse" } @@ -42,7 +42,7 @@ } } }, - "/v3beta/auth/disable": { + "/v3/auth/disable": { "post": { "tags": [ "Auth" @@ -61,7 +61,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthDisableResponse" } @@ -69,7 +69,7 @@ } } }, - "/v3beta/auth/enable": { + "/v3/auth/enable": { "post": { "tags": [ "Auth" @@ -88,7 +88,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthEnableResponse" } @@ -96,7 +96,7 @@ } } }, - "/v3beta/auth/role/add": { + "/v3/auth/role/add": { "post": { "tags": [ "Auth" @@ -115,7 +115,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthRoleAddResponse" } @@ -123,7 +123,7 @@ } } }, - "/v3beta/auth/role/delete": { + "/v3/auth/role/delete": { "post": { "tags": [ "Auth" @@ -142,7 +142,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthRoleDeleteResponse" } @@ -150,7 +150,7 @@ } } }, - "/v3beta/auth/role/get": { + "/v3/auth/role/get": { "post": { "tags": [ "Auth" @@ -169,7 +169,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthRoleGetResponse" } @@ -177,7 +177,7 @@ } } }, - "/v3beta/auth/role/grant": { + "/v3/auth/role/grant": { "post": { "tags": [ "Auth" @@ -196,7 +196,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthRoleGrantPermissionResponse" } @@ -204,7 +204,7 @@ } } }, - "/v3beta/auth/role/list": { + "/v3/auth/role/list": { "post": { "tags": [ "Auth" @@ -223,7 +223,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthRoleListResponse" } @@ -231,7 +231,7 @@ } } }, - "/v3beta/auth/role/revoke": { + "/v3/auth/role/revoke": { "post": { "tags": [ "Auth" @@ -250,7 +250,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthRoleRevokePermissionResponse" } @@ -258,7 +258,7 @@ } } }, - "/v3beta/auth/user/add": { + "/v3/auth/user/add": { "post": { "tags": [ "Auth" @@ -277,7 +277,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthUserAddResponse" } @@ -285,7 +285,7 @@ } } }, - "/v3beta/auth/user/changepw": { + "/v3/auth/user/changepw": { "post": { "tags": [ "Auth" @@ -304,7 +304,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthUserChangePasswordResponse" } @@ -312,7 +312,7 @@ } } }, - "/v3beta/auth/user/delete": { + "/v3/auth/user/delete": { "post": { "tags": [ "Auth" @@ -331,7 +331,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthUserDeleteResponse" } @@ -339,7 +339,7 @@ } } }, - "/v3beta/auth/user/get": { + "/v3/auth/user/get": { "post": { "tags": [ "Auth" @@ -358,7 +358,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthUserGetResponse" } @@ -366,7 +366,7 @@ } } }, - "/v3beta/auth/user/grant": { + "/v3/auth/user/grant": { "post": { "tags": [ "Auth" @@ -385,7 +385,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthUserGrantRoleResponse" } @@ -393,7 +393,7 @@ } } }, - "/v3beta/auth/user/list": { + "/v3/auth/user/list": { "post": { "tags": [ "Auth" @@ -412,7 +412,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthUserListResponse" } @@ -420,7 +420,7 @@ } } }, - "/v3beta/auth/user/revoke": { + "/v3/auth/user/revoke": { "post": { "tags": [ "Auth" @@ -439,7 +439,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAuthUserRevokeRoleResponse" } @@ -447,7 +447,7 @@ } } }, - "/v3beta/cluster/member/add": { + "/v3/cluster/member/add": { "post": { "tags": [ "Cluster" @@ -466,7 +466,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbMemberAddResponse" } @@ -474,7 +474,7 @@ } } }, - "/v3beta/cluster/member/list": { + "/v3/cluster/member/list": { "post": { "tags": [ "Cluster" @@ -493,7 +493,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbMemberListResponse" } @@ -501,7 +501,7 @@ } } }, - "/v3beta/cluster/member/remove": { + "/v3/cluster/member/remove": { "post": { "tags": [ "Cluster" @@ -520,7 +520,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbMemberRemoveResponse" } @@ -528,7 +528,7 @@ } } }, - "/v3beta/cluster/member/update": { + "/v3/cluster/member/update": { "post": { "tags": [ "Cluster" @@ -547,7 +547,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbMemberUpdateResponse" } @@ -555,7 +555,7 @@ } } }, - "/v3beta/kv/compaction": { + "/v3/kv/compaction": { "post": { "tags": [ "KV" @@ -574,7 +574,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbCompactionResponse" } @@ -582,7 +582,7 @@ } } }, - "/v3beta/kv/deleterange": { + "/v3/kv/deleterange": { "post": { "tags": [ "KV" @@ -601,7 +601,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbDeleteRangeResponse" } @@ -609,13 +609,13 @@ } } }, - "/v3beta/kv/lease/leases": { + "/v3/kv/lease/leases": { "post": { "tags": [ "Lease" ], "summary": "LeaseLeases lists all existing leases.", - "operationId": "LeaseLeases", + "operationId": "LeaseLeases2", "parameters": [ { "name": "body", @@ -628,7 +628,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbLeaseLeasesResponse" } @@ -636,13 +636,13 @@ } } }, - "/v3beta/kv/lease/revoke": { + "/v3/kv/lease/revoke": { "post": { "tags": [ "Lease" ], "summary": "LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.", - "operationId": "LeaseRevoke", + "operationId": "LeaseRevoke2", "parameters": [ { "name": "body", @@ -655,7 +655,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbLeaseRevokeResponse" } @@ -663,13 +663,13 @@ } } }, - "/v3beta/kv/lease/timetolive": { + "/v3/kv/lease/timetolive": { "post": { "tags": [ "Lease" ], "summary": "LeaseTimeToLive retrieves lease information.", - "operationId": "LeaseTimeToLive", + "operationId": "LeaseTimeToLive2", "parameters": [ { "name": "body", @@ -682,7 +682,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbLeaseTimeToLiveResponse" } @@ -690,7 +690,7 @@ } } }, - "/v3beta/kv/put": { + "/v3/kv/put": { "post": { "tags": [ "KV" @@ -709,7 +709,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbPutResponse" } @@ -717,7 +717,7 @@ } } }, - "/v3beta/kv/range": { + "/v3/kv/range": { "post": { "tags": [ "KV" @@ -736,7 +736,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbRangeResponse" } @@ -744,7 +744,7 @@ } } }, - "/v3beta/kv/txn": { + "/v3/kv/txn": { "post": { "tags": [ "KV" @@ -763,7 +763,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbTxnResponse" } @@ -771,7 +771,7 @@ } } }, - "/v3beta/lease/grant": { + "/v3/lease/grant": { "post": { "tags": [ "Lease" @@ -790,7 +790,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbLeaseGrantResponse" } @@ -798,7 +798,7 @@ } } }, - "/v3beta/lease/keepalive": { + "/v3/lease/keepalive": { "post": { "tags": [ "Lease" @@ -807,7 +807,7 @@ "operationId": "LeaseKeepAlive", "parameters": [ { - "description": "(streaming inputs)", + "description": " (streaming inputs)", "name": "body", "in": "body", "required": true, @@ -818,7 +818,7 @@ ], "responses": { "200": { - "description": "(streaming responses)", + "description": "A successful response.(streaming responses)", "schema": { "$ref": "#/definitions/etcdserverpbLeaseKeepAliveResponse" } @@ -826,7 +826,88 @@ } } }, - "/v3beta/maintenance/alarm": { + "/v3/lease/leases": { + "post": { + "tags": [ + "Lease" + ], + "summary": "LeaseLeases lists all existing leases.", + "operationId": "LeaseLeases", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/etcdserverpbLeaseLeasesRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/etcdserverpbLeaseLeasesResponse" + } + } + } + } + }, + "/v3/lease/revoke": { + "post": { + "tags": [ + "Lease" + ], + "summary": "LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.", + "operationId": "LeaseRevoke", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/etcdserverpbLeaseRevokeRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/etcdserverpbLeaseRevokeResponse" + } + } + } + } + }, + "/v3/lease/timetolive": { + "post": { + "tags": [ + "Lease" + ], + "summary": "LeaseTimeToLive retrieves lease information.", + "operationId": "LeaseTimeToLive", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/etcdserverpbLeaseTimeToLiveRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/etcdserverpbLeaseTimeToLiveResponse" + } + } + } + } + }, + "/v3/maintenance/alarm": { "post": { "tags": [ "Maintenance" @@ -845,7 +926,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbAlarmResponse" } @@ -853,7 +934,7 @@ } } }, - "/v3beta/maintenance/defragment": { + "/v3/maintenance/defragment": { "post": { "tags": [ "Maintenance" @@ -872,7 +953,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbDefragmentResponse" } @@ -880,12 +961,12 @@ } } }, - "/v3beta/maintenance/hash": { + "/v3/maintenance/hash": { "post": { "tags": [ "Maintenance" ], - "summary": "HashKV computes the hash of all MVCC keys up to a given revision.", + "summary": "HashKV computes the hash of all MVCC keys up to a given revision.\nIt only iterates \"key\" bucket in backend storage.", "operationId": "HashKV", "parameters": [ { @@ -899,7 +980,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbHashKVResponse" } @@ -907,7 +988,7 @@ } } }, - "/v3beta/maintenance/snapshot": { + "/v3/maintenance/snapshot": { "post": { "tags": [ "Maintenance" @@ -926,7 +1007,7 @@ ], "responses": { "200": { - "description": "(streaming responses)", + "description": "A successful response.(streaming responses)", "schema": { "$ref": "#/definitions/etcdserverpbSnapshotResponse" } @@ -934,7 +1015,7 @@ } } }, - "/v3beta/maintenance/status": { + "/v3/maintenance/status": { "post": { "tags": [ "Maintenance" @@ -953,7 +1034,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbStatusResponse" } @@ -961,7 +1042,7 @@ } } }, - "/v3beta/maintenance/transfer-leadership": { + "/v3/maintenance/transfer-leadership": { "post": { "tags": [ "Maintenance" @@ -980,7 +1061,7 @@ ], "responses": { "200": { - "description": "(empty)", + "description": "A successful response.", "schema": { "$ref": "#/definitions/etcdserverpbMoveLeaderResponse" } @@ -988,7 +1069,7 @@ } } }, - "/v3beta/watch": { + "/v3/watch": { "post": { "tags": [ "Watch" @@ -997,7 +1078,7 @@ "operationId": "Watch", "parameters": [ { - "description": "(streaming inputs)", + "description": " (streaming inputs)", "name": "body", "in": "body", "required": true, @@ -1008,7 +1089,7 @@ ], "responses": { "200": { - "description": "(streaming responses)", + "description": "A successful response.(streaming responses)", "schema": { "$ref": "#/definitions/etcdserverpbWatchResponse" } @@ -1286,10 +1367,12 @@ "type": "object", "properties": { "key": { - "type": "string" + "type": "string", + "format": "byte" }, "range_end": { - "type": "string" + "type": "string", + "format": "byte" }, "role": { "type": "string" @@ -2017,7 +2100,7 @@ "format": "int64" }, "min_create_revision": { - "description": "min_create_revision is the lower bound for returned key create revisions; all keys with\nlesser create trevisions will be filtered away.", + "description": "min_create_revision is the lower bound for returned key create revisions; all keys with\nlesser create revisions will be filtered away.", "type": "string", "format": "int64" }, @@ -2112,7 +2195,7 @@ "format": "uint64" }, "revision": { - "description": "revision is the key-value store revision when the request was applied.", + "description": "revision is the key-value store revision when the request was applied.\nFor watch progress responses, the header.revision indicates progress. All future events\nrecieved in this stream are guaranteed to have a higher revision number than the\nheader.revision number.", "type": "string", "format": "int64" } @@ -2164,10 +2247,22 @@ "type": "object", "properties": { "dbSize": { - "description": "dbSize is the size of the backend database, in bytes, of the responding member.", + "description": "dbSize is the size of the backend database physically allocated, in bytes, of the responding member.", "type": "string", "format": "int64" }, + "dbSizeInUse": { + "description": "dbSizeInUse is the size of the backend database logically in use, in bytes, of the responding member.", + "type": "string", + "format": "int64" + }, + "errors": { + "description": "errors contains alarm/health information and status.", + "type": "array", + "items": { + "type": "string" + } + }, "header": { "$ref": "#/definitions/etcdserverpbResponseHeader" }, @@ -2176,8 +2271,13 @@ "type": "string", "format": "uint64" }, + "raftAppliedIndex": { + "description": "raftAppliedIndex is the current raft applied index of the responding member.", + "type": "string", + "format": "uint64" + }, "raftIndex": { - "description": "raftIndex is the current raft index of the responding member.", + "description": "raftIndex is the current raft committed index of the responding member.", "type": "string", "format": "uint64" }, @@ -2259,6 +2359,11 @@ "$ref": "#/definitions/WatchCreateRequestFilterType" } }, + "fragment": { + "description": "fragment enables splitting large revisions into multiple watch responses.", + "type": "boolean", + "format": "boolean" + }, "key": { "description": "key is the key to register for watching.", "type": "string", @@ -2283,9 +2388,18 @@ "description": "start_revision is an optional revision to watch from (inclusive). No start_revision is \"now\".", "type": "string", "format": "int64" + }, + "watch_id": { + "description": "If watch_id is provided and non-zero, it will be assigned to this watcher.\nSince creating a watcher in etcd is not a synchronous operation,\nthis can be used ensure that ordering is correct when creating multiple\nwatchers on the same stream. Creating a watcher with an ID already in\nuse on the stream will cause an error to be returned.", + "type": "string", + "format": "int64" } } }, + "etcdserverpbWatchProgressRequest": { + "description": "Requests the a watch stream progress status be sent in the watch response stream as soon as\npossible.", + "type": "object" + }, "etcdserverpbWatchRequest": { "type": "object", "properties": { @@ -2294,6 +2408,9 @@ }, "create_request": { "$ref": "#/definitions/etcdserverpbWatchCreateRequest" + }, + "progress_request": { + "$ref": "#/definitions/etcdserverpbWatchProgressRequest" } } }, @@ -2325,6 +2442,11 @@ "$ref": "#/definitions/mvccpbEvent" } }, + "fragment": { + "description": "framgment is true if large watch response was split over multiple responses.", + "type": "boolean", + "format": "boolean" + }, "header": { "$ref": "#/definitions/etcdserverpbResponseHeader" }, diff --git a/Documentation/dev-guide/apispec/swagger/v3election.swagger.json b/Documentation/dev-guide/apispec/swagger/v3election.swagger.json index a479e7cd2..b0d33ad08 100644 --- a/Documentation/dev-guide/apispec/swagger/v3election.swagger.json +++ b/Documentation/dev-guide/apispec/swagger/v3election.swagger.json @@ -15,13 +15,13 @@ "application/json" ], "paths": { - "/v3beta/election/campaign": { + "/v3/election/campaign": { "post": { "summary": "Campaign waits to acquire leadership in an election, returning a LeaderKey\nrepresenting the leadership if successful. The LeaderKey can then be used\nto issue new values on the election, transactionally guard API requests on\nleadership still being held, and resign from the election.", "operationId": "Campaign", "responses": { "200": { - "description": "", + "description": "A successful response.", "schema": { "$ref": "#/definitions/v3electionpbCampaignResponse" } @@ -42,13 +42,13 @@ ] } }, - "/v3beta/election/leader": { + "/v3/election/leader": { "post": { "summary": "Leader returns the current election proclamation, if any.", "operationId": "Leader", "responses": { "200": { - "description": "", + "description": "A successful response.", "schema": { "$ref": "#/definitions/v3electionpbLeaderResponse" } @@ -69,13 +69,13 @@ ] } }, - "/v3beta/election/observe": { + "/v3/election/observe": { "post": { "summary": "Observe streams election proclamations in-order as made by the election's\nelected leaders.", "operationId": "Observe", "responses": { "200": { - "description": "(streaming responses)", + "description": "A successful response.(streaming responses)", "schema": { "$ref": "#/definitions/v3electionpbLeaderResponse" } @@ -96,13 +96,13 @@ ] } }, - "/v3beta/election/proclaim": { + "/v3/election/proclaim": { "post": { "summary": "Proclaim updates the leader's posted value with a new value.", "operationId": "Proclaim", "responses": { "200": { - "description": "", + "description": "A successful response.", "schema": { "$ref": "#/definitions/v3electionpbProclaimResponse" } @@ -123,13 +123,13 @@ ] } }, - "/v3beta/election/resign": { + "/v3/election/resign": { "post": { "summary": "Resign releases election leadership so other campaigners may acquire\nleadership on the election.", "operationId": "Resign", "responses": { "200": { - "description": "", + "description": "A successful response.", "schema": { "$ref": "#/definitions/v3electionpbResignResponse" } @@ -168,7 +168,7 @@ "revision": { "type": "string", "format": "int64", - "description": "revision is the key-value store revision when the request was applied." + "description": "revision is the key-value store revision when the request was applied.\nFor watch progress responses, the header.revision indicates progress. All future events\nrecieved in this stream are guaranteed to have a higher revision number than the\nheader.revision number." }, "raft_term": { "type": "string", diff --git a/Documentation/dev-guide/apispec/swagger/v3lock.swagger.json b/Documentation/dev-guide/apispec/swagger/v3lock.swagger.json index 464f7a071..45a826150 100644 --- a/Documentation/dev-guide/apispec/swagger/v3lock.swagger.json +++ b/Documentation/dev-guide/apispec/swagger/v3lock.swagger.json @@ -15,13 +15,13 @@ "application/json" ], "paths": { - "/v3beta/lock/lock": { + "/v3/lock/lock": { "post": { "summary": "Lock acquires a distributed shared lock on a given named lock.\nOn success, it will return a unique key that exists so long as the\nlock is held by the caller. This key can be used in conjunction with\ntransactions to safely ensure updates to etcd only occur while holding\nlock ownership. The lock is held until Unlock is called on the key or the\nlease associate with the owner expires.", "operationId": "Lock", "responses": { "200": { - "description": "", + "description": "A successful response.", "schema": { "$ref": "#/definitions/v3lockpbLockResponse" } @@ -42,13 +42,13 @@ ] } }, - "/v3beta/lock/unlock": { + "/v3/lock/unlock": { "post": { "summary": "Unlock takes a key returned by Lock and releases the hold on lock. The\nnext Lock caller waiting for the lock will then be woken up and given\nownership of the lock.", "operationId": "Unlock", "responses": { "200": { - "description": "", + "description": "A successful response.", "schema": { "$ref": "#/definitions/v3lockpbUnlockResponse" } @@ -87,7 +87,7 @@ "revision": { "type": "string", "format": "int64", - "description": "revision is the key-value store revision when the request was applied." + "description": "revision is the key-value store revision when the request was applied.\nFor watch progress responses, the header.revision indicates progress. All future events\nrecieved in this stream are guaranteed to have a higher revision number than the\nheader.revision number." }, "raft_term": { "type": "string", @@ -107,7 +107,7 @@ "lease": { "type": "string", "format": "int64", - "description": "lease is the ID of the lease that will be attached to ownership of the\nlock. If the lease expires or is revoked and currently holds the lock,\nthe lock is automatically released. Calls to Lock with the same lease will\nbe treated as a single acquistion; locking twice with the same lease is a\nno-op." + "description": "lease is the ID of the lease that will be attached to ownership of the\nlock. If the lease expires or is revoked and currently holds the lock,\nthe lock is automatically released. Calls to Lock with the same lease will\nbe treated as a single acquisition; locking twice with the same lease is a\nno-op." } } }, diff --git a/Documentation/dev-guide/experimental_apis.md b/Documentation/dev-guide/experimental_apis.md index dde2f09d6..aba974208 100644 --- a/Documentation/dev-guide/experimental_apis.md +++ b/Documentation/dev-guide/experimental_apis.md @@ -1,7 +1,9 @@ -# Experimental APIs and features +--- +title: Experimental APIs and features +--- For the most part, the etcd project is stable, but we are still moving fast! We believe in the release fast philosophy. We want to get early feedback on features still in development and stabilizing. Thus, there are, and will be more, experimental features and APIs. We plan to improve these features based on the early feedback from the community, or abandon them if there is little interest, in the next few releases. Please do not rely on any experimental features or APIs in production environment. ## The current experimental API/features are: -- [KV ordering](https://godoc.org/github.com/coreos/etcd/clientv3/ordering) wrapper. When an etcd client switches endpoints, responses to serializable reads may go backward in time if the new endpoint is lagging behind the rest of the cluster. The ordering wrapper caches the current cluster revision from response headers. If a response revision is less than the cached revision, the client selects another endpoint and reissues the read. Enable in grpcproxy with `--experimental-serializable-ordering`. +- [KV ordering](https://godoc.org/github.com/etcd-io/etcd/clientv3/ordering) wrapper. When an etcd client switches endpoints, responses to serializable reads may go backward in time if the new endpoint is lagging behind the rest of the cluster. The ordering wrapper caches the current cluster revision from response headers. If a response revision is less than the cached revision, the client selects another endpoint and reissues the read. Enable in grpcproxy with `--experimental-serializable-ordering`. diff --git a/Documentation/dev-guide/grpc_naming.md b/Documentation/dev-guide/grpc_naming.md index 4662d6ee7..77287c6e1 100644 --- a/Documentation/dev-guide/grpc_naming.md +++ b/Documentation/dev-guide/grpc_naming.md @@ -1,4 +1,6 @@ -# gRPC naming and discovery +--- +title: gRPC naming and discovery +--- etcd provides a gRPC resolver to support an alternative name system that fetches endpoints from etcd for discovering gRPC services. The underlying mechanism is based on watching updates to keys prefixed with the service name. @@ -8,8 +10,8 @@ The etcd client provides a gRPC resolver for resolving gRPC endpoints with an et ```go import ( - "github.com/coreos/etcd/clientv3" - etcdnaming "github.com/coreos/etcd/clientv3/naming" + "go.etcd.io/etcd/clientv3" + etcdnaming "go.etcd.io/etcd/clientv3/naming" "google.golang.org/grpc" ) @@ -19,7 +21,7 @@ import ( cli, cerr := clientv3.NewFromURL("http://localhost:2379") r := &etcdnaming.GRPCResolver{Client: cli} b := grpc.RoundRobin(r) -conn, gerr := grpc.Dial("my-service", grpc.WithBalancer(b)) +conn, gerr := grpc.Dial("my-service", grpc.WithBalancer(b), grpc.WithBlock(), ...) ``` ## Managing service endpoints diff --git a/Documentation/dev-guide/interacting_v3.md b/Documentation/dev-guide/interacting_v3.md index 2f01aae86..3638cd30b 100644 --- a/Documentation/dev-guide/interacting_v3.md +++ b/Documentation/dev-guide/interacting_v3.md @@ -1,8 +1,12 @@ -# Interacting with etcd +--- +title: Interacting with etcd +--- Users mostly interact with etcd by putting or getting the value of a key. This section describes how to do that by using etcdctl, a command line tool for interacting with etcd server. The concepts described here should apply to the gRPC APIs or client library APIs. -By default, etcdctl talks to the etcd server with the v2 API for backward compatibility. For etcdctl to speak to etcd using the v3 API, the API version must be set to version 3 via the `ETCDCTL_API` environment variable. However note that any key that was created using the v2 API will not be able to be queried via the v3 API. A v3 API ```etcdctl get``` of a v2 key will exit with 0 and no key data, this is the expected behaviour. +The API version used by etcdctl to speak to etcd may be set to version `2` or `3` via the `ETCDCTL_API` environment variable. By default, etcdctl on master (3.4) uses the v3 API and earlier versions (3.3 and earlier) default to the v2 API. + +Note that any key that was created using the v2 API will not be able to be queried via the v2 API. A v3 API ```etcdctl get``` of a v2 key will exit with 0 and no key data, this is the expected behaviour. ```bash @@ -355,6 +359,26 @@ foo # key bar_latest # value of foo key after modification ``` +## Watch progress + +Applications may want to check the progress of a watch to determine how up-to-date the watch stream is. For example, if a watch is used to update a cache, it can be useful to know if the cache is stale compared to the revision from a quorum read. + +Progress requests can be issued using the "progress" command in interactive watch session to ask the etcd server to send a progress notify update in the watch stream: + +```bash +$ etcdctl watch -i +$ watch a +$ progress +progress notify: 1 +# in another terminal: etcdctl put x 0 +# in another terminal: etcdctl put y 1 +$ progress +progress notify: 3 +``` + +Note: The revision number in the progress notify response is the revision from the local etcd server node that the watch stream is connected to. If this node is partitioned and not part of quorum, this progress notify revision might be lower than +than the revision returned by a quorum read against a non-partitioned etcd server node. + ## Compacted revisions As we mentioned, etcd keeps revisions so that applications can read past versions of keys. However, to avoid accumulating an unbounded amount of history, it is important to compact past revisions. After compacting, etcd removes historical revisions, releasing resources for future use. All superseded data with revisions before the compacted revision will be unavailable. diff --git a/Documentation/dev-guide/limit.md b/Documentation/dev-guide/limit.md index 207b16700..0dfeca72f 100644 --- a/Documentation/dev-guide/limit.md +++ b/Documentation/dev-guide/limit.md @@ -1,8 +1,10 @@ -# System limits +--- +title: System limits +--- ## Request size limit -etcd is designed to handle small key value pairs typical for metadata. Larger requests will work, but may increase the latency of other requests. For the time being, etcd guarantees to support RPC requests with up to 1MB of data. In the future, the size limit may be loosened or made configurable. +etcd is designed to handle small key value pairs typical for metadata. Larger requests will work, but may increase the latency of other requests. By default, the maximum size of any request is 1.5 MiB. This limit is configurable through `--max-request-bytes` flag for etcd server. ## Storage size limit diff --git a/Documentation/dev-guide/local_cluster.md b/Documentation/dev-guide/local_cluster.md index 92ed1bc22..f41890830 100644 --- a/Documentation/dev-guide/local_cluster.md +++ b/Documentation/dev-guide/local_cluster.md @@ -1,4 +1,6 @@ -# Set up a local cluster +--- +title: Set up a local cluster +--- For testing and development deployments, the quickest and easiest way is to configure a local cluster. For a production deployment, refer to the [clustering][clustering] section. @@ -21,14 +23,7 @@ The running etcd member listens on `localhost:2379` for client requests. Use `etcdctl` to interact with the running cluster: -1. Configure the environment to have `ETCDCTL_API=3` so `etcdctl` uses the etcd API version 3 instead of defaulting to version 2. - - ``` - # use API version 3 - $ export ETCDCTL_API=3 - ``` - -2. Store an example key-value pair in the cluster: +1. Store an example key-value pair in the cluster: ``` $ ./etcdctl put foo bar @@ -37,7 +32,7 @@ Use `etcdctl` to interact with the running cluster: If OK is printed, storing key-value pair is successful. -3. Retrieve the value of `foo`: +2. Retrieve the value of `foo`: ``` $ ./etcdctl get foo @@ -70,14 +65,7 @@ A `Procfile` at the base of the etcd git repository is provided to easily config Use `etcdctl` to interact with the running cluster: -1. Configure the environment to have `ETCDCTL_API=3` so `etcdctl` uses the etcd API version 3 instead of defaulting to version 2. - - ``` - # use API version 3 - $ export ETCDCTL_API=3 - ``` - -2. Print the list of members: +1. Print the list of members: ``` $ etcdctl --write-out=table --endpoints=localhost:2379 member list @@ -94,7 +82,7 @@ Use `etcdctl` to interact with the running cluster: +------------------+---------+--------+------------------------+------------------------+ ``` -3. Store an example key-value pair in the cluster: +2. Store an example key-value pair in the cluster: ``` $ etcdctl put foo bar diff --git a/Documentation/dev-internal/discovery_protocol.md b/Documentation/dev-internal/discovery_protocol.md index 34da2b2c8..cbe3a467a 100644 --- a/Documentation/dev-internal/discovery_protocol.md +++ b/Documentation/dev-internal/discovery_protocol.md @@ -1,4 +1,6 @@ -# Discovery service protocol +--- +title: Discovery service protocol +--- Discovery service protocol helps new etcd member to discover all other members in cluster bootstrap phase using a shared discovery URL. diff --git a/Documentation/dev-internal/logging.md b/Documentation/dev-internal/logging.md index aa97dc2b5..ef0acd355 100644 --- a/Documentation/dev-internal/logging.md +++ b/Documentation/dev-internal/logging.md @@ -1,4 +1,6 @@ -# Logging conventions +--- +title: Logging conventions +--- etcd uses the [capnslog][capnslog] library for logging application output categorized into *levels*. A log message's level is determined according to these conventions: diff --git a/Documentation/dev-internal/release.md b/Documentation/dev-internal/release.md index 8cec2c830..97aeb1722 100644 --- a/Documentation/dev-internal/release.md +++ b/Documentation/dev-internal/release.md @@ -1,4 +1,6 @@ -# etcd release guide +--- +title: etcd release guide +--- The guide talks about how to release a new version of etcd. @@ -13,7 +15,8 @@ release and for ensuring the stability of the release branch. | Releases | Manager | | -------- | ------- | | 3.1 patch (post 3.1.0) | Joe Betz [@jpbetz](https://github.com/jpbetz) | -| 3.2 patch (post 3.2.0) | Gyuho Lee [@gyuho](https://github.com/gyuho) | +| 3.2 patch (post 3.2.0) | Joe Betz [@jpbetz](https://github.com/jpbetz) | +| 3.3 patch (post 3.3.0) | Gyuho Lee [@gyuho](https://github.com/gyuho) | ## Prepare release @@ -29,9 +32,9 @@ All releases version numbers follow the format of [semantic versioning 2.0.0](ht ### Major, minor version release, or its pre-release - Ensure the relevant milestone on GitHub is complete. All referenced issues should be closed, or moved elsewhere. -- Remove this release from [roadmap](https://github.com/coreos/etcd/blob/master/ROADMAP.md), if necessary. +- Remove this release from [roadmap](https://github.com/etcd-io/etcd/blob/master/ROADMAP.md), if necessary. - Ensure the latest upgrade documentation is available. -- Bump [hardcoded MinClusterVerion in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L29), if necessary. +- Bump [hardcoded MinClusterVerion in the repository](https://github.com/etcd-io/etcd/blob/master/version/version.go#L29), if necessary. - Add feature capability maps for the new version, if necessary. ### Patch version release @@ -49,14 +52,14 @@ All releases version numbers follow the format of [semantic versioning 2.0.0](ht ## Tag version -- Bump [hardcoded Version in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L30) to the latest version `${VERSION}`. +- Bump [hardcoded Version in the repository](https://github.com/etcd-io/etcd/blob/master/version/version.go#L30) to the latest version `${VERSION}`. - Ensure all tests on CI system are passed. - Manually check etcd is buildable in Linux, Darwin and Windows. - Manually check upgrade etcd cluster of previous minor version works well. - Manually check new features work well. - Add a signed tag through `git tag -s ${VERSION}`. - Sanity check tag correctness through `git show tags/$VERSION`. -- Push the tag to GitHub through `git push origin tags/$VERSION`. This assumes `origin` corresponds to "https://github.com/coreos/etcd". +- Push the tag to GitHub through `git push origin tags/$VERSION`. This assumes `origin` corresponds to "https://github.com/etcd-io/etcd". ## Build release binaries and images @@ -79,15 +82,15 @@ The following commands are used for public release sign: ``` cd release -for i in etcd-*{.zip,.tar.gz,.aci}; do gpg2 --default-key $SUBKEYID --armor --output ${i}.asc --detach-sign ${i}; done -for i in etcd-*{.zip,.tar.gz,.aci}; do gpg2 --verify ${i}.asc ${i}; done +for i in etcd-*{.zip,.tar.gz}; do gpg2 --default-key $SUBKEYID --armor --output ${i}.asc --detach-sign ${i}; done +for i in etcd-*{.zip,.tar.gz}; do gpg2 --verify ${i}.asc ${i}; done # sign zipped source code files -wget https://github.com/coreos/etcd/archive/${VERSION}.zip +wget https://github.com/etcd-io/etcd/archive/${VERSION}.zip gpg2 --armor --default-key $SUBKEYID --output ${VERSION}.zip.asc --detach-sign ${VERSION}.zip gpg2 --verify ${VERSION}.zip.asc ${VERSION}.zip -wget https://github.com/coreos/etcd/archive/${VERSION}.tar.gz +wget https://github.com/etcd-io/etcd/archive/${VERSION}.tar.gz gpg2 --armor --default-key $SUBKEYID --output ${VERSION}.tar.gz.asc --detach-sign ${VERSION}.tar.gz gpg2 --verify ${VERSION}.tar.gz.asc ${VERSION}.tar.gz ``` @@ -99,7 +102,7 @@ The public key for GPG signing can be found at [CoreOS Application Signing Key]( - Set release title as the version name. - Follow the format of previous release pages. -- Attach the generated binaries, aci image and signatures. +- Attach the generated binaries and signatures. - Select whether it is a pre-release. - Publish the release! @@ -155,5 +158,5 @@ git log ...${PREV_VERSION} --pretty=format:"%an" | sort | uniq | tr '\n' ',' | s ## Post release -- Create new stable branch through `git push origin ${VERSION_MAJOR}.${VERSION_MINOR}` if this is a major stable release. This assumes `origin` corresponds to "https://github.com/coreos/etcd". -- Bump [hardcoded Version in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L30) to the version `${VERSION}+git`. +- Create new stable branch through `git push origin ${VERSION_MAJOR}.${VERSION_MINOR}` if this is a major stable release. This assumes `origin` corresponds to "https://github.com/etcd-io/etcd". +- Bump [hardcoded Version in the repository](https://github.com/etcd-io/etcd/blob/master/version/version.go#L30) to the version `${VERSION}+git`. diff --git a/Documentation/dl_build.md b/Documentation/dl_build.md index ee5877c36..9787c52e5 100644 --- a/Documentation/dl_build.md +++ b/Documentation/dl_build.md @@ -1,4 +1,7 @@ -# Download and build +--- +title: Download and build +weight: 1 +--- ## System requirements @@ -15,7 +18,7 @@ For those wanting to try the very latest version, build etcd from the `master` b To build `etcd` from the `master` branch without a `GOPATH` using the official `build` script: ```sh -$ git clone https://github.com/coreos/etcd.git +$ git clone https://github.com/etcd-io/etcd.git $ cd etcd $ ./build ``` @@ -26,16 +29,8 @@ To build a vendored `etcd` from the `master` branch via `go get`: # GOPATH should be set $ echo $GOPATH /Users/example/go -$ go get github.com/coreos/etcd/cmd/etcd -``` - -To build `etcd` from the `master` branch without vendoring (may not build due to upstream conflicts): - -```sh -# GOPATH should be set -$ echo $GOPATH -/Users/example/go -$ go get github.com/coreos/etcd +$ go get -v go.etcd.io/etcd +$ go get -v go.etcd.io/etcd/etcdctl ``` ## Test the installation @@ -44,14 +39,14 @@ Check the etcd binary is built correctly by starting etcd and setting a key. ### Starting etcd -If etcd is built without using GOPATH, run the following: +If etcd is built without using `go get`, run the following: -``` +```sh $ ./bin/etcd ``` -If etcd is built using GOPATH, run the following: +If etcd is built using `go get`, run the following: -``` +```sh $ $GOPATH/bin/etcd ``` @@ -59,14 +54,16 @@ $ $GOPATH/bin/etcd Run the following: -``` -$ ETCDCTL_API=3 ./bin/etcdctl put foo bar +```sh +$ ./bin/etcdctl put foo bar OK ``` +(or `$GOPATH/bin/etcdctl put foo bar` if etcdctl was installed with `go get`) + If OK is printed, then etcd is working! -[github-release]: https://github.com/coreos/etcd/releases/ +[github-release]: https://github.com/etcd-io/etcd/releases/ [go]: https://golang.org/doc/install [build-script]: ../build [cmd-directory]: ../cmd diff --git a/Documentation/docs.md b/Documentation/docs.md deleted file mode 100644 index 0f9b6c1a4..000000000 --- a/Documentation/docs.md +++ /dev/null @@ -1,114 +0,0 @@ -# Documentation - -etcd is a distributed key-value store designed to reliably and quickly preserve and provide access to critical data. It enables reliable distributed coordination through distributed locking, leader elections, and write barriers. An etcd cluster is intended for high availability and permanent data storage and retrieval. - -## Getting started - -New etcd users and developers should get started by [downloading and building][download_build] etcd. After getting etcd, follow this [quick demo][demo] to see the basics of creating and working with an etcd cluster. - -## Developing with etcd - -The easiest way to get started using etcd as a distributed key-value store is to [set up a local cluster][local_cluster]. - - - [Setting up local clusters][local_cluster] - - [Interacting with etcd][interacting] - - gRPC [etcd core][api_ref] and [etcd concurrency][api_concurrency_ref] API references - - [HTTP JSON API through the gRPC gateway][api_grpc_gateway] - - [gRPC naming and discovery][grpc_naming] - - [Client][namespace_client] and [proxy][namespace_proxy] namespacing - - [Embedding etcd][embed_etcd] - - [Experimental features and APIs][experimental] - - [System limits][system-limit] - -## Operating etcd clusters - -Administrators who need a fault-tolerant etcd cluster for either development or production should begin with a [cluster on multiple machines][clustering]. - -### Setting up etcd - - - [Configuration flags][conf] - - [Multi-member cluster][clustering] - - [gRPC proxy][grpc_proxy] - - [L4 gateway][gateway] - -### System configuration - - - [Supported systems][supported_platforms] - - [Hardware recommendations][hardware] - - [Performance benchmarking][performance] - - [Tuning][tuning] - -### Platform guides - - - [Amazon Web Services][aws_platform] - - [Container Linux, systemd][container_linux_platform] - - [FreeBSD][freebsd_platform] - - [Docker container][container_docker] - - [rkt container][container_rkt] - -### Security - - - [TLS][security] - - [Role-based access control][authentication] - -### Maintenance and troubleshooting - - - [Frequently asked questions][faq] - - [Monitoring][monitoring] - - [Maintenance][maintenance] - - [Failure modes][failures] - - [Disaster recovery][recovery] - - [Upgrading][upgrading] - -## Learning - -To learn more about the concepts and internals behind etcd, read the following pages: - - - [Why etcd?][why] - - [Understand data model][data_model] - - [Understand APIs][understand_apis] - - [Glossary][glossary] - - Internals - - [Auth subsystem][auth_design] - -[api_ref]: dev-guide/api_reference_v3.md -[api_concurrency_ref]: dev-guide/api_concurrency_reference_v3.md -[api_grpc_gateway]: dev-guide/api_grpc_gateway.md -[clustering]: op-guide/clustering.md -[conf]: op-guide/configuration.md -[system-limit]: dev-guide/limit.md -[faq]: faq.md -[why]: learning/why.md -[data_model]: learning/data_model.md -[demo]: demo.md -[download_build]: dl_build.md -[embed_etcd]: https://godoc.org/github.com/coreos/etcd/embed -[grpc_naming]: dev-guide/grpc_naming.md -[failures]: op-guide/failures.md -[gateway]: op-guide/gateway.md -[glossary]: learning/glossary.md -[namespace_client]: https://godoc.org/github.com/coreos/etcd/clientv3/namespace -[namespace_proxy]: op-guide/grpc_proxy.md#namespacing -[grpc_proxy]: op-guide/grpc_proxy.md -[hardware]: op-guide/hardware.md -[interacting]: dev-guide/interacting_v3.md -[local_cluster]: dev-guide/local_cluster.md -[performance]: op-guide/performance.md -[recovery]: op-guide/recovery.md -[maintenance]: op-guide/maintenance.md -[security]: op-guide/security.md -[monitoring]: op-guide/monitoring.md -[v2_migration]: op-guide/v2-migration.md -[container_rkt]: op-guide/container.md#rkt -[container_docker]: op-guide/container.md#docker -[understand_apis]: learning/api.md -[versioning]: op-guide/versioning.md -[supported_platforms]: op-guide/supported-platform.md -[container_linux_platform]: platforms/container-linux-systemd.md -[freebsd_platform]: platforms/freebsd.md -[aws_platform]: platforms/aws.md -[experimental]: dev-guide/experimental_apis.md -[authentication]: op-guide/authentication.md -[auth_design]: learning/auth_design.md -[tuning]: tuning.md -[upgrading]: upgrades/upgrading-etcd.md diff --git a/Documentation/faq.md b/Documentation/faq.md index 4078407e7..f89f23422 100644 --- a/Documentation/faq.md +++ b/Documentation/faq.md @@ -1,4 +1,6 @@ -# Frequently Asked Questions (FAQ) +--- +title: Frequently Asked Questions (FAQ) +--- ## etcd, general @@ -106,7 +108,7 @@ To recover from the low space quota alarm: This is gRPC-side warning when a server receives a TCP RST flag with client-side streams being prematurely closed. For example, a client closes its connection, while gRPC server has not yet processed all HTTP/2 frames in the TCP queue. Some data may have been lost in server side, but it is ok so long as client connection has already been closed. -Only [old versions of gRPC](https://github.com/grpc/grpc-go/issues/1362) log this. etcd [>=v3.2.13 by default log this with DEBUG level](https://github.com/coreos/etcd/pull/9080), thus only visible with `--debug` flag enabled. +Only [old versions of gRPC](https://github.com/grpc/grpc-go/issues/1362) log this. etcd [>=v3.2.13 by default log this with DEBUG level](https://github.com/etcd-io/etcd/pull/9080), thus only visible with `--debug` flag enabled. ## Performance @@ -147,14 +149,14 @@ etcd sends a snapshot of its complete key-value store to refresh slow followers [supported-platform]: ./op-guide/supported-platform.md [wal_fsync_duration_seconds]: ./metrics.md#disk [tuning]: ./tuning.md -[new_issue]: https://github.com/coreos/etcd/issues/new +[new_issue]: https://github.com/etcd-io/etcd/issues/new [backend_commit_metrics]: ./metrics.md#disk [raft]: https://raft.github.io/raft.pdf -[backup]: https://github.com/coreos/etcd/blob/master/Documentation/op-guide/recovery.md#snapshotting-the-keyspace +[backup]: https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/recovery.md#snapshotting-the-keyspace [chubby]: http://static.googleusercontent.com/media/research.google.com/en//archive/chubby-osdi06.pdf -[runtime reconfiguration]: https://github.com/coreos/etcd/blob/master/Documentation/op-guide/runtime-configuration.md +[runtime reconfiguration]: https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/runtime-configuration.md [benchmark]: https://github.com/coreos/etcd/tree/master/tools/benchmark -[benchmark-result]: https://github.com/coreos/etcd/blob/master/Documentation/op-guide/performance.md +[benchmark-result]: https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/performance.md [api-mvcc]: learning/api.md#revisions [maintenance-compact]: op-guide/maintenance.md#history-compaction [maintenance-defragment]: op-guide/maintenance.md#defragmentation diff --git a/Documentation/integrations.md b/Documentation/integrations.md index 11722cf09..8c2ed5b5f 100644 --- a/Documentation/integrations.md +++ b/Documentation/integrations.md @@ -1,8 +1,11 @@ -# Libraries and tools +--- +title: Libraries and tools +weight: 2 +--- **Tools** -- [etcdctl](https://github.com/coreos/etcd/tree/master/etcdctl) - A command line client for etcd +- [etcdctl](https://github.com/etcd-io/etcd/tree/master/etcdctl) - A command line client for etcd - [etcd-backup](https://github.com/fanhattan/etcd-backup) - A powerful command line utility for dumping/restoring etcd - Supports v2 - [etcd-dump](https://npmjs.org/package/etcd-dump) - Command line utility for dumping/restoring etcd. - [etcd-fs](https://github.com/xetorthio/etcd-fs) - FUSE filesystem for etcd @@ -15,17 +18,18 @@ - [etcd-rest](https://github.com/mickep76/etcd-rest) - Create generic REST API in Go using etcd as a backend with validation using JSON schema - [etcdsh](https://github.com/kamilhark/etcdsh) - A command line client with support of command history and tab completion. Supports v2 - [etcdloadtest](https://github.com/sinsharat/etcdloadtest) - A command line load test client for etcd version 3.0 and above. +- [lucas](https://github.com/ringtail/lucas) - A web-based key-value viewer for kubernetes etcd3.0+ cluster. **Go libraries** -- [etcd/clientv3](https://github.com/coreos/etcd/blob/master/clientv3) - the officially maintained Go client for v3 -- [etcd/client](https://github.com/coreos/etcd/blob/master/client) - the officially maintained Go client for v2 +- [etcd/clientv3](https://github.com/etcd-io/etcd/blob/master/clientv3) - the officially maintained Go client for v3 +- [etcd/client](https://github.com/etcd-io/etcd/blob/master/client) - the officially maintained Go client for v2 - [go-etcd](https://github.com/coreos/go-etcd) - the deprecated official client. May be useful for older (<2.0.0) versions of etcd. - [encWrapper](https://github.com/lumjjb/etcd/tree/enc_wrapper/clientwrap/encwrapper) - encWrapper is an encryption wrapper for the etcd client Keys API/KV. **Java libraries** -- [coreos/jetcd](https://github.com/coreos/jetcd) - Supports v3 +- [coreos/jetcd](https://github.com/etcd-io/jetcd) - Supports v3 - [boonproject/etcd](https://github.com/boonproject/boon/blob/master/etcd/README.md) - Supports v2, Async/Sync and waits - [justinsb/jetcd](https://github.com/justinsb/jetcd) - [diwakergupta/jetcd](https://github.com/diwakergupta/jetcd) - Supports v2 @@ -53,6 +57,7 @@ - [txaio-etcd](https://github.com/crossbario/txaio-etcd) - Asynchronous etcd v3-only client library for Twisted (today) and asyncio (future) - [dims/etcd3-gateway](https://github.com/dims/etcd3-gateway) - etcd v3 API library using the HTTP grpc gateway - [aioetcd3](https://github.com/gaopeiliang/aioetcd3) - (Python 3.6+) etcd v3 API for asyncio +- [Revolution1/etcd3-py](https://github.com/Revolution1/etcd3-py) - (python2.7 and python3.5+) Python client for etcd v3, using gRPC-JSON-Gateway **Node libraries** @@ -88,17 +93,20 @@ **Erlang libraries** -- [marshall-lee/etcd.erl](https://github.com/marshall-lee/etcd.erl) +- [marshall-lee/etcd.erl](https://github.com/marshall-lee/etcd.erl) - Supports v2 +- [zhongwencool/eetcd](https://github.com/zhongwencool/eetcd) - Supports v3+ (GRPC only) **.Net Libraries** - [wangjia184/etcdnet](https://github.com/wangjia184/etcdnet) - Supports v2 - [drusellers/etcetera](https://github.com/drusellers/etcetera) +- [shubhamranjan/dotnet-etcd](https://github.com/shubhamranjan/dotnet-etcd) - Supports v3+ (GRPC only) **PHP Libraries** - [linkorb/etcd-php](https://github.com/linkorb/etcd-php) - [activecollab/etcd](https://github.com/activecollab/etcd) +- [ouqiang/etcd-php](https://github.com/ouqiang/etcd-php) - Client for v3 gRPC gateway **Haskell libraries** @@ -138,6 +146,7 @@ - [cloudfoundry/cf-release](https://github.com/cloudfoundry/cf-release/tree/master/jobs/etcd) **Projects using etcd** + - [etcd Raft users](../raft/README.md#notable-users) - projects using etcd's raft library implementation. - [apache/celix](https://github.com/apache/celix) - an implementation of the OSGi specification adapted to C and C++ - [binocarlos/yoda](https://github.com/binocarlos/yoda) - etcd + ZeroMQ @@ -164,4 +173,9 @@ - [Vitess](http://vitess.io/) - Vitess is a database clustering system for horizontal scaling of MySQL. - [lclarkmichalek/etcdhcp](https://github.com/lclarkmichalek/etcdhcp) - DHCP server that uses etcd for persistence and coordination. - [openstack/networking-vpp](https://github.com/openstack/networking-vpp) - A networking driver that programs the [FD.io VPP dataplane](https://wiki.fd.io/view/VPP) to provide [OpenStack](https://www.openstack.org/) cloud virtual networking -- [openstack](https://github.com/openstack/governance/blob/master/reference/base-services.rst) - OpenStack services can rely on etcd as a base service. +- [OpenStack](https://github.com/openstack/governance/blob/master/reference/base-services.rst) - OpenStack services can rely on etcd as a base service. +- [CoreDNS](https://github.com/coredns/coredns/tree/master/plugin/etcd) - CoreDNS is a DNS server that chains plugins, part of CNCF and Kubernetes +- [Uber M3](https://github.com/m3db/m3) - M3: Uber’s Open Source, Large-scale Metrics Platform for Prometheus +- [Rook](https://github.com/rook/rook) - Storage Orchestration for Kubernetes +- [Patroni](https://github.com/zalando/patroni) - A template for PostgreSQL High Availability with ZooKeeper, etcd, or Consul +- [Trillian](https://github.com/google/trillian) - Trillian implements a Merkle tree whose contents are served from a data storage layer, to allow scalability to extremely large trees. diff --git a/Documentation/learning/_index.md b/Documentation/learning/_index.md new file mode 100644 index 000000000..acf1d0f06 --- /dev/null +++ b/Documentation/learning/_index.md @@ -0,0 +1,3 @@ +--- +title: Learning +--- \ No newline at end of file diff --git a/Documentation/learning/api.md b/Documentation/learning/api.md index a326b05e7..828c73eee 100644 --- a/Documentation/learning/api.md +++ b/Documentation/learning/api.md @@ -1,4 +1,6 @@ -# etcd3 API +--- +title: etcd3 API +--- This document is meant to give an overview of the etcd3 API's central design. It is by no means all encompassing, but intended to focus on the basic ideas needed to understand etcd without the distraction of less common API calls. All etcd3 API's are defined in [gRPC services][grpc-service], which categorize remote procedure calls (RPCs) understood by the etcd server. A full listing of all etcd RPCs are documented in markdown in the [gRPC API listing][grpc-api]. @@ -472,10 +474,10 @@ message LeaseKeepAliveResponse { * ID - the lease that was refreshed with a new TTL. * TTL - the new time-to-live, in seconds, that the lease has remaining. -[elections]: https://github.com/coreos/etcd/blob/master/clientv3/concurrency/election.go -[kv-proto]: https://github.com/coreos/etcd/blob/master/mvcc/mvccpb/kv.proto +[elections]: https://github.com/etcd-io/etcd/blob/master/clientv3/concurrency/election.go +[kv-proto]: https://github.com/etcd-io/etcd/blob/master/mvcc/mvccpb/kv.proto [grpc-api]: ../dev-guide/api_reference_v3.md -[grpc-service]: https://github.com/coreos/etcd/blob/master/etcdserver/etcdserverpb/rpc.proto -[locks]: https://github.com/coreos/etcd/blob/master/clientv3/concurrency/mutex.go +[grpc-service]: https://github.com/etcd-io/etcd/blob/master/etcdserver/etcdserverpb/rpc.proto +[locks]: https://github.com/etcd-io/etcd/blob/master/clientv3/concurrency/mutex.go [mvcc]: https://en.wikipedia.org/wiki/Multiversion_concurrency_control -[stm]: https://github.com/coreos/etcd/blob/master/clientv3/concurrency/stm.go +[stm]: https://github.com/etcd-io/etcd/blob/master/clientv3/concurrency/stm.go diff --git a/Documentation/learning/api_guarantees.md b/Documentation/learning/api_guarantees.md index 936e74138..5bcd6aa71 100644 --- a/Documentation/learning/api_guarantees.md +++ b/Documentation/learning/api_guarantees.md @@ -1,4 +1,6 @@ -# KV API guarantees +--- +title: KV API guarantees +--- etcd is a consistent and durable key value store with [mini-transaction][txn] support. The key value store is exposed through the KV APIs. etcd tries to ensure the strongest consistency and durability guarantees for a distributed system. This specification enumerates the KV API guarantees made by etcd. @@ -51,7 +53,7 @@ Linearizability (also known as Atomic Consistency or External Consistency) is a For linearizability, suppose each operation receives a timestamp from a loosely synchronized global clock. Operations are linearized if and only if they always complete as though they were executed in a sequential order and each operation appears to complete in the order specified by the program. Likewise, if an operation’s timestamp precedes another, that operation must also precede the other operation in the sequence. -For example, consider a client completing a write at time point 1 (*t1*). A client issuing a read at *t2* (for *t2* > *t1*) should receive a value at least as recent as the previous write, completed at *t1*. However, the read might actually complete only by *t3*, and the returned value, current at *t2* when the read began, might be "stale" by *t3*. +For example, consider a client completing a write at time point 1 (*t1*). A client issuing a read at *t2* (for *t2* > *t1*) should receive a value at least as recent as the previous write, completed at *t1*. However, the read might actually complete only by *t3*. Linearizability guarantees the read returns the most current value. Without linearizability guarantee, the returned value, current at *t2* when the read began, might be "stale" by *t3* because a concurrent write might happen between *t2* and *t3*. etcd does not ensure linearizability for watch operations. Users are expected to verify the revision of watch responses to ensure correct ordering. diff --git a/Documentation/learning/auth_design.md b/Documentation/learning/auth_design.md index 52c979731..acf3dd5f2 100644 --- a/Documentation/learning/auth_design.md +++ b/Documentation/learning/auth_design.md @@ -1,4 +1,6 @@ -# etcd v3 authentication design +--- +title: etcd v3 authentication design +--- ## Why not reuse the v2 auth system? @@ -26,7 +28,7 @@ The metadata for auth should also be stored and managed in the storage controlle The authentication mechanism in the etcd v2 protocol has a tricky part because the metadata consistency should work as in the above, but does not: each permission check is processed by the etcd member that receives the client request (etcdserver/api/v2http/client.go), including follower members. Therefore, it's possible the check may be based on stale metadata. -This staleness means that auth configuration cannot be reflected as soon as operators execute etcdctl. Therefore there is no way to know how long the stale metadata is active. Practically, the configuration change is reflected immediately after the command execution. However, in some cases of heavy load, the inconsistent state can be prolonged and it might result in counter-intuitive situations for users and developers. It requires a workaround like this: https://github.com/coreos/etcd/pull/4317#issuecomment-179037582 +This staleness means that auth configuration cannot be reflected as soon as operators execute etcdctl. Therefore there is no way to know how long the stale metadata is active. Practically, the configuration change is reflected immediately after the command execution. However, in some cases of heavy load, the inconsistent state can be prolonged and it might result in counter-intuitive situations for users and developers. It requires a workaround like this: https://github.com/etcd-io/etcd/pull/4317#issuecomment-179037582 ### Inconsistent permissions are unsafe for linearized requests @@ -38,7 +40,7 @@ Therefore, the permission checking logic should be added to the state machine of ### Authentication -At first, a client must create a gRPC connection only to authenticate its user ID and password. An etcd server will respond with an authentication reply. The reponse will be an authentication token on success or an error on failure. The client can use its authentication token to present its credentials to etcd when making API requests. +At first, a client must create a gRPC connection only to authenticate its user ID and password. An etcd server will respond with an authentication reply. The response will be an authentication token on success or an error on failure. The client can use its authentication token to present its credentials to etcd when making API requests. The client connection used to request the authentication token is typically thrown away; it cannot carry the new token's credentials. This is because gRPC doesn't provide a way for adding per RPC credential after creation of the connection (calling `grpc.Dial()`). Therefore, a client cannot assign a token to its connection that is obtained through the connection. The client needs a new connection for using the token. diff --git a/Documentation/learning/client-architecture.md b/Documentation/learning/client-architecture.md new file mode 100644 index 000000000..9ee21aa4e --- /dev/null +++ b/Documentation/learning/client-architecture.md @@ -0,0 +1,114 @@ +--- +title: etcd client architecture +weight: 1 +--- + +## Introduction + +etcd server has proven its robustness with years of failure injection testing. Most complex application logic is already handled by etcd server and its data stores (e.g. cluster membership is transparent to clients, with Raft-layer forwarding proposals to leader). Although server components are correct, its composition with client requires a different set of intricate protocols to guarantee its correctness and high availability under faulty conditions. Ideally, etcd server provides one logical cluster view of many physical machines, and client implements automatic failover between replicas. This documents client architectural decisions and its implementation details. + +## Glossary + +**clientv3** --- etcd Official Go client for etcd v3 API. + +**clientv3-grpc1.0** --- Official client implementation, with [grpc-go v1.0.x](https://github.com/grpc/grpc-go/releases/tag/v1.0.0), which is used in latest etcd v3.1. + +**clientv3-grpc1.7** --- Official client implementation, with [grpc-go v1.7.x](https://github.com/grpc/grpc-go/releases/tag/v1.7.0), which is used in latest etcd v3.2 and v3.3. + +**clientv3-grpc1.14** --- Official client implementation, with [grpc-go v1.14.x](https://github.com/grpc/grpc-go/releases/tag/v1.14.0), which is used in latest etcd v3.4. + +**Balancer** --- etcd client load balancer that implements retry and failover mechanism. etcd client should automatically balance loads between multiple endpoints. + +**Endpoints** --- A list of etcd server endpoints that clients can connect to. Typically, 3 or 5 client URLs of an etcd cluster. + +**Pinned endpoint** --- When configured with multiple endpoints, <= v3.3 client balancer chooses only one endpoint to establish a TCP connection, in order to conserve total open connections to etcd cluster. In v3.4, balancer round-robins pinned endpoints for every request, thus distributing loads more evenly. + +**Client Connection** --- TCP connection that has been established to an etcd server, via gRPC Dial. + +**Sub Connection** --- gRPC SubConn interface. Each sub-connection contains a list of addresses. Balancer creates a SubConn from a list of resolved addresses. gRPC ClientConn can map to multiple SubConn (e.g. example.com resolves to `10.10.10.1` and `10.10.10.2` of two sub-connections). etcd v3.4 balancer employs internal resolver to establish one sub-connection for each endpoint. + +**Transient disconnect** --- When gRPC server returns a status error of [code Unavailable](https://godoc.org/google.golang.org/grpc/codes#Code). + +## Client requirements + +**Correctness** --- Requests may fail in the presence of server faults. However, it never violates consistency guarantees: global ordering properties, never write corrupted data, at-most once semantics for mutable operations, watch never observes partial events, and so on. + +**Liveness** --- Servers may fail or disconnect briefly. Clients should make progress in either way. Clients should [never deadlock](https://github.com/etcd-io/etcd/issues/8980) waiting for a server to come back from offline, unless configured to do so. Ideally, clients detect unavailable servers with HTTP/2 ping and failover to other nodes with clear error messages. + +**Effectiveness** --- Clients should operate effectively with minimum resources: previous TCP connections should be [gracefully closed](https://github.com/etcd-io/etcd/issues/9212) after endpoint switch. Failover mechanism should effectively predict the next replica to connect, without wastefully retrying on failed nodes. + +**Portability** --- Official client should be clearly documented and its implementation be applicable to other language bindings. Error handling between different language bindings should be consistent. Since etcd is fully committed to gRPC, implementation should be closely aligned with gRPC long-term design goals (e.g. pluggable retry policy should be compatible with [gRPC retry](https://github.com/grpc/proposal/blob/master/A6-client-retries.md)). Upgrades between two client versions should be non-disruptive. + +## Client overview + +The etcd client implements the following components: + +* balancer that establishes gRPC connections to an etcd cluster, +* API client that sends RPCs to an etcd server, and +* error handler that decides whether to retry a failed request or switch endpoints. + +Languages may differ in how to establish an initial connection (e.g. configure TLS), how to encode and send Protocol Buffer messages to server, how to handle stream RPCs, and so on. However, errors returned from etcd server will be the same. So should be error handling and retry policy. + +For example, etcd server may return `"rpc error: code = Unavailable desc = etcdserver: request timed out"`, which is transient error that expects retries. Or return `rpc error: code = InvalidArgument desc = etcdserver: key is not provided`, which means request was invalid and should not be retried. Go client can parse errors with `google.golang.org/grpc/status.FromError`, and Java client with `io.grpc.Status.fromThrowable`. + +### clientv3-grpc1.0: Balancer Overview + +`clientv3-grpc1.0` maintains multiple TCP connections when configured with multiple etcd endpoints. Then pick one address and use it to send all client requests. The pinned address is maintained until the client object is closed (see *Figure 1*). When the client receives an error, it randomly picks another and retries. + +{{< figure src="/img/client-architecture-balancer-figure-01.png" >}} + +### clientv3-grpc1.0: Balancer Limitation + +`clientv3-grpc1.0` opening multiple TCP connections may provide faster balancer failover but requires more resources. The balancer does not understand node’s health status or cluster membership. So, it is possible that balancer gets stuck with one failed or partitioned node. + +### clientv3-grpc1.7: Balancer Overview + +`clientv3-grpc1.7` maintains only one TCP connection to a chosen etcd server. When given multiple cluster endpoints, a client first tries to connect to them all. As soon as one connection is up, balancer pins the address, closing others (see **Figure 2**). + +{{< figure src="/img/client-architecture-balancer-figure-02.png" >}} + +The pinned address is to be maintained until the client object is closed. An error, from server or client network fault, is sent to client error handler (see **Figure 3**). + +{{< figure src="/img/client-architecture-balancer-figure-03.png" >}} + +The client error handler takes an error from gRPC server, and decides whether to retry on the same endpoint, or to switch to other addresses, based on the error code and message (see **Figure 4** and **Figure 5**). + +{{< figure src="/img/client-architecture-balancer-figure-04.png" >}} + +{{< figure src="/img/client-architecture-balancer-figure-05.png" >}} + +Stream RPCs, such as Watch and KeepAlive, are often requested with no timeouts. Instead, client can send periodic HTTP/2 pings to check the status of a pinned endpoint; if the server does not respond to the ping, balancer switches to other endpoints (see **Figure 6**). + +{{< figure src="/img/client-architecture-balancer-figure-06.png" >}} + +### clientv3-grpc1.7: Balancer Limitation + +`clientv3-grpc1.7` balancer sends HTTP/2 keepalives to detect disconnects from streaming requests. It is a simple gRPC server ping mechanism and does not reason about cluster membership, thus unable to detect network partitions. Since partitioned gRPC server can still respond to client pings, balancer may get stuck with a partitioned node. Ideally, keepalive ping detects partition and triggers endpoint switch, before request time-out (see [issue #8673](https://github.com/etcd-io/etcd/issues/8673) and **Figure 7**). + +{{< figure src="/img/client-architecture-balancer-figure-07.png" >}} + +`clientv3-grpc1.7` balancer maintains a list of unhealthy endpoints. Disconnected addresses are added to “unhealthy” list, and considered unavailable until after wait duration, which is hard coded as dial timeout with default value 5-second. Balancer can have false positives on which endpoints are unhealthy. For instance, endpoint A may come back right after being blacklisted, but still unusable for next 5 seconds (see **Figure 8**). + +`clientv3-grpc1.0` suffered the same problems above. + +{{< figure src="/img/client-architecture-balancer-figure-08.png" >}} + +Upstream gRPC Go had already migrated to new balancer interface. For example, `clientv3-grpc1.7` underlying balancer implementation uses new gRPC balancer and tries to be consistent with old balancer behaviors. While its compatibility has been maintained reasonably well, etcd client still [suffered from subtle breaking changes](https://github.com/grpc/grpc-go/issues/1649). Furthermore, gRPC maintainer recommends [not relying on the old balancer interface](https://github.com/grpc/grpc-go/issues/1942#issuecomment-375368665). In general, to get better support from upstream, it is best to be in sync with latest gRPC releases. And new features, such as retry policy, may not be backported to gRPC 1.7 branch. Thus, both etcd server and client must migrate to latest gRPC versions. + +### clientv3-grpc1.14: Balancer Overview + +`clientv3-grpc1.7` is so tightly coupled with old gRPC interface, that every single gRPC dependency upgrade broke client behavior. Majority of development and debugging efforts were devoted to fixing those client behavior changes. As a result, its implementation has become overly complicated with bad assumptions on server connectivities. + +The primary goal of `clientv3-grpc1.14` is to simplify balancer failover logic; rather than maintaining a list of unhealthy endpoints, which may be stale, simply roundrobin to the next endpoint whenever client gets disconnected from the current endpoint. It does not assume endpoint status. Thus, no more complicated status tracking is needed (see *Figure 8* and above). Upgrading to `clientv3-grpc1.14` should be no issue; all changes were internal while keeping all the backward compatibilities. + +Internally, when given multiple endpoints, `clientv3-grpc1.14` creates multiple sub-connections (one sub-connection per each endpoint), while `clientv3-grpc1.7` creates only one connection to a pinned endpoint (see *Figure 9*). For instance, in 5-node cluster, `clientv3-grpc1.14` balancer would require 5 TCP connections, while `clientv3-grpc1.7` only requires one. By preserving the pool of TCP connections, `clientv3-grpc1.14` may consume more resources but provide more flexible load balancer with better failover performance. The default balancing policy is round robin but can be easily extended to support other types of balancers (e.g. power of two, pick leader, etc.). `clientv3-grpc1.14` uses gRPC resolver group and implements balancer picker policy, in order to delegate complex balancing work to upstream gRPC. On the other hand, `clientv3-grpc1.7` manually handles each gRPC connection and balancer failover, which complicates the implementation. `clientv3-grpc1.14` implements retry in the gRPC interceptor chain that automatically handles gRPC internal errors and enables more advanced retry policies like backoff, while `clientv3-grpc1.7` manually interprets gRPC errors for retries. + +{{< figure src="/img/client-architecture-balancer-figure-09.png" >}} + +### clientv3-grpc1.14: Balancer Limitation + +Improvements can be made by caching the status of each endpoint. For instance, balancer can ping each server in advance to maintain a list of healthy candidates, and use this information when doing round-robin. Or when disconnected, balancer can prioritize healthy endpoints. This may complicate the balancer implementation, thus can be addressed in later versions. + +Client-side keepalive ping still does not reason about network partitions. Streaming request may get stuck with a partitioned node. Advanced health checking service need to be implemented to understand the cluster membership (see [issue #8673](https://github.com/etcd-io/etcd/issues/8673) for more detail). + +Currently, retry logic is handled manually as an interceptor. This may be simplified via [official gRPC retries](https://github.com/grpc/proposal/blob/master/A6-client-retries.md). diff --git a/Documentation/learning/client-feature-matrix.md b/Documentation/learning/client-feature-matrix.md new file mode 100644 index 000000000..4a70c0fa9 --- /dev/null +++ b/Documentation/learning/client-feature-matrix.md @@ -0,0 +1,157 @@ +--- +title: Client feature matrix +--- + +## Features + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +Automatic retry | Yes | . +Retry backoff | Yes | . +Automatic failover | Yes | . +Load balancer | Round-Robin | · +`WithRequireLeader(context.Context)` | Yes | . +`TLS` | Yes | Yes +`SetEndpoints` | Yes | . +`Sync` endpoints | Yes | . +`AutoSyncInterval` | Yes | . +`KeepAlive` ping | Yes | . +`MaxCallSendMsgSize` | Yes | . +`MaxCallRecvMsgSize` | Yes | . +`RejectOldCluster` | Yes | . + +## [KV](https://godoc.org/go.etcd.io/etcd/clientv3#KV) + + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +`Put` | Yes | . +`Get` | Yes | . +`Delete` | Yes | . +`Compact` | Yes | . +`Do(Op)` | Yes | . +`Txn` | Yes | . + +## [Lease](https://godoc.org/go.etcd.io/etcd/clientv3#Lease) + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +`Grant` | Yes | . +`Revoke` | Yes | . +`TimeToLive` | Yes | . +`Leases` | Yes | . +`KeepAlive` | Yes | . +`KeepAliveOnce` | Yes | . + +## [Watcher](https://godoc.org/go.etcd.io/etcd/clientv3#Watcher) + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +`Watch` | Yes | Yes +`RequestProgress` | Yes | . + +## [Cluster](https://godoc.org/go.etcd.io/etcd/clientv3#Cluster) + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +`MemberList` | Yes | Yes +`MemberAdd` | Yes | Yes +`MemberRemove` | Yes | Yes +`MemberUpdate` | Yes | Yes + +## [Maintenance](https://godoc.org/go.etcd.io/etcd/clientv3#Maintenance) + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +`AlarmList` | Yes | Yes +`AlarmDisarm` | Yes | · +`Defragment` | Yes | · +`Status` | Yes | · +`HashKV` | Yes | · +`Snapshot` | Yes | · +`MoveLeader` | Yes | · + +## [Auth](https://godoc.org/go.etcd.io/etcd/clientv3#Auth) + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +`AuthEnable` | Yes | . +`AuthDisable` | Yes | . +`UserAdd` | Yes | . +`UserDelete` | Yes | . +`UserChangePassword` | Yes | . +`UserGrantRole` | Yes | . +`UserGet` | Yes | . +`UserList` | Yes | . +`UserRevokeRole` | Yes | . +`RoleAdd` | Yes | . +`RoleGrantPermission` | Yes | . +`RoleGet` | Yes | . +`RoleList` | Yes | . +`RoleRevokePermission` | Yes | . +`RoleDelete` | Yes | . + +## [clientv3util](https://godoc.org/go.etcd.io/etcd/clientv3/clientv3util) + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +`KeyExists` | Yes | No +`KeyMissing` | Yes | No + +## [Concurrency](https://godoc.org/go.etcd.io/etcd/clientv3/concurrency) + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +`Session` | Yes | No +`NewMutex(Session, prefix)` | Yes | No +`NewElection(Session, prefix)` | Yes | No +`NewLocker(Session, prefix)` | Yes | No +`STM Isolation SerializableSnapshot` | Yes | No +`STM Isolation Serializable` | Yes | No +`STM Isolation RepeatableReads` | Yes | No +`STM Isolation ReadCommitted` | Yes | No +`STM Get` | Yes | No +`STM Put` | Yes | No +`STM Rev` | Yes | No +`STM Del` | Yes | No + +## [Leasing](https://godoc.org/go.etcd.io/etcd/clientv3/leasing) + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +`NewKV(Client, prefix)` | Yes | No + +## [Mirror](https://godoc.org/go.etcd.io/etcd/clientv3/mirror) + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +`SyncBase` | Yes | No +`SyncUpdates` | Yes | No + +## [Namespace](https://godoc.org/go.etcd.io/etcd/clientv3/namespace) + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +`KV` | Yes | No +`Lease` | Yes | No +`Watcher` | Yes | No + +## [Naming](https://godoc.org/go.etcd.io/etcd/clientv3/naming) + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +`GRPCResolver` | Yes | No + +## [Ordering](https://godoc.org/go.etcd.io/etcd/clientv3/ordering) + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +`KV` | Yes | No + +## [Snapshot](https://godoc.org/go.etcd.io/etcd/clientv3/snapshot) + +Feature | `clientv3-grpc1.14` | `jetcd v0.0.2` +:-------|:--------------------|:-------------- +`Save` | Yes | No +`Status` | Yes | No +`Restore` | Yes | No diff --git a/Documentation/learning/data_model.md b/Documentation/learning/data_model.md index e497238f2..bc430c907 100644 --- a/Documentation/learning/data_model.md +++ b/Documentation/learning/data_model.md @@ -1,4 +1,6 @@ -# Data model +--- +title: Data model +--- etcd is designed to reliably store infrequently updated data and provide reliable watch queries. etcd exposes previous versions of key-value pairs to support inexpensive snapshots and watch history events (“time travel queries”). A persistent, multi-version, concurrency-control data model is a good fit for these use cases. @@ -8,9 +10,9 @@ etcd stores data in a multiversion [persistent][persistent-ds] key-value store. The store’s logical view is a flat binary key space. The key space has a lexically sorted index on byte string keys so range queries are inexpensive. -The key space maintains multiple revisions. Each atomic mutative operation (e.g., a transaction operation may contain multiple operations) creates a new revision on the key space. All data held by previous revisions remains unchanged. Old versions of key can still be accessed through previous revisions. Likewise, revisions are indexed as well; ranging over revisions with watchers is efficient. If the store is compacted to save space, revisions before the compact revision will be removed. +The key space maintains multiple **revisions**. Each atomic mutative operation (e.g., a transaction operation may contain multiple operations) creates a new revision on the key space. All data held by previous revisions remains unchanged. Old versions of key can still be accessed through previous revisions. Likewise, revisions are indexed as well; ranging over revisions with watchers is efficient. If the store is compacted to save space, revisions before the compact revision will be removed. Revisions are monotonically increasing over the lifetime of a cluster. -A key’s lifetime spans a generation, denoted by its version. Each key may have one or multiple generations. Creating a key increments the version of that key, starting at 1 if the key never existed. Deleting a key generates a key tombstone, concluding the key’s current generation by resetting its version. Each modification of a key increments its version. Once a compaction happens, any version ended before the given revision will be removed and values set before the compaction revision except the latest one will be removed. +A key's life spans a generation, from creation to deletion. Each key may have one or multiple generations. Creating a key increments the **version** of that key, starting at 1 if the key does not exist at the current revision. Deleting a key generates a key tombstone, concluding the key’s current generation by resetting its version to 0. Each modification of a key increments its version; so, versions are monotonically increasing within a key's generation. Once a compaction happens, any generation ended before the compaction revision will be removed, and values set before the compaction revision except the latest one will be removed. ### Physical view diff --git a/Documentation/learning/glossary.md b/Documentation/learning/glossary.md index 876cb55e4..a2f80b5de 100644 --- a/Documentation/learning/glossary.md +++ b/Documentation/learning/glossary.md @@ -1,4 +1,6 @@ -# Glossary +--- +title: Glossary +--- This document defines the various terms used in etcd documentation, command line and source code. diff --git a/Documentation/learning/learner.md b/Documentation/learning/learner.md new file mode 100644 index 000000000..d2d595962 --- /dev/null +++ b/Documentation/learning/learner.md @@ -0,0 +1,106 @@ +--- +title: Learner +--- + +## Background + +Membership reconfiguration has been one of the biggest operational challenges. Let’s review common challenges. + +A newly joined etcd member starts with no data, thus demanding more updates from leader until it catches up with leader’s logs. Then leader’s network is more likely to be overloaded, blocking or dropping leader heartbeats to followers. In such case, a follower may election-timeout to start a new leader election. That is, a cluster with a new member is more vulnerable to leader election. Both leader election and the subsequent update propagation to the new member are prone to causing periods of cluster unavailability (see **Figure 1** below). + +{{< figure src="/img/server-learner-figure-01.png" >}} + +What if network partition happens? It depends on leader partition. If the leader still maintains the active quorum, the cluster would continue to operate (see **Figure 2**). + +{{< figure src="/img/server-learner-figure-02.png" >}} + +What if the leader becomes isolated from the rest of the cluster? Leader monitors progress of each follower. When leader loses connectivity from the quorum it reverts back to follower which will affect the cluster availability (see **Figure 3**). + +{{< figure src="/img/server-learner-figure-03.png" >}} + +When a new node is added to 3 node cluster, the cluster size becomes 4 and the quorum size becomes 3. What if a new node had joined the cluster, and then network partition happens? It depends on which partition the new member gets located after partition. If the new node happens to be located in the same partition as leader’s, the leader still maintains the active quorum of 3. No leadership election happens, and no cluster availability gets affected (see **Figure 4**). + +{{< figure src="/img/server-learner-figure-04.png" >}} + +If the cluster is 2-and-2 partitioned, then neither of partition maintains the quorum of 3. In this case, leadership election happens (see **Figure 5**). + +{{< figure src="/img/server-learner-figure-05.png" >}} + +What if network partition happens first, and then a new member gets added? A partitioned 3-node cluster already has one disconnected follower. When a new member is added, the quorum changes from 2 to 3. Now, this cluster has only 2 active nodes out 4, thus losing quorum and starting a new leadership election (see **Figure 6**). + +{{< figure src="/img/server-learner-figure-06.png" >}} + +Since member add operation can change the size of quorum, it is always recommended to “member remove” first to replace an unhealthy node. + +Adding a new member to a 1-node cluster changes the quorum size to 2, immediately causing a leader election when the previous leader finds out quorum is not active. This is because “member add” operation is a 2-step process where user needs to apply “member add” command first, and then starts the new node process (see **Figure 7**). + +{{< figure src="/img/server-learner-figure-07.png" >}} + +An even worse case is when an added member is misconfigured. Membership reconfiguration is a two-step process: “etcdctl member add” and starting an etcd server process with the given peer URL. That is, “member add” command is applied regardless of URL, even when the URL value is invalid. If the first step is applied with invalid URLs, the second step cannot even start the new etcd. Once the cluster loses quorum, there is no way to revert the membership change (see **Figure 8**). + +{{< figure src="/img/server-learner-figure-08.png" >}} + +Same applies to a multi-node cluster. For example, the cluster has two members down (one is failed, the other is misconfigured) and two members up, but now it requires at least 3 votes to change the cluster membership (see **Figure 9**). + +{{< figure src="/img/server-learner-figure-09.png" >}} + +As seen above, a simple misconfiguration can fail the whole cluster into an inoperative state. In such case, an operator need manually recreate the cluster with `etcd --force-new-cluster` flag. As etcd has become a mission-critical service for [Kubernetes](https://kubernetes.io), even the slightest outage may have significant impact on users. What can we better to make etcd such operations easier? Among other things, leader election is most critical to cluster availability: Can we make membership reconfiguration less disruptive by not changing the size of quorum? Can a new node be idle, only requesting the minimum updates from leader, until it catches up? Can membership misconfiguration be always reversible and handled in a more secure way (wrong member add command run should never fail the cluster)? Should an user worry about network topology when adding a new member? Can member add API work regardless of the location of nodes and ongoing network partitions? + +## Raft learner + +In order to mitigate such availability gaps in the previous section, [Raft §4.2.1](https://ramcloud.stanford.edu/~ongaro/thesis.pdf) introduces a new node state “Learner,” which joins the cluster as a **non-voting member** until it catches up to the leader’s logs. + +## Features in v3.4 + +An operator should do the minimum amount of work possible to add a new learner node. `member add --learner` command to add a new learner, which joins cluster as a non-voting member but still receives all data from leader (see **Figure 10**). + +{{< figure src="/img/server-learner-figure-10.png" >}} + +When a learner has caught up with leader’s progress, the learner can be promoted to a voting member using the `member promote` API, which then counts towards the quorum (see **Figure 11**). + +{{< figure src="/img/server-learner-figure-11.png" >}} + +etcd server validates promote request to ensure its operational safety. Only after its log has caught up to leader’s can learner be promoted to a voting member (see **Figure 12**). + +{{< figure src="/img/server-learner-figure-12.png" >}} + +Learner only serves as a standby node until promoted: Leadership cannot be transferred to learner. Learner rejects client reads and writes (client balancer should not route requests to learner). Which means learner does not need issue Read Index requests to leader. Such limitation simplifies the initial learner implementation in v3.4 release (see **Figure 13**). + +{{< figure src="/img/server-learner-figure-13.png" >}} + +In addition, etcd limits the total number of learners that a cluster can have, and avoids overloading the leader with log replication. Learner never promotes itself. While etcd provides learner status information and safety checks, cluster operator must make the final decision whether to promote learner or not. + +## Features in v3.5 + +**Make learner state only and default** --- Defaulting a new member state to learner will greatly improve membership reconfiguration safety, because learner does not change the size of quorum. Misconfiguration will always be reversible without losing the quorum. + +**Make voting-member promotion fully automatic** --- Once a learner catches up to leader’s logs, a cluster can automatically promote the learner. etcd requires certain thresholds to be defined by the user, and once the requirements are satisfied, learner promotes itself to a voting member. From a user’s perspective, “member add” command would work the same way as today but with greater safety provided by learner feature. + +**Make learner standby failover node** --- A learner joins as a standby node, and gets automatically promoted when the cluster availability is affected. + +**Make learner read-only** --- A learner can serve as a read-only node that never gets promoted. In a weak consistency mode, learner only receives data from leader and never process writes. Serving reads locally without consensus overhead would greatly decrease the workloads to leader but may serve stale data. In a strong consistency mode, learner requests read index from leader to serve latest data, but still rejects writes. + +## Learner vs. mirror maker + +etcd implements “mirror maker” using watch API to continuously relay key creates and updates to a separate cluster. Mirroring usually has low latency overhead once it completes initial synchronization. Learner and mirroring overlap in that both can be used to replicate existing data for read-only. However, mirroring does not guarantee linearizability. During network disconnects, previous key-values might have been discarded, and clients are expected to verify watch responses for correct ordering. Thus, there is no ordering guarantee in mirror. Use mirror for minimum latency (e.g. cross data center) at the costs of consistency. Use learner to retain all historical data and its ordering. + +## Appendix: learner implementation in v3.4 + +### Expose "Learner" node type to "MemberAdd" API + +etcd client adds a flag to “MemberAdd” API for learner node. And etcd server handler applies membership change entry with `pb.ConfChangeAddLearnerNode` type. Once the command has been applied, a server joins the cluster with `etcd --initial-cluster-state=existing` flag. This learner node can neither vote nor count as quorum. + +etcd server must not transfer leadership to learner, since it may still lag behind and does not count as quorum. etcd server limits the number of learners that cluster can have to one: the more learners we have, the more data the leader has to propagate. Clients may talk to learner node, but learner rejects all requests other than serializable read and member status API. This is for simplicity of initial implementation. In the future, learner can be extended as a read-only server that continuously mirrors cluster data. Client balancer must provide helper function to exclude learner node endpoint. Otherwise, request sent to learner may fail. Client sync member call should factor into learner node type. So should client endpoints update call. + +`MemberList` and `MemberStatus` responses should indicate which node is learner. + +### Add "MemberPromote" API + +Internally in Raft, second `MemberAdd` call to learner node promotes it to a voting member. Leader maintains the progress of each follower and learner. If learner has not completed its snapshot message, reject promote request. Only accept promote request if and only if: The learner node is in a healthy state. The learner is in sync with leader or the delta is within the threshold (e.g. the number of entries to replicate to learner is less than 1/10 of snapshot count, which means it is less likely that even after promotion leader would not need send snapshot to the learner). All these logic are hard-coded in `etcdserver` package and not configurable. + +## Reference + +* Original GitHub issue ([issue #9161](https://github.com/etcd-io/etcd/issues/9161)) +* Use case ([issue #3715](https://github.com/etcd-io/etcd/issues/3715)) +* Use case ([issue #8888](https://github.com/etcd-io/etcd/issues/8888)) +* Use case ([issue #10114](https://github.com/etcd-io/etcd/issues/10114)) diff --git a/Documentation/learning/why.md b/Documentation/learning/why.md index 90769d808..0ce20a6c0 100644 --- a/Documentation/learning/why.md +++ b/Documentation/learning/why.md @@ -1,6 +1,8 @@ -# etcd versus other key-value stores +--- +title: etcd versus other key-value stores +--- -The name "etcd" originated from two ideas, the unix "/etc" folder and "d"istibuted systems. The "/etc" folder is a place to store configuration data for a single system whereas etcd stores configuration information for large scale distributed systems. Hence, a "d"istributed "/etc" is "etcd". +The name "etcd" originated from two ideas, the unix "/etc" folder and "d"istributed systems. The "/etc" folder is a place to store configuration data for a single system whereas etcd stores configuration information for large scale distributed systems. Hence, a "d"istributed "/etc" is "etcd". etcd is designed as a general substrate for large scale distributed systems. These are systems that will never tolerate split-brain operation and are willing to sacrifice availability to achieve this end. etcd stores metadata in a consistent and fault-tolerant way. An etcd cluster is meant to provide key-value storage with best of class stability, reliability, scalability and performance. @@ -76,18 +78,18 @@ In theory, it’s possible to build these primitives atop any storage systems pr For distributed coordination, choosing etcd can help prevent operational headaches and save engineering effort. [production-users]: ../production-users.md -[grpc]: http://www.grpc.io +[grpc]: https://www.grpc.io [consul-bulletproof]: https://www.consul.io/docs/internals/sessions.html [curator]: http://curator.apache.org/ [cockroach]: https://github.com/cockroachdb/cockroach [spanner]: https://cloud.google.com/spanner/ [tidb]: https://github.com/pingcap/tidb -[etcd-v3lock]: https://godoc.org/github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb -[etcd-v3election]: https://godoc.org/github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb +[etcd-v3lock]: https://godoc.org/github.com/etcd-io/etcd/etcdserver/api/v3lock/v3lockpb +[etcd-v3election]: https://godoc.org/github.com/coreos/etcd-io/etcdserver/api/v3election/v3electionpb [etcd-etcdctl-lock]: ../../etcdctl/README.md#lock-lockname-command-arg1-arg2- [etcd-etcdctl-elect]: ../../etcdctl/README.md#elect-options-election-name-proposal [etcd-mvcc]: data_model.md -[etcd-recipe]: https://godoc.org/github.com/coreos/etcd/contrib/recipes +[etcd-recipe]: https://godoc.org/github.com/etcd-io/etcd/contrib/recipes [consul-lock]: https://www.consul.io/docs/commands/lock.html [newsql-leader]: http://dl.acm.org/citation.cfm?id=2960999 [etcd-reconfig]: ../op-guide/runtime-configuration.md @@ -112,5 +114,5 @@ For distributed coordination, choosing etcd can help prevent operational headach [zk-bindings]: https://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html#ch_bindings [container-linux]: https://coreos.com/why [locksmith]: https://github.com/coreos/locksmith -[kubernetes]: http://kubernetes.io/docs/whatisk8s +[kubernetes]: https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/ [dbtester-comparison-results]: https://github.com/coreos/dbtester/tree/master/test-results/2018Q1-02-etcd-zookeeper-consul diff --git a/Documentation/metrics.md b/Documentation/metrics.md index 58e526394..125e6f68c 100644 --- a/Documentation/metrics.md +++ b/Documentation/metrics.md @@ -1,4 +1,7 @@ -# Metrics +--- +title: Metrics +weight: 3 +--- etcd uses [Prometheus][prometheus] for metrics reporting. The metrics can be used for real-time monitoring and debugging. etcd does not persist its metrics; if a member restarts, the metrics will be reset. @@ -99,7 +102,7 @@ Abnormally high snapshot duration (`snapshot_save_total_duration_seconds`) indic ## Prometheus supplied metrics -The Prometheus client library provides a number of metrics under the `go` and `process` namespaces. There are a few that are particlarly interesting. +The Prometheus client library provides a number of metrics under the `go` and `process` namespaces. There are a few that are particularly interesting. | Name | Description | Type | |-----------------------------------|--------------------------------------------|--------------| @@ -113,4 +116,4 @@ Heavy file descriptor (`process_open_fds`) usage (i.e., near the process's file [prometheus-getting-started]: http://prometheus.io/docs/introduction/getting_started/ [prometheus-naming]: http://prometheus.io/docs/practices/naming/ [v2-http-metrics]: v2/metrics.md#http-requests -[go-grpc-prometheus]: https://github.com/grpc-ecosystem/go-grpc-prometheus \ No newline at end of file +[go-grpc-prometheus]: https://github.com/grpc-ecosystem/go-grpc-prometheus diff --git a/Documentation/op-guide/_index.md b/Documentation/op-guide/_index.md new file mode 100644 index 000000000..34b93651f --- /dev/null +++ b/Documentation/op-guide/_index.md @@ -0,0 +1,3 @@ +--- +title: Operations guide +--- \ No newline at end of file diff --git a/Documentation/op-guide/authentication.md b/Documentation/op-guide/authentication.md index a528a8d04..13aaa37a8 100644 --- a/Documentation/op-guide/authentication.md +++ b/Documentation/op-guide/authentication.md @@ -1,4 +1,6 @@ -# Role-based access control +--- +title: Role-based access control +--- ## Overview @@ -32,7 +34,7 @@ Creating a user is as easy as $ etcdctl user add myusername ``` -Creating a new user will prompt for a new password. The password can be supplied from standard input when an option `--interactive=false` is given. +Creating a new user will prompt for a new password. The password can be supplied from standard input when an option `--interactive=false` is given. `--new-user-password` can also be used for supplying the password. Roles can be granted and revoked for a user with: @@ -122,12 +124,12 @@ $ etcdctl role remove myrolename ## Enabling authentication -The minimal steps to enabling auth are as follows. The administrator can set up users and roles before or after enabling authentication, as a matter of preference. +The minimal steps to enabling auth are as follows. The administrator can set up users and roles before or after enabling authentication, as a matter of preference. Make sure the root user is created: ``` -$ etcdctl user add root +$ etcdctl user add root Password of root: ``` @@ -157,8 +159,18 @@ The password can be taken from a prompt: $ etcdctl --user user get foo ``` +The password can also be taken from a command line flag `--password`: + +``` +$ etcdctl --user user --password password get foo +``` + + Otherwise, all `etcdctl` commands remain the same. Users and roles can still be created and modified, but require authentication by a user with the root role. ## Using TLS Common Name +As of version v3.2 if an etcd server is launched with the option `--client-cert-auth=true`, the field of Common Name (CN) in the client's TLS cert will be used as an etcd user. In this case, the common name authenticates the user and the client does not need a password. Note that if both of 1. `--client-cert-auth=true` is passed and CN is provided by the client, and 2. username and password are provided by the client, the username and password based authentication is prioritized. Note that this feature cannot be used with gRPC-proxy and gRPC-gateway. This is because gRPC-proxy terminates TLS from its client so all the clients share a cert of the proxy. gRPC-gateway uses a TLS connection internally for transforming HTTP request to gRPC request so it shares the same limitation. Therefore the clients cannot provide their CN to the server correctly. gRPC-proxy will cause an error and stop if a given cert has non empty CN. gRPC-proxy returns an error which indicates that the client has an non empty CN in its cert. + +As of version v3.3 if an etcd server is launched with the option `--peer-cert-allowed-cn` filtering of CN inter-peer connections is enabled. Nodes can only join the etcd cluster if their CN match the allowed one. +See [etcd security page](https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/security.md) for more details. -If an etcd server is launched with the option `--client-cert-auth=true`, the field of Common Name (CN) in the client's TLS cert will be used as an etcd user. In this case, the common name authenticates the user and the client does not need a password. Note that if both of 1. `--client-cert-auth=true` is passed and CN is provided by the client, and 2. username and password are provided by the client, the username and password based authentication is prioritized. diff --git a/Documentation/op-guide/clustering.md b/Documentation/op-guide/clustering.md index 2e205beef..99d411441 100644 --- a/Documentation/op-guide/clustering.md +++ b/Documentation/op-guide/clustering.md @@ -1,4 +1,6 @@ -# Clustering Guide +--- +title: Clustering Guide +--- ## Overview @@ -342,8 +344,8 @@ etcdserver: discovery token ignored since a cluster has already been initialized ### DNS discovery DNS [SRV records][rfc-srv] can be used as a discovery mechanism. -The `-discovery-srv` flag can be used to set the DNS domain name where the discovery SRV records can be found. -The following DNS SRV records are looked up in the listed order: +The `--discovery-srv` flag can be used to set the DNS domain name where the discovery SRV records can be found. +Setting `--discovery-srv example.com` causes DNS SRV records to be looked up in the listed order: * _etcd-server-ssl._tcp.example.com * _etcd-server._tcp.example.com @@ -357,8 +359,21 @@ To help clients discover the etcd cluster, the following DNS SRV records are loo If `_etcd-client-ssl._tcp.example.com` is found, clients will attempt to communicate with the etcd cluster over SSL/TLS. +If etcd is using TLS, the discovery SRV record (e.g. `example.com`) must be included in the SSL certificate DNS SAN along with the hostname, or clustering will fail with log messages like the following: + +``` +[...] rejected connection from "10.0.1.11:53162" (error "remote error: tls: bad certificate", ServerName "example.com") +``` + If etcd is using TLS without a custom certificate authority, the discovery domain (e.g., example.com) must match the SRV record domain (e.g., infra1.example.com). This is to mitigate attacks that forge SRV records to point to a different domain; the domain would have a valid certificate under PKI but be controlled by an unknown third party. +The `-discovery-srv-name` flag additionally configures a suffix to the SRV name that is queried during discovery. +Use this flag to differentiate between multiple etcd clusters under the same domain. +For example, if `discovery-srv=example.com` and `-discovery-srv-name=foo` are set, the following DNS SRV queries are made: + +* _etcd-server-ssl-foo._tcp.example.com +* _etcd-server-foo._tcp.example.com + #### Create DNS SRV records ``` @@ -384,7 +399,8 @@ infra2.example.com. 300 IN A 10.0.1.12 #### Bootstrap the etcd cluster using DNS -etcd cluster members can listen on domain names or IP address, the bootstrap process will resolve DNS A records. +etcd cluster members can advertise domain names or IP address, the bootstrap process will resolve DNS A records. +Since 3.2 (3.1 prints warnings) `--listen-peer-urls` and `--listen-client-urls` will reject domain name for the network interface binding. The resolved address in `--initial-advertise-peer-urls` *must match* one of the resolved addresses in the SRV targets. The etcd member reads the resolved address to find out if it belongs to the cluster defined in the SRV records. @@ -395,8 +411,8 @@ $ etcd --name infra0 \ --initial-cluster-token etcd-cluster-1 \ --initial-cluster-state new \ --advertise-client-urls http://infra0.example.com:2379 \ ---listen-client-urls http://infra0.example.com:2379 \ ---listen-peer-urls http://infra0.example.com:2380 +--listen-client-urls http://0.0.0.0:2379 \ +--listen-peer-urls http://0.0.0.0:2380 ``` ``` @@ -406,8 +422,8 @@ $ etcd --name infra1 \ --initial-cluster-token etcd-cluster-1 \ --initial-cluster-state new \ --advertise-client-urls http://infra1.example.com:2379 \ ---listen-client-urls http://infra1.example.com:2379 \ ---listen-peer-urls http://infra1.example.com:2380 +--listen-client-urls http://0.0.0.0:2379 \ +--listen-peer-urls http://0.0.0.0:2380 ``` ``` @@ -417,8 +433,8 @@ $ etcd --name infra2 \ --initial-cluster-token etcd-cluster-1 \ --initial-cluster-state new \ --advertise-client-urls http://infra2.example.com:2379 \ ---listen-client-urls http://infra2.example.com:2379 \ ---listen-peer-urls http://infra2.example.com:2380 +--listen-client-urls http://0.0.0.0:2379 \ +--listen-peer-urls http://0.0.0.0:2380 ``` The cluster can also bootstrap using IP addresses instead of domain names: diff --git a/Documentation/op-guide/configuration.md b/Documentation/op-guide/configuration.md index ef91845f2..d2ff02547 100644 --- a/Documentation/op-guide/configuration.md +++ b/Documentation/op-guide/configuration.md @@ -1,4 +1,6 @@ -# Configuration flags +--- +title: Configuration flags +--- etcd is configurable through a configuration file, various command-line flags, and environment variables. @@ -47,14 +49,14 @@ To start etcd automatically using custom settings at startup in Linux, using a [ + env variable: ETCD_ELECTION_TIMEOUT ### --listen-peer-urls -+ List of URLs to listen on for peer traffic. This flag tells the etcd to accept incoming requests from its peers on the specified scheme://IP:port combinations. Scheme can be either http or https.If 0.0.0.0 is specified as the IP, etcd listens to the given port on all interfaces. If an IP address is given as well as a port, etcd will listen on the given port and interface. Multiple URLs may be used to specify a number of addresses and ports to listen on. The etcd will respond to requests from any of the listed addresses and ports. ++ List of URLs to listen on for peer traffic. This flag tells the etcd to accept incoming requests from its peers on the specified scheme://IP:port combinations. Scheme can be http or https. Alternatively, use `unix://` or `unixs://` for unix sockets. If 0.0.0.0 is specified as the IP, etcd listens to the given port on all interfaces. If an IP address is given as well as a port, etcd will listen on the given port and interface. Multiple URLs may be used to specify a number of addresses and ports to listen on. The etcd will respond to requests from any of the listed addresses and ports. + default: "http://localhost:2380" + env variable: ETCD_LISTEN_PEER_URLS + example: "http://10.0.0.1:2380" + invalid example: "http://example.com:2380" (domain name is invalid for binding) ### --listen-client-urls -+ List of URLs to listen on for client traffic. This flag tells the etcd to accept incoming requests from the clients on the specified scheme://IP:port combinations. Scheme can be either http or https. If 0.0.0.0 is specified as the IP, etcd listens to the given port on all interfaces. If an IP address is given as well as a port, etcd will listen on the given port and interface. Multiple URLs may be used to specify a number of addresses and ports to listen on. The etcd will respond to requests from any of the listed addresses and ports. ++ List of URLs to listen on for client traffic. This flag tells the etcd to accept incoming requests from the clients on the specified scheme://IP:port combinations. Scheme can be either http or https. Alternatively, use `unix://` or `unixs://` for unix sockets. If 0.0.0.0 is specified as the IP, etcd listens to the given port on all interfaces. If an IP address is given as well as a port, etcd will listen on the given port and interface. Multiple URLs may be used to specify a number of addresses and ports to listen on. The etcd will respond to requests from any of the listed addresses and ports. + default: "http://localhost:2379" + env variable: ETCD_LISTEN_CLIENT_URLS + example: "http://10.0.0.1:2379" @@ -82,6 +84,16 @@ To start etcd automatically using custom settings at startup in Linux, using a [ + default: 0 + env variable: ETCD_QUOTA_BACKEND_BYTES +### --backend-batch-limit ++ BackendBatchLimit is the maximum operations before commit the backend transaction. ++ default: 0 ++ env variable: ETCD_BACKEND_BATCH_LIMIT + +### --backend-batch-interval ++ BackendBatchInterval is the maximum time before commit the backend transaction. ++ default: 0 ++ env variable: ETCD_BACKEND_BATCH_INTERVAL + ### --max-txn-ops + Maximum number of operations permitted in a transaction. + default: 128 @@ -109,7 +121,7 @@ To start etcd automatically using custom settings at startup in Linux, using a [ ## Clustering flags -`--initial` prefix flags are used in bootstrapping ([static bootstrap][build-cluster], [discovery-service bootstrap][discovery] or [runtime reconfiguration][reconfig]) a new member, and ignored when restarting an existing member. +`--initial-advertise-peer-urls`, `--initial-cluster`, `--initial-cluster-state`, and `--initial-cluster-token` flags are used in bootstrapping ([static bootstrap][build-cluster], [discovery-service bootstrap][discovery] or [runtime reconfiguration][reconfig]) a new member, and ignored when restarting an existing member. `--discovery` prefix flags need to be set when using [discovery service][discovery]. @@ -155,6 +167,11 @@ To start etcd automatically using custom settings at startup in Linux, using a [ + default: "" + env variable: ETCD_DISCOVERY_SRV +### --discovery-srv-name ++ Suffix to the DNS srv name queried when bootstrapping using DNS. ++ default: "" ++ env variable: ETCD_DISCOVERY_SRV_NAME + ### --discovery-fallback + Expected behavior ("exit" or "proxy") when discovery services fails. "proxy" supports v2 API only. + default: "proxy" @@ -167,7 +184,7 @@ To start etcd automatically using custom settings at startup in Linux, using a [ ### --strict-reconfig-check + Reject reconfiguration requests that would cause quorum loss. -+ default: false ++ default: true + env variable: ETCD_STRICT_RECONFIG_CHECK ### --auto-compaction-retention @@ -176,7 +193,7 @@ To start etcd automatically using custom settings at startup in Linux, using a [ + env variable: ETCD_AUTO_COMPACTION_RETENTION ### --auto-compaction-mode -+ Interpret 'auto-compaction-retention' one of: periodic|revision. 'periodic' for duration based retention, defaulting to hours if no time unit is provided (e.g. '5m'). 'revision' for revision number based retention. ++ Interpret 'auto-compaction-retention' one of: 'periodic', 'revision'. 'periodic' for duration based retention, defaulting to hours if no time unit is provided (e.g. '5m'). 'revision' for revision number based retention. + default: periodic + env variable: ETCD_AUTO_COMPACTION_MODE @@ -246,6 +263,7 @@ The security flags help to [build a secure etcd cluster][security]. + Enable client cert authentication. + default: false + env variable: ETCD_CLIENT_CERT_AUTH ++ CN authentication is not supported by gRPC-gateway. ### --client-crl-file + Path to the client certificate revocation list file. @@ -305,8 +323,27 @@ The security flags help to [build a secure etcd cluster][security]. + default: none + env variable: ETCD_PEER_CERT_ALLOWED_CN +### --cipher-suites ++ Comma-separated list of supported TLS cipher suites between server/client and peers. ++ default: "" ++ env variable: ETCD_CIPHER_SUITES + ## Logging flags +### --logger + +**Available from v3.4** + ++ Specify 'zap' for structured logging or 'capnslog'. ++ default: capnslog ++ env variable: ETCD_LOGGER + +### --log-outputs ++ Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd, or list of comma separated output targets. ++ default: default ++ env variable: ETCD_LOG_OUTPUTS ++ 'default' use 'stderr' config for v3.4 during zap logger migraion + ### --debug + Drop the default log level to DEBUG for all subpackages. + default: false (INFO for all packages) @@ -324,7 +361,7 @@ For example, it may panic if other members in the cluster are still alive. Follow the instructions when using these flags. ### --force-new-cluster -+ Force to create a new one-member cluster. It commits configuration changes forcing to remove all existing members in the cluster and add itself. It needs to be set to [restore a backup][restore]. ++ Force to create a new one-member cluster. It commits configuration changes forcing to remove all existing members in the cluster and add itself, but is strongly discouraged. Please review the [disaster recovery][recovery] documentation for preferred v3 recovery procedures. + default: false + env variable: ETCD_FORCE_NEW_CLUSTER @@ -338,33 +375,50 @@ Follow the instructions when using these flags. + Load server configuration from a file. + default: "" + example: [sample configuration file][sample-config-file] ++ env variable: ETCD_CONFIG_FILE ## Profiling flags ### --enable-pprof + Enable runtime profiling data via HTTP server. Address is at client URL + "/debug/pprof/" + default: false ++ env variable: ETCD_ENABLE_PPROF ### --metrics + Set level of detail for exported metrics, specify 'extensive' to include histogram metrics. + default: basic ++ env variable: ETCD_METRICS ### --listen-metrics-urls -+ List of URLs to listen on for metrics. ++ List of additional URLs to listen on that will respond to both the `/metrics` and `/health` endpoints + default: "" ++ env variable: ETCD_LISTEN_METRICS_URLS ## Auth flags ### --auth-token -+ Specify a token type and token specific options, especially for JWT. Its format is "type,var1=val1,var2=val2,...". Possible type is 'simple' or 'jwt'. Possible variables are 'sign-method' for specifying a sign method of jwt (its possible values are 'ES256', 'ES384', 'ES512', 'HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512', 'PS256', 'PS384', or 'PS512'), 'pub-key' for specifying a path to a public key for verifying jwt, and 'priv-key' for specifying a path to a private key for signing jwt. -+ Example option of JWT: '--auth-token jwt,pub-key=app.rsa.pub,priv-key=app.rsa,sign-method=RS512' ++ Specify a token type and token specific options, especially for JWT. Its format is "type,var1=val1,var2=val2,...". Possible type is 'simple' or 'jwt'. Possible variables are 'sign-method' for specifying a sign method of jwt (its possible values are 'ES256', 'ES384', 'ES512', 'HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512', 'PS256', 'PS384', or 'PS512'), 'pub-key' for specifying a path to a public key for verifying jwt, 'priv-key' for specifying a path to a private key for signing jwt, and 'ttl' for specifying TTL of jwt tokens. ++ For asymmetric algorithms ('RS', 'PS', 'ES'), the public key is optional, as the private key contains enough information to both sign and verify tokens. ++ Example option of JWT: '--auth-token jwt,pub-key=app.rsa.pub,priv-key=app.rsa,sign-method=RS512,ttl=10m' + default: "simple" ++ env variable: ETCD_AUTH_TOKEN + +### --bcrypt-cost ++ Specify the cost / strength of the bcrypt algorithm for hashing auth passwords. Valid values are between 4 and 31. ++ default: 10 ++ env variable: (not supported) ## Experimental flags +### --experimental-backend-bbolt-freelist-type ++ The freelist type that etcd backend(bboltdb) uses (array and map are supported types). ++ default: array ++ env variable: ETCD_EXPERIMENTAL_BACKEND_BBOLT_FREELIST_TYPE + ### --experimental-corrupt-check-time + Duration of time between cluster corruption check passes + default: 0s ++ env variable: ETCD_EXPERIMENTAL_CORRUPT_CHECK_TIME [build-cluster]: clustering.md#static [reconfig]: runtime-configuration.md @@ -376,3 +430,4 @@ Follow the instructions when using these flags. [systemd-intro]: http://freedesktop.org/wiki/Software/systemd/ [tuning]: ../tuning.md#time-parameters [sample-config-file]: ../../etcd.conf.yml.sample +[recovery]: recovery.md#disaster-recovery diff --git a/Documentation/op-guide/container.md b/Documentation/op-guide/container.md index 197cff873..3c7693a25 100644 --- a/Documentation/op-guide/container.md +++ b/Documentation/op-guide/container.md @@ -1,4 +1,6 @@ -# Run etcd clusters inside containers +--- +title: Run etcd clusters inside containers +--- The following guide shows how to run etcd with rkt and Docker using the [static bootstrap process](clustering.md#static). diff --git a/Documentation/op-guide/etcd3_alert.rules b/Documentation/op-guide/etcd3_alert.rules index 919756dc2..98139115b 100644 --- a/Documentation/op-guide/etcd3_alert.rules +++ b/Documentation/op-guide/etcd3_alert.rules @@ -79,47 +79,6 @@ ANNOTATIONS { description = "on etcd instance {{ $labels.instance }} gRPC requests to {{ $labels.grpc_method }} are slow", } -# HTTP requests alerts -# ==================== - -# alert if more than 1% of requests to an HTTP endpoint have failed within the last 5 minutes -ALERT HighNumberOfFailedHTTPRequests -IF 100 * (sum(rate(grpc_server_handled_total{grpc_code!="OK",job="etcd"}[5m])) BY (grpc_service, grpc_method) - / sum(rate(grpc_server_handled_total{job="etcd"}[5m])) BY (grpc_service, grpc_method)) > 1 -FOR 10m -LABELS { - severity = "warning" -} -ANNOTATIONS { - summary = "a high number of HTTP requests are failing", - description = "{{ $value }}% of requests for {{ $labels.method }} failed on etcd instance {{ $labels.instance }}", -} - -# alert if more than 5% of requests to an HTTP endpoint have failed within the last 5 minutes -ALERT HighNumberOfFailedHTTPRequests -IF 100 * (sum(rate(grpc_server_handled_total{grpc_code!="OK",job="etcd"}[5m])) BY (grpc_service, grpc_method) - / sum(rate(grpc_server_handled_total{job="etcd"}[5m])) BY (grpc_service, grpc_method)) > 5 -FOR 5m -LABELS { - severity = "critical" -} -ANNOTATIONS { - summary = "a high number of HTTP requests are failing", - description = "{{ $value }}% of requests for {{ $labels.method }} failed on etcd instance {{ $labels.instance }}", -} - -# alert if the 99th percentile of HTTP requests take more than 150ms -ALERT HTTPRequestsSlow -IF histogram_quantile(0.99, rate(etcd_http_successful_duration_seconds_bucket[5m])) > 0.15 -FOR 10m -LABELS { - severity = "warning" -} -ANNOTATIONS { - summary = "slow HTTP requests", - description = "on etcd instance {{ $labels.instance }} HTTP requests to {{ $labels.method }} are slow", -} - # file descriptor alerts # ====================== diff --git a/Documentation/op-guide/etcd3_alert.rules.yml b/Documentation/op-guide/etcd3_alert.rules.yml index fbd12c7ec..17287172b 100644 --- a/Documentation/op-guide/etcd3_alert.rules.yml +++ b/Documentation/op-guide/etcd3_alert.rules.yml @@ -1,143 +1,134 @@ +# these rules synced manually from https://github.com/etcd-io/etcd/blob/master/Documentation/etcd-mixin/mixin.libsonnet groups: -- name: etcd3_alert.rules +- name: etcd rules: - - alert: InsufficientMembers - expr: count(up{job="etcd"} == 0) > (count(up{job="etcd"}) / 2 - 1) + - alert: etcdInsufficientMembers + annotations: + message: 'etcd cluster "{{ $labels.job }}": insufficient members ({{ $value + }}).' + expr: | + sum(up{job=~".*etcd.*"} == bool 1) by (job) < ((count(up{job=~".*etcd.*"}) by (job) + 1) / 2) for: 3m labels: severity: critical + - alert: etcdNoLeader annotations: - description: If one more etcd member goes down the cluster will be unavailable - summary: etcd cluster insufficient members - - alert: NoLeader - expr: etcd_server_has_leader{job="etcd"} == 0 + message: 'etcd cluster "{{ $labels.job }}": member {{ $labels.instance }} has + no leader.' + expr: | + etcd_server_has_leader{job=~".*etcd.*"} == 0 for: 1m labels: severity: critical + - alert: etcdHighNumberOfLeaderChanges annotations: - description: etcd member {{ $labels.instance }} has no leader - summary: etcd member has no leader - - alert: HighNumberOfLeaderChanges - expr: increase(etcd_server_leader_changes_seen_total{job="etcd"}[1h]) > 3 + message: 'etcd cluster "{{ $labels.job }}": instance {{ $labels.instance }} + has seen {{ $value }} leader changes within the last hour.' + expr: | + rate(etcd_server_leader_changes_seen_total{job=~".*etcd.*"}[15m]) > 3 + for: 15m labels: severity: warning + - alert: etcdHighNumberOfFailedGRPCRequests annotations: - description: etcd instance {{ $labels.instance }} has seen {{ $value }} leader - changes within the last hour - summary: a high number of leader changes within the etcd cluster are happening - - alert: HighNumberOfFailedGRPCRequests - expr: 100 * (sum(rate(grpc_server_handled_total{grpc_code!="OK",job="etcd"}[5m])) BY (grpc_service, grpc_method) - / sum(rate(grpc_server_handled_total{job="etcd"}[5m])) BY (grpc_service, grpc_method)) > 1 + message: 'etcd cluster "{{ $labels.job }}": {{ $value }}% of requests for {{ + $labels.grpc_method }} failed on etcd instance {{ $labels.instance }}.' + expr: | + 100 * sum(rate(grpc_server_handled_total{job=~".*etcd.*", grpc_code!="OK"}[5m])) BY (job, instance, grpc_service, grpc_method) + / + sum(rate(grpc_server_handled_total{job=~".*etcd.*"}[5m])) BY (job, instance, grpc_service, grpc_method) + > 1 for: 10m labels: severity: warning + - alert: etcdHighNumberOfFailedGRPCRequests annotations: - description: '{{ $value }}% of requests for {{ $labels.grpc_method }} failed - on etcd instance {{ $labels.instance }}' - summary: a high number of gRPC requests are failing - - alert: HighNumberOfFailedGRPCRequests - expr: 100 * (sum(rate(grpc_server_handled_total{grpc_code!="OK",job="etcd"}[5m])) BY (grpc_service, grpc_method) - / sum(rate(grpc_server_handled_total{job="etcd"}[5m])) BY (grpc_service, grpc_method)) > 5 + message: 'etcd cluster "{{ $labels.job }}": {{ $value }}% of requests for {{ + $labels.grpc_method }} failed on etcd instance {{ $labels.instance }}.' + expr: | + 100 * sum(rate(grpc_server_handled_total{job=~".*etcd.*", grpc_code!="OK"}[5m])) BY (job, instance, grpc_service, grpc_method) + / + sum(rate(grpc_server_handled_total{job=~".*etcd.*"}[5m])) BY (job, instance, grpc_service, grpc_method) + > 5 for: 5m labels: severity: critical + - alert: etcdGRPCRequestsSlow annotations: - description: '{{ $value }}% of requests for {{ $labels.grpc_method }} failed - on etcd instance {{ $labels.instance }}' - summary: a high number of gRPC requests are failing - - alert: GRPCRequestsSlow - expr: histogram_quantile(0.99, sum(rate(grpc_server_handling_seconds_bucket{job="etcd",grpc_type="unary"}[5m])) by (grpc_service, grpc_method, le)) + message: 'etcd cluster "{{ $labels.job }}": gRPC requests to {{ $labels.grpc_method + }} are taking {{ $value }}s on etcd instance {{ $labels.instance }}.' + expr: | + histogram_quantile(0.99, sum(rate(grpc_server_handling_seconds_bucket{job=~".*etcd.*", grpc_type="unary"}[5m])) by (job, instance, grpc_service, grpc_method, le)) > 0.15 for: 10m labels: severity: critical + - alert: etcdMemberCommunicationSlow annotations: - description: on etcd instance {{ $labels.instance }} gRPC requests to {{ $labels.grpc_method - }} are slow - summary: slow gRPC requests - - alert: HighNumberOfFailedHTTPRequests - expr: 100 * (sum(rate(etcd_http_failed_total{job="etcd"}[5m])) BY (method) / sum(rate(etcd_http_received_total{job="etcd"}[5m])) - BY (method)) > 1 - for: 10m - labels: - severity: warning - annotations: - description: '{{ $value }}% of requests for {{ $labels.method }} failed on etcd - instance {{ $labels.instance }}' - summary: a high number of HTTP requests are failing - - alert: HighNumberOfFailedHTTPRequests - expr: 100 * (sum(rate(etcd_http_failed_total{job="etcd"}[5m])) BY (method) / sum(rate(etcd_http_received_total{job="etcd"}[5m])) - BY (method)) > 5 - for: 5m - labels: - severity: critical - annotations: - description: '{{ $value }}% of requests for {{ $labels.method }} failed on etcd - instance {{ $labels.instance }}' - summary: a high number of HTTP requests are failing - - alert: HTTPRequestsSlow - expr: histogram_quantile(0.99, rate(etcd_http_successful_duration_seconds_bucket[5m])) + message: 'etcd cluster "{{ $labels.job }}": member communication with {{ $labels.To + }} is taking {{ $value }}s on etcd instance {{ $labels.instance }}.' + expr: | + histogram_quantile(0.99, rate(etcd_network_peer_round_trip_time_seconds_bucket{job=~".*etcd.*"}[5m])) > 0.15 for: 10m labels: severity: warning + - alert: etcdHighNumberOfFailedProposals annotations: - description: on etcd instance {{ $labels.instance }} HTTP requests to {{ $labels.method - }} are slow - summary: slow HTTP requests - - record: instance:fd_utilization - expr: process_open_fds / process_max_fds - - alert: FdExhaustionClose - expr: predict_linear(instance:fd_utilization[1h], 3600 * 4) > 1 - for: 10m + message: 'etcd cluster "{{ $labels.job }}": {{ $value }} proposal failures within + the last hour on etcd instance {{ $labels.instance }}.' + expr: | + rate(etcd_server_proposals_failed_total{job=~".*etcd.*"}[15m]) > 5 + for: 15m labels: severity: warning + - alert: etcdHighFsyncDurations annotations: - description: '{{ $labels.job }} instance {{ $labels.instance }} will exhaust - its file descriptors soon' - summary: file descriptors soon exhausted - - alert: FdExhaustionClose - expr: predict_linear(instance:fd_utilization[10m], 3600) > 1 - for: 10m - labels: - severity: critical - annotations: - description: '{{ $labels.job }} instance {{ $labels.instance }} will exhaust - its file descriptors soon' - summary: file descriptors soon exhausted - - alert: EtcdMemberCommunicationSlow - expr: histogram_quantile(0.99, rate(etcd_network_peer_round_trip_time_seconds_bucket[5m])) - > 0.15 - for: 10m - labels: - severity: warning - annotations: - description: etcd instance {{ $labels.instance }} member communication with - {{ $labels.To }} is slow - summary: etcd member communication is slow - - alert: HighNumberOfFailedProposals - expr: increase(etcd_server_proposals_failed_total{job="etcd"}[1h]) > 5 - labels: - severity: warning - annotations: - description: etcd instance {{ $labels.instance }} has seen {{ $value }} proposal - failures within the last hour - summary: a high number of proposals within the etcd cluster are failing - - alert: HighFsyncDurations - expr: histogram_quantile(0.99, rate(etcd_disk_wal_fsync_duration_seconds_bucket[5m])) + message: 'etcd cluster "{{ $labels.job }}": 99th percentile fync durations are + {{ $value }}s on etcd instance {{ $labels.instance }}.' + expr: | + histogram_quantile(0.99, rate(etcd_disk_wal_fsync_duration_seconds_bucket{job=~".*etcd.*"}[5m])) > 0.5 for: 10m labels: severity: warning + - alert: etcdHighCommitDurations annotations: - description: etcd instance {{ $labels.instance }} fync durations are high - summary: high fsync durations - - alert: HighCommitDurations - expr: histogram_quantile(0.99, rate(etcd_disk_backend_commit_duration_seconds_bucket[5m])) + message: 'etcd cluster "{{ $labels.job }}": 99th percentile commit durations + {{ $value }}s on etcd instance {{ $labels.instance }}.' + expr: | + histogram_quantile(0.99, rate(etcd_disk_backend_commit_duration_seconds_bucket{job=~".*etcd.*"}[5m])) > 0.25 for: 10m labels: severity: warning + - alert: etcdHighNumberOfFailedHTTPRequests annotations: - description: etcd instance {{ $labels.instance }} commit durations are high - summary: high commit durations + message: '{{ $value }}% of requests for {{ $labels.method }} failed on etcd + instance {{ $labels.instance }}' + expr: | + sum(rate(etcd_http_failed_total{job=~".*etcd.*", code!="404"}[5m])) BY (method) / sum(rate(etcd_http_received_total{job=~".*etcd.*"}[5m])) + BY (method) > 0.01 + for: 10m + labels: + severity: warning + - alert: etcdHighNumberOfFailedHTTPRequests + annotations: + message: '{{ $value }}% of requests for {{ $labels.method }} failed on etcd + instance {{ $labels.instance }}.' + expr: | + sum(rate(etcd_http_failed_total{job=~".*etcd.*", code!="404"}[5m])) BY (method) / sum(rate(etcd_http_received_total{job=~".*etcd.*"}[5m])) + BY (method) > 0.05 + for: 10m + labels: + severity: critical + - alert: etcdHTTPRequestsSlow + annotations: + message: etcd instance {{ $labels.instance }} HTTP requests to {{ $labels.method + }} are slow. + expr: | + histogram_quantile(0.99, rate(etcd_http_successful_duration_seconds_bucket[5m])) + > 0.15 + for: 10m + labels: + severity: warning diff --git a/Documentation/op-guide/failures.md b/Documentation/op-guide/failures.md index 6139e05fc..c60e7ec49 100644 --- a/Documentation/op-guide/failures.md +++ b/Documentation/op-guide/failures.md @@ -1,4 +1,6 @@ -# Failure modes +--- +title: Failure modes +--- Failures are common in a large deployment of machines. A machine fails when its hardware or software malfunctions. Multiple machines fail together when there are power failures or network issues. Multiple kinds of failures can also happen at once; it is almost impossible to enumerate all possible failure cases. diff --git a/Documentation/op-guide/gateway.md b/Documentation/op-guide/gateway.md index 10fe5d0c3..8240d3c54 100644 --- a/Documentation/op-guide/gateway.md +++ b/Documentation/op-guide/gateway.md @@ -1,10 +1,12 @@ -# etcd gateway +--- +title: etcd gateway +--- ## What is etcd gateway etcd gateway is a simple TCP proxy that forwards network data to the etcd cluster. The gateway is stateless and transparent; it neither inspects client requests nor interferes with cluster responses. -The gateway supports multiple etcd server endpoints and works on a simple round-robin policy. It only routes to available enpoints and hides failures from its clients. Other retry policies, such as weighted round-robin, may be supported in the future. +The gateway supports multiple etcd server endpoints and works on a simple round-robin policy. It only routes to available endpoints and hides failures from its clients. Other retry policies, such as weighted round-robin, may be supported in the future. ## When to use etcd gateway @@ -60,7 +62,7 @@ infra2.example.com. 300 IN A 10.0.1.12 Start the etcd gateway to fetch the endpoints from the DNS SRV entries with the command: ```bash -$ etcd gateway --discovery-srv=example.com +$ etcd gateway start --discovery-srv=example.com 2016-08-16 11:21:18.867350 I | tcpproxy: ready to proxy client requests to [...] ``` diff --git a/Documentation/op-guide/grafana.json b/Documentation/op-guide/grafana.json index 4b7a432ea..c405fdfee 100644 --- a/Documentation/op-guide/grafana.json +++ b/Documentation/op-guide/grafana.json @@ -1,1015 +1,1225 @@ { - "id": 6, - "title": "test-etcd", - "description": "etcd sample Grafana dashboard with Prometheus", - "tags": [], - "style": "dark", - "timezone": "browser", - "editable": true, - "hideControls": false, - "sharedCrosshair": false, - "rows": [{ - "collapse": false, - "editable": true, - "height": "250px", - "panels": [{ - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "test-etcd", - "editable": true, - "error": false, - "format": "none", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "id": 28, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [{ - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [{ - "from": "null", - "text": "N/A", - "to": "null" - }], - "span": 3, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "targets": [{ - "expr": "sum(etcd_server_has_leader)", - "intervalFactor": 2, - "legendFormat": "", - "metric": "etcd_server_has_leader", - "refId": "A", - "step": 20 - }], - "thresholds": "", - "title": "Up", - "type": "singlestat", - "valueFontSize": "200%", - "valueMaps": [{ - "op": "=", - "text": "N/A", - "value": "null" - }], - "valueName": "avg" - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "test-etcd", - "editable": true, - "error": false, - "fill": 0, - "id": 23, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 5, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(rate(grpc_server_started_total{grpc_type=\"unary\"}[5m]))", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "RPC Rate", - "metric": "grpc_server_started_total", - "refId": "A", - "step": 2 - }, - { - "expr": "sum(rate(grpc_server_handled_total{grpc_type=\"unary\",grpc_code!=\"OK\"}[5m]))", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "RPC Failed Rate", - "metric": "grpc_server_handled_total", - "refId": "B", - "step": 2 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "RPC Rate", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [{ - "format": "ops", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "test-etcd", - "editable": true, - "error": false, - "fill": 0, - "id": 41, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 4, - "stack": true, - "steppedLine": false, - "targets": [{ - "expr": "sum(grpc_server_started_total{grpc_service=\"etcdserverpb.Watch\",grpc_type=\"bidi_stream\"}) - sum(grpc_server_handled_total{grpc_service=\"etcdserverpb.Watch\",grpc_type=\"bidi_stream\"})", - "intervalFactor": 2, - "legendFormat": "Watch Streams", - "metric": "grpc_server_handled_total", - "refId": "A", - "step": 4 - }, - { - "expr": "sum(grpc_server_started_total{grpc_service=\"etcdserverpb.Lease\",grpc_type=\"bidi_stream\"}) - sum(grpc_server_handled_total{grpc_service=\"etcdserverpb.Lease\",grpc_type=\"bidi_stream\"})", - "intervalFactor": 2, - "legendFormat": "Lease Streams", - "metric": "grpc_server_handled_total", - "refId": "B", - "step": 4 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Active Streams", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [{ - "format": "short", - "label": "", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - } - ], - "showTitle": false, - "title": "Row" + "etcd.json": { + "annotations": { + "list": [ + + ] }, - { - "collapse": false, - "editable": true, - "height": "250px", - "panels": [{ - "aliasColors": {}, - "bars": false, - "datasource": "test-etcd", - "decimals": null, - "editable": true, - "error": false, - "fill": 0, - "grid": {}, - "id": 1, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 4, - "stack": false, - "steppedLine": false, - "targets": [{ - "expr": "etcd_debugging_mvcc_db_total_size_in_bytes", - "hide": false, - "interval": "", - "intervalFactor": 2, - "legendFormat": "{{instance}} DB Size", - "metric": "", - "refId": "A", - "step": 4 - }], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "DB Size", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [{ - "format": "bytes", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "test-etcd", - "editable": true, - "error": false, - "fill": 0, - "grid": {}, - "id": 3, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 1, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 4, - "stack": false, - "steppedLine": true, - "targets": [{ - "expr": "histogram_quantile(0.99, sum(rate(etcd_disk_wal_fsync_duration_seconds_bucket[5m])) by (instance, le))", - "hide": false, - "intervalFactor": 2, - "legendFormat": "{{instance}} WAL fsync", - "metric": "etcd_disk_wal_fsync_duration_seconds_bucket", - "refId": "A", - "step": 4 - }, - { - "expr": "histogram_quantile(0.99, sum(rate(etcd_disk_backend_commit_duration_seconds_bucket[5m])) by (instance, le))", - "intervalFactor": 2, - "legendFormat": "{{instance}} DB fsync", - "metric": "etcd_disk_backend_commit_duration_seconds_bucket", - "refId": "B", - "step": 4 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Disk Sync Duration", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [{ - "format": "s", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "test-etcd", - "editable": true, - "error": false, - "fill": 0, - "id": 29, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 4, - "stack": false, - "steppedLine": false, - "targets": [{ - "expr": "process_resident_memory_bytes", - "intervalFactor": 2, - "legendFormat": "{{instance}} Resident Memory", - "metric": "process_resident_memory_bytes", - "refId": "A", - "step": 4 - }], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Memory", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [{ - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - } - ], - "title": "New row" - }, - { - "collapse": false, - "editable": true, - "height": "250px", - "panels": [{ - "aliasColors": {}, - "bars": false, - "datasource": "test-etcd", - "editable": true, - "error": false, - "fill": 5, - "id": 22, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 3, - "stack": true, - "steppedLine": false, - "targets": [{ - "expr": "rate(etcd_network_client_grpc_received_bytes_total[5m])", - "intervalFactor": 2, - "legendFormat": "{{instance}} Client Traffic In", - "metric": "etcd_network_client_grpc_received_bytes_total", - "refId": "A", - "step": 4 - }], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Client Traffic In", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [{ - "format": "Bps", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "test-etcd", - "editable": true, - "error": false, - "fill": 5, - "id": 21, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 3, - "stack": true, - "steppedLine": false, - "targets": [{ - "expr": "rate(etcd_network_client_grpc_sent_bytes_total[5m])", - "intervalFactor": 2, - "legendFormat": "{{instance}} Client Traffic Out", - "metric": "etcd_network_client_grpc_sent_bytes_total", - "refId": "A", - "step": 4 - }], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Client Traffic Out", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [{ - "format": "Bps", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "test-etcd", - "editable": true, - "error": false, - "fill": 0, - "id": 20, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 3, - "stack": false, - "steppedLine": false, - "targets": [{ - "expr": "sum(rate(etcd_network_peer_received_bytes_total[5m])) by (instance)", - "intervalFactor": 2, - "legendFormat": "{{instance}} Peer Traffic In", - "metric": "etcd_network_peer_received_bytes_total", - "refId": "A", - "step": 4 - }], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Peer Traffic In", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [{ - "format": "Bps", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "test-etcd", - "decimals": null, - "editable": true, - "error": false, - "fill": 0, - "grid": {}, - "id": 16, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 3, - "stack": false, - "steppedLine": false, - "targets": [{ - "expr": "sum(rate(etcd_network_peer_sent_bytes_total[5m])) by (instance)", - "hide": false, - "interval": "", - "intervalFactor": 2, - "legendFormat": "{{instance}} Peer Traffic Out", - "metric": "etcd_network_peer_sent_bytes_total", - "refId": "A", - "step": 4 - }], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Peer Traffic Out", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [{ - "format": "Bps", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - } - ], - "title": "New row" - }, - { - "collapse": false, - "editable": true, - "height": "250px", - "panels": [{ - "aliasColors": {}, - "bars": false, - "datasource": "test-etcd", - "editable": true, - "error": false, - "fill": 0, - "id": 40, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [{ - "expr": "sum(rate(etcd_server_proposals_failed_total[5m]))", - "intervalFactor": 2, - "legendFormat": "Proposal Failure Rate", - "metric": "etcd_server_proposals_failed_total", - "refId": "A", - "step": 2 - }, - { - "expr": "sum(etcd_server_proposals_pending)", - "intervalFactor": 2, - "legendFormat": "Proposal Pending Total", - "metric": "etcd_server_proposals_pending", - "refId": "B", - "step": 2 - }, - { - "expr": "sum(rate(etcd_server_proposals_committed_total[5m]))", - "intervalFactor": 2, - "legendFormat": "Proposal Commit Rate", - "metric": "etcd_server_proposals_committed_total", - "refId": "C", - "step": 2 - }, - { - "expr": "sum(rate(etcd_server_proposals_applied_total[5m]))", - "intervalFactor": 2, - "legendFormat": "Proposal Apply Rate", - "refId": "D", - "step": 2 - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Raft Proposals", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [{ - "format": "short", - "label": "", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "test-etcd", - "decimals": 0, - "editable": true, - "error": false, - "fill": 0, - "id": 19, - "isNew": true, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [{ - "expr": "changes(etcd_server_leader_changes_seen_total[1d])", - "intervalFactor": 2, - "legendFormat": "{{instance}} Total Leader Elections Per Day", - "metric": "etcd_server_leader_changes_seen_total", - "refId": "A", - "step": 2 - }], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Total Leader Elections Per Day", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [{ - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - } - ], - "title": "New row" - } - ], - "time": { - "from": "now-15m", - "to": "now" - }, - "timepicker": { - "now": true, - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" + "description": "etcd sample Grafana dashboard with Prometheus", + "editable": true, + "gnetId": null, + "hideControls": false, + "id": 6, + "links": [ + ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "templating": { - "list": [] - }, - "annotations": { - "list": [] - }, - "refresh": false, - "schemaVersion": 13, - "version": 215, - "links": [], - "gnetId": null + "refresh": false, + "rows": [ + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "$datasource", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "id": 28, + "interval": null, + "isNew": true, + "links": [ + + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "span": 3, + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "targets": [ + { + "expr": "sum(etcd_server_has_leader{job=\"$cluster\"})", + "intervalFactor": 2, + "legendFormat": "", + "metric": "etcd_server_has_leader", + "refId": "A", + "step": 20 + } + ], + "thresholds": "", + "title": "Up", + "type": "singlestat", + "valueFontSize": "200%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "aliasColors": { + + }, + "bars": false, + "datasource": "$datasource", + "editable": true, + "error": false, + "fill": 0, + "id": 23, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [ + + ], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "span": 5, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(rate(grpc_server_started_total{job=\"$cluster\",grpc_type=\"unary\"}[5m]))", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "RPC Rate", + "metric": "grpc_server_started_total", + "refId": "A", + "step": 2 + }, + { + "expr": "sum(rate(grpc_server_handled_total{job=\"$cluster\",grpc_type=\"unary\",grpc_code!=\"OK\"}[5m]))", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "RPC Failed Rate", + "metric": "grpc_server_handled_total", + "refId": "B", + "step": 2 + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "RPC Rate", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "ops", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": { + + }, + "bars": false, + "datasource": "$datasource", + "editable": true, + "error": false, + "fill": 0, + "id": 41, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [ + + ], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "span": 4, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "sum(grpc_server_started_total{job=\"$cluster\",grpc_service=\"etcdserverpb.Watch\",grpc_type=\"bidi_stream\"}) - sum(grpc_server_handled_total{job=\"$cluster\",grpc_service=\"etcdserverpb.Watch\",grpc_type=\"bidi_stream\"})", + "intervalFactor": 2, + "legendFormat": "Watch Streams", + "metric": "grpc_server_handled_total", + "refId": "A", + "step": 4 + }, + { + "expr": "sum(grpc_server_started_total{job=\"$cluster\",grpc_service=\"etcdserverpb.Lease\",grpc_type=\"bidi_stream\"}) - sum(grpc_server_handled_total{job=\"$cluster\",grpc_service=\"etcdserverpb.Lease\",grpc_type=\"bidi_stream\"})", + "intervalFactor": 2, + "legendFormat": "Lease Streams", + "metric": "grpc_server_handled_total", + "refId": "B", + "step": 4 + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Active Streams", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + } + ], + "showTitle": false, + "title": "Row" + }, + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "aliasColors": { + + }, + "bars": false, + "datasource": "$datasource", + "decimals": null, + "editable": true, + "error": false, + "fill": 0, + "grid": { + + }, + "id": 1, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [ + + ], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "span": 4, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "etcd_mvcc_db_total_size_in_bytes{job=\"$cluster\"}", + "hide": false, + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{instance}} DB Size", + "metric": "", + "refId": "A", + "step": 4 + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "DB Size", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "bytes", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + }, + { + "aliasColors": { + + }, + "bars": false, + "datasource": "$datasource", + "editable": true, + "error": false, + "fill": 0, + "grid": { + + }, + "id": 3, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [ + + ], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 1, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "span": 4, + "stack": false, + "steppedLine": true, + "targets": [ + { + "expr": "histogram_quantile(0.99, sum(rate(etcd_disk_wal_fsync_duration_seconds_bucket{job=\"$cluster\"}[5m])) by (instance, le))", + "hide": false, + "intervalFactor": 2, + "legendFormat": "{{instance}} WAL fsync", + "metric": "etcd_disk_wal_fsync_duration_seconds_bucket", + "refId": "A", + "step": 4 + }, + { + "expr": "histogram_quantile(0.99, sum(rate(etcd_disk_backend_commit_duration_seconds_bucket{job=\"$cluster\"}[5m])) by (instance, le))", + "intervalFactor": 2, + "legendFormat": "{{instance}} DB fsync", + "metric": "etcd_disk_backend_commit_duration_seconds_bucket", + "refId": "B", + "step": 4 + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Disk Sync Duration", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "s", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + }, + { + "aliasColors": { + + }, + "bars": false, + "datasource": "$datasource", + "editable": true, + "error": false, + "fill": 0, + "id": 29, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [ + + ], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "span": 4, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "process_resident_memory_bytes{job=\"$cluster\"}", + "intervalFactor": 2, + "legendFormat": "{{instance}} Resident Memory", + "metric": "process_resident_memory_bytes", + "refId": "A", + "step": 4 + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Memory", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + } + ], + "title": "New row" + }, + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "aliasColors": { + + }, + "bars": false, + "datasource": "$datasource", + "editable": true, + "error": false, + "fill": 5, + "id": 22, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [ + + ], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "span": 3, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "rate(etcd_network_client_grpc_received_bytes_total{job=\"$cluster\"}[5m])", + "intervalFactor": 2, + "legendFormat": "{{instance}} Client Traffic In", + "metric": "etcd_network_client_grpc_received_bytes_total", + "refId": "A", + "step": 4 + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Client Traffic In", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": { + + }, + "bars": false, + "datasource": "$datasource", + "editable": true, + "error": false, + "fill": 5, + "id": 21, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [ + + ], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "span": 3, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "rate(etcd_network_client_grpc_sent_bytes_total{job=\"$cluster\"}[5m])", + "intervalFactor": 2, + "legendFormat": "{{instance}} Client Traffic Out", + "metric": "etcd_network_client_grpc_sent_bytes_total", + "refId": "A", + "step": 4 + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Client Traffic Out", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": { + + }, + "bars": false, + "datasource": "$datasource", + "editable": true, + "error": false, + "fill": 0, + "id": 20, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [ + + ], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "span": 3, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(rate(etcd_network_peer_received_bytes_total{job=\"$cluster\"}[5m])) by (instance)", + "intervalFactor": 2, + "legendFormat": "{{instance}} Peer Traffic In", + "metric": "etcd_network_peer_received_bytes_total", + "refId": "A", + "step": 4 + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Peer Traffic In", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": { + + }, + "bars": false, + "datasource": "$datasource", + "decimals": null, + "editable": true, + "error": false, + "fill": 0, + "grid": { + + }, + "id": 16, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [ + + ], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "span": 3, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(rate(etcd_network_peer_sent_bytes_total{job=\"$cluster\"}[5m])) by (instance)", + "hide": false, + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{instance}} Peer Traffic Out", + "metric": "etcd_network_peer_sent_bytes_total", + "refId": "A", + "step": 4 + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Peer Traffic Out", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "Bps", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + } + ], + "title": "New row" + }, + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "aliasColors": { + + }, + "bars": false, + "datasource": "$datasource", + "editable": true, + "error": false, + "fill": 0, + "id": 40, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [ + + ], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(rate(etcd_server_proposals_failed_total{job=\"$cluster\"}[5m]))", + "intervalFactor": 2, + "legendFormat": "Proposal Failure Rate", + "metric": "etcd_server_proposals_failed_total", + "refId": "A", + "step": 2 + }, + { + "expr": "sum(etcd_server_proposals_pending{job=\"$cluster\"})", + "intervalFactor": 2, + "legendFormat": "Proposal Pending Total", + "metric": "etcd_server_proposals_pending", + "refId": "B", + "step": 2 + }, + { + "expr": "sum(rate(etcd_server_proposals_committed_total{job=\"$cluster\"}[5m]))", + "intervalFactor": 2, + "legendFormat": "Proposal Commit Rate", + "metric": "etcd_server_proposals_committed_total", + "refId": "C", + "step": 2 + }, + { + "expr": "sum(rate(etcd_server_proposals_applied_total{job=\"$cluster\"}[5m]))", + "intervalFactor": 2, + "legendFormat": "Proposal Apply Rate", + "refId": "D", + "step": 2 + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Raft Proposals", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": { + + }, + "bars": false, + "datasource": "$datasource", + "decimals": 0, + "editable": true, + "error": false, + "fill": 0, + "id": 19, + "isNew": true, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [ + + ], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "changes(etcd_server_leader_changes_seen_total{job=\"$cluster\"}[1d])", + "intervalFactor": 2, + "legendFormat": "{{instance}} Total Leader Elections Per Day", + "metric": "etcd_server_leader_changes_seen_total", + "refId": "A", + "step": 2 + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Total Leader Elections Per Day", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + } + ], + "title": "New row" + } + ], + "schemaVersion": 13, + "sharedCrosshair": false, + "style": "dark", + "tags": [ + + ], + "templating": { + "list": [ + { + "current": { + "text": "Prometheus", + "value": "Prometheus" + }, + "hide": 0, + "label": null, + "name": "datasource", + "options": [ + + ], + "query": "prometheus", + "refresh": 1, + "regex": "", + "type": "datasource" + }, + { + "allValue": null, + "current": { + "text": "prod", + "value": "prod" + }, + "datasource": "$datasource", + "hide": 0, + "includeAll": false, + "label": "cluster", + "multi": false, + "name": "cluster", + "options": [ + + ], + "query": "label_values(etcd_server_has_leader, job)", + "refresh": 1, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [ + + ], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-15m", + "to": "now" + }, + "timepicker": { + "now": true, + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "etcd", + "version": 215 + } } diff --git a/Documentation/op-guide/grpc_proxy.md b/Documentation/op-guide/grpc_proxy.md index 70912b4f6..d06577122 100644 --- a/Documentation/op-guide/grpc_proxy.md +++ b/Documentation/op-guide/grpc_proxy.md @@ -1,4 +1,6 @@ -# gRPC proxy +--- +title: gRPC proxy +--- The gRPC proxy is a stateless etcd reverse proxy operating at the gRPC layer (L7). The proxy is designed to reduce the total processing load on the core etcd cluster. For horizontal scalability, it coalesces watch and lease API requests. To protect the cluster against abusive clients, it caches key range requests. @@ -85,7 +87,7 @@ Start the etcd gRPC proxy to use these static endpoints with the command: $ etcd grpc-proxy start --endpoints=infra0.example.com,infra1.example.com,infra2.example.com --listen-addr=127.0.0.1:2379 ``` -The etcd gRPC proxy starts and listens on port 8080. It forwards client requests to one of the three endpoints provided above. +The etcd gRPC proxy starts and listens on port 2379. It forwards client requests to one of the three endpoints provided above. Sending requests through the proxy: @@ -194,7 +196,7 @@ $ ETCDCTL_API=3 etcdctl --endpoints=localhost:2379 get my-prefix/my-key ## TLS termination -Terminate TLS from a secure etcd cluster with the grpc proxy by serving an unencrypted local endpoint. +Terminate TLS from a secure etcd cluster with the gRPC proxy by serving an unencrypted local endpoint. To try it out, start a single member etcd cluster with client https: @@ -211,7 +213,7 @@ $ ETCDCTL_API=3 etcdctl --endpoints=http://localhost:2379 endpoint status $ ETCDCTL_API=3 etcdctl --endpoints=https://localhost:2379 --cert=client.crt --key=client.key --cacert=ca.crt endpoint status ``` -Next, start a grpc proxy on `localhost:12379` by connecting to the etcd endpoint `https://localhost:2379` using the client certificates: +Next, start a gRPC proxy on `localhost:12379` by connecting to the etcd endpoint `https://localhost:2379` using the client certificates: ```sh $ etcd grpc-proxy start --endpoints=https://localhost:2379 --listen-addr localhost:12379 --cert client.crt --key client.key --cacert=ca.crt --insecure-skip-tls-verify & diff --git a/Documentation/op-guide/hardware.md b/Documentation/op-guide/hardware.md index ff946cd9b..90a6b03e2 100644 --- a/Documentation/op-guide/hardware.md +++ b/Documentation/op-guide/hardware.md @@ -1,4 +1,6 @@ -# Hardware recommendations +--- +title: Hardware recommendations +--- etcd usually runs well with limited resources for development or testing purposes; it’s common to develop with etcd on a laptop or a cheap cloud machine. However, when running etcd clusters in production, some hardware guidelines are useful for proper administration. These suggestions are not hard rules; they serve as a good starting point for a robust production deployment. As always, deployments should be tested with simulated workloads before running in production. diff --git a/Documentation/op-guide/maintenance.md b/Documentation/op-guide/maintenance.md index 85a822ef9..843ee6572 100644 --- a/Documentation/op-guide/maintenance.md +++ b/Documentation/op-guide/maintenance.md @@ -1,4 +1,6 @@ -# Maintenance +--- +title: Maintenance +--- ## Overview @@ -6,25 +8,27 @@ An etcd cluster needs periodic maintenance to remain reliable. Depending on an e All etcd maintenance manages storage resources consumed by the etcd keyspace. Failure to adequately control the keyspace size is guarded by storage space quotas; if an etcd member runs low on space, a quota will trigger cluster-wide alarms which will put the system into a limited-operation maintenance mode. To avoid running out of space for writes to the keyspace, the etcd keyspace history must be compacted. Storage space itself may be reclaimed by defragmenting etcd members. Finally, periodic snapshot backups of etcd member state makes it possible to recover any unintended logical data loss or corruption caused by operational error. -## History compaction +## Raft log retention + +`etcd --snapshot-count` configures the number of applied Raft entries to hold in-memory before compaction. When `--snapshot-count` reaches, server first persists snapshot data onto disk, and then truncates old entries. When a slow follower requests logs before a compacted index, leader sends the snapshot forcing the follower to overwrite its state. + +Higher `--snapshot-count` holds more Raft entries in memory until snapshot, thus causing [recurrent higher memory usage](https://github.com/kubernetes/kubernetes/issues/60589#issuecomment-371977156). Since leader retains latest Raft entries for longer, a slow follower has more time to catch up before leader snapshot. `--snapshot-count` is a tradeoff between higher memory usage and better availabilities of slow followers. + +Since v3.2, the default value of `--snapshot-count` has [changed from from 10,000 to 100,000](https://github.com/etcd-io/etcd/pull/7160). + +In performance-wise, `--snapshot-count` greater than 100,000 may impact the write throughput. Higher number of in-memory objects can slow down [Go GC mark phase `runtime.scanobject`](https://golang.org/src/runtime/mgc.go), and infrequent memory reclamation makes allocation slow. Performance varies depending on the workloads and system environments. However, in general, too frequent compaction affects cluster availabilities and write throughputs. Too infrequent compaction is also harmful placing too much pressure on Go garbage collector. See https://www.slideshare.net/mitakeh/understanding-performance-aspects-of-etcd-and-raft for more research results. + +## History compaction: v3 API Key-Value Database Since etcd keeps an exact history of its keyspace, this history should be periodically compacted to avoid performance degradation and eventual storage space exhaustion. Compacting the keyspace history drops all information about keys superseded prior to a given keyspace revision. The space used by these keys then becomes available for additional writes to the keyspace. The keyspace can be compacted automatically with `etcd`'s time windowed history retention policy, or manually with `etcdctl`. The `etcdctl` method provides fine-grained control over the compacting process whereas automatic compacting fits applications that only need key history for some length of time. -`etcd` can be set to automatically compact the keyspace with the `--auto-compaction` option with a period of hours: - -```sh -# keep one hour of history -$ etcd --auto-compaction-retention=1 -``` - An `etcdctl` initiated compaction works as follows: ```sh # compact up to revision 3 $ etcdctl compact 3 - ``` Revisions prior to the compaction revision become inaccessible: @@ -34,6 +38,38 @@ $ etcdctl get --rev=2 somekey Error: rpc error: code = 11 desc = etcdserver: mvcc: required revision has been compacted ``` +### Auto Compaction + +`etcd` can be set to automatically compact the keyspace with the `--auto-compaction-*` option with a period of hours: + +```sh +# keep one hour of history +$ etcd --auto-compaction-retention=1 +``` + +[v3.0.0](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.0.md) and [v3.1.0](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.1.md) with `--auto-compaction-retention=10` run periodic compaction on v3 key-value store for every 10-hour. Compactor only supports periodic compaction. Compactor records latest revisions every 5-minute, until it reaches the first compaction period (e.g. 10-hour). In order to retain key-value history of last compaction period, it uses the last revision that was fetched before compaction period, from the revision records that were collected every 5-minute. When `--auto-compaction-retention=10`, compactor uses revision 100 for compact revision where revision 100 is the latest revision fetched from 10 hours ago. If compaction succeeds or requested revision has already been compacted, it resets period timer and starts over with new historical revision records (e.g. restart revision collect and compact for the next 10-hour period). If compaction fails, it retries in 5 minutes. + +[v3.2.0](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.2.md) compactor runs [every hour](https://github.com/etcd-io/etcd/pull/7875). Compactor only supports periodic compaction. Compactor continues to record latest revisions every 5-minute. For every hour, it uses the last revision that was fetched before compaction period, from the revision records that were collected every 5-minute. That is, for every hour, compactor discards historical data created before compaction period. The retention window of compaction period moves to next hour. For instance, when hourly writes are 100 and `--auto-compaction-retention=10`, v3.1 compacts revision 1000, 2000, and 3000 for every 10-hour, while v3.2.x, v3.3.0, v3.3.1, and v3.3.2 compact revision 1000, 1100, and 1200 for every 1-hour. If compaction succeeds or requested revision has already been compacted, it resets period timer and removes used compacted revision from historical revision records (e.g. start next revision collect and compaction from previously collected revisions). If compaction fails, it retries in 5 minutes. + +In [v3.3.0](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.3.md), [v3.3.1](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.3.md), and [v3.3.2](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.3.md), `--auto-compaction-mode=revision --auto-compaction-retention=1000` automatically `Compact` on `"latest revision" - 1000` every 5-minute (when latest revision is 30000, compact on revision 29000). For instance, `--auto-compaction-mode=periodic --auto-compaction-retention=72h` automatically `Compact` with 72-hour retention windown, for every 7.2-hour. For instance, `--auto-compaction-mode=periodic --auto-compaction-retention=30m` automatically `Compact` with 30-minute retention windown, for every 3-minute. Periodic compactor continues to record latest revisions for every 1/10 of given compaction period (e.g. 1-hour when `--auto-compaction-mode=periodic --auto-compaction-retention=10h`). For every 1/10 of given compaction period, compactor uses the last revision that was fetched before compaction period, to discard historical data. The retention window of compaction period moves for every 1/10 of given compaction period. For instance, when hourly writes are 100 and `--auto-compaction-retention=10`, v3.1 compacts revision 1000, 2000, and 3000 for every 10-hour, while v3.2.x, v3.3.0, v3.3.1, and v3.3.2 compact revision 1000, 1100, and 1200 for every 1-hour. Futhermore, when writes per minute are 1000, v3.3.0, v3.3.1, and v3.3.2 with `--auto-compaction-mode=periodic --auto-compaction-retention=30m` compact revision 30000, 33000, and 36000, for every 3-minute with more finer granularity. + +When `--auto-compaction-retention=10h`, etcd first waits 10-hour for the first compaction, and then does compaction every hour (1/10 of 10-hour) afterwards like this: + +``` +0Hr (rev = 1) +1hr (rev = 10) +... +8hr (rev = 80) +9hr (rev = 90) +10hr (rev = 100, Compact(1)) +11hr (rev = 110, Compact(10)) +... +``` + +Whether compaction succeeds or not, this process repeats for every 1/10 of given compaction period. If compaction succeeds, it just removes compacted revision from historical revision records. + +In [v3.3.3](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.3.md), `--auto-compaction-mode=revision --auto-compaction-retention=1000` automatically `Compact` on `"latest revision" - 1000` every 5-minute (when latest revision is 30000, compact on revision 29000). Previously, `--auto-compaction-mode=periodic --auto-compaction-retention=72h` automatically `Compact` with 72-hour retention windown for every 7.2-hour. **Now, `Compact` happens, for every 1-hour but still with 72-hour retention window.** Previously, `--auto-compaction-mode=periodic --auto-compaction-retention=30m` automatically `Compact` with 30-minute retention windown for every 3-minute. **Now, `Compact` happens, for every 30-minute but still with 30-minute retention window.** Periodic compactor keeps recording latest revisions for every compaction period when given period is less than 1-hour, or for every 1-hour when given compaction period is greater than 1-hour (e.g. 1-hour when `--auto-compaction-mode=periodic --auto-compaction-retention=24h`). For every compaction period or 1-hour, compactor uses the last revision that was fetched before compaction period, to discard historical data. The retention window of compaction period moves for every given compaction period or hour. For instance, when hourly writes are 100 and `--auto-compaction-mode=periodic --auto-compaction-retention=24h`, `v3.2.x`, `v3.3.0`, `v3.3.1`, and `v3.3.2` compact revision 2400, 2640, and 2880 for every 2.4-hour, while `v3.3.3` *or later* compacts revision 2400, 2500, 2600 for every 1-hour. Furthermore, when `--auto-compaction-mode=periodic --auto-compaction-retention=30m` and writes per minute are about 1000, `v3.3.0`, `v3.3.1`, and `v3.3.2` compact revision 30000, 33000, and 36000, for every 3-minute, while `v3.3.3` *or later* compacts revision 30000, 60000, and 90000, for every 30-minute. + ## Defragmentation After compacting the keyspace, the backend database may exhibit internal fragmentation. Any internal fragmentation is space that is free to use by the backend but still consumes storage space. Compacting old revisions internally fragments `etcd` by leaving gaps in backend database. Fragmented space is available for use by `etcd` but unavailable to the host filesystem. In other words, deleting application data does not reclaim the space on disk. @@ -49,7 +85,16 @@ Finished defragmenting etcd member[127.0.0.1:2379] **Note that defragmentation to a live member blocks the system from reading and writing data while rebuilding its states**. -**Note that defragmentation request does not get replicated over cluster. That is, the request is only applied to the local node. Specify all members in `--endpoints` flag.** +**Note that defragmentation request does not get replicated over cluster. That is, the request is only applied to the local node. Specify all members in `--endpoints` flag or `--cluster` flag to automatically find all cluster members.** + +Run defragment operations for all endpoints in the cluster associated with the default endpoint: + +```bash +$ etcdctl defrag --cluster +Finished defragmenting etcd member[http://127.0.0.1:2379] +Finished defragmenting etcd member[http://127.0.0.1:22379] +Finished defragmenting etcd member[http://127.0.0.1:32379] +``` To defragment an etcd data directory directly, while etcd is not running, use the command: @@ -106,6 +151,10 @@ $ ETCDCTL_API=3 etcdctl put newkey 123 OK ``` +The metric `etcd_mvcc_db_total_size_in_use_in_bytes` indicates the actual database usage after a history compaction, while `etcd_debugging_mvcc_db_total_size_in_bytes` shows the database size including free space waiting for defragmentation. The latter increases only when the former is close to it, meaning when both of these metrics are close to the quota, a history compaction is required to avoid triggering the space quota. + +`etcd_debugging_mvcc_db_total_size_in_bytes` is renamed to `etcd_mvcc_db_total_size_in_bytes` from v3.4. + ## Snapshot backup Snapshotting the `etcd` cluster on a regular basis serves as a durable backup for an etcd keyspace. By taking periodic snapshots of an etcd member's backend database, an `etcd` cluster can be recovered to a point in time with a known good state. @@ -120,5 +169,4 @@ $ etcdctl --write-out=table snapshot status backup.db +----------+----------+------------+------------+ | fe01cf57 | 10 | 7 | 2.1 MB | +----------+----------+------------+------------+ - ``` diff --git a/Documentation/op-guide/monitoring.md b/Documentation/op-guide/monitoring.md index 04e717df0..4c2e7e4d4 100644 --- a/Documentation/op-guide/monitoring.md +++ b/Documentation/op-guide/monitoring.md @@ -1,4 +1,6 @@ -# Monitoring etcd +--- +title: Monitoring etcd +--- Each etcd server provides local monitoring information on its client port through http endpoints. The monitoring data is useful for both system health checking and cluster debugging. @@ -20,14 +22,14 @@ Showing top 10 nodes out of 157 (cum >= 10ms) flat flat% sum% cum cum% 130ms 27.08% 27.08% 130ms 27.08% runtime.futex 70ms 14.58% 41.67% 70ms 14.58% syscall.Syscall - 20ms 4.17% 45.83% 20ms 4.17% github.com/coreos/etcd/cmd/vendor/golang.org/x/net/http2/hpack.huffmanDecode + 20ms 4.17% 45.83% 20ms 4.17% github.com/coreos/etcd/vendor/golang.org/x/net/http2/hpack.huffmanDecode 20ms 4.17% 50.00% 30ms 6.25% runtime.pcvalue 20ms 4.17% 54.17% 50ms 10.42% runtime.schedule - 10ms 2.08% 56.25% 10ms 2.08% github.com/coreos/etcd/cmd/vendor/github.com/coreos/etcd/etcdserver.(*EtcdServer).AuthInfoFromCtx - 10ms 2.08% 58.33% 10ms 2.08% github.com/coreos/etcd/cmd/vendor/github.com/coreos/etcd/etcdserver.(*EtcdServer).Lead - 10ms 2.08% 60.42% 10ms 2.08% github.com/coreos/etcd/cmd/vendor/github.com/coreos/etcd/pkg/wait.(*timeList).Trigger - 10ms 2.08% 62.50% 10ms 2.08% github.com/coreos/etcd/cmd/vendor/github.com/prometheus/client_golang/prometheus.(*MetricVec).hashLabelValues - 10ms 2.08% 64.58% 10ms 2.08% github.com/coreos/etcd/cmd/vendor/golang.org/x/net/http2.(*Framer).WriteHeaders + 10ms 2.08% 56.25% 10ms 2.08% github.com/coreos/etcd/vendor/github.com/coreos/etcd/etcdserver.(*EtcdServer).AuthInfoFromCtx + 10ms 2.08% 58.33% 10ms 2.08% github.com/coreos/etcd/vendor/github.com/coreos/etcd/etcdserver.(*EtcdServer).Lead + 10ms 2.08% 60.42% 10ms 2.08% github.com/coreos/etcd/vendor/github.com/coreos/etcd/pkg/wait.(*timeList).Trigger + 10ms 2.08% 62.50% 10ms 2.08% github.com/coreos/etcd/vendor/github.com/prometheus/client_golang/prometheus.(*MetricVec).hashLabelValues + 10ms 2.08% 64.58% 10ms 2.08% github.com/coreos/etcd/vendor/golang.org/x/net/http2.(*Framer).WriteHeaders ``` The `/debug/requests` endpoint gives gRPC traces and performance statistics through a web browser. For example, here is a `Range` request for the key `abc`: @@ -43,7 +45,7 @@ When Elapsed (s) ## Metrics endpoint -Each etcd server exports metrics under the `/metrics` path on its client port and optionally on interfaces given by `--listen-metrics-urls`. +Each etcd server exports metrics under the `/metrics` path on its client port and optionally on locations given by `--listen-metrics-urls`. The metrics can be fetched with `curl`: @@ -59,6 +61,10 @@ etcd_disk_backend_commit_duration_seconds_bucket{le="0.016"} 406464 ... ``` +## Health Check + +Since v3.3.0, in addition to responding to the `/metrics` endpoint, any locations specified by `--listen-metrics-urls` will also respond to the `/health` endpoint. This can be useful if the standard endpoint is configured with mutual (client) TLS authentication, but a load balancer or monitoring service still needs access to the health check. + ## Prometheus Running a [Prometheus][prometheus] monitoring service is the easiest way to ingest and record etcd's metrics. @@ -117,8 +123,6 @@ Access: proxy Then import the default [etcd dashboard template][template] and customize. For instance, if Prometheus data source name is `my-etcd`, the `datasource` field values in JSON also need to be `my-etcd`. -See the [demo][demo]. - Sample dashboard: ![](./etcd-sample-grafana.png) @@ -127,4 +131,3 @@ Sample dashboard: [prometheus]: https://prometheus.io/ [grafana]: http://grafana.org/ [template]: ./grafana.json -[demo]: http://dash.etcd.io/dashboard/db/test-etcd-kubernetes diff --git a/Documentation/op-guide/performance.md b/Documentation/op-guide/performance.md index 926caf327..40bb7f956 100644 --- a/Documentation/op-guide/performance.md +++ b/Documentation/op-guide/performance.md @@ -1,10 +1,12 @@ -# Performance +--- +title: Performance +--- ## Understanding performance etcd provides stable, sustained high performance. Two factors define performance: latency and throughput. Latency is the time taken to complete an operation. Throughput is the total operations completed within some time period. Usually average latency increases as the overall throughput increases when etcd accepts concurrent client requests. In common cloud environments, like a standard `n-4` on Google Compute Engine (GCE) or a comparable machine type on AWS, a three member etcd cluster finishes a request in less than one millisecond under light load, and can complete more than 30,000 requests per second under heavy load. -etcd uses the Raft consensus algorithm to replicate requests among members and reach agreement. Consensus performance, especially commit latency, is limited by two physical constraints: network IO latency and disk IO latency. The minimum time to finish an etcd request is the network Round Trip Time (RTT) between members, plus the time `fdatasync` requires to commit the data to permanant storage. The RTT within a datacenter may be as long as several hundred microseconds. A typical RTT within the United States is around 50ms, and can be as slow as 400ms between continents. The typical fdatasync latency for a spinning disk is about 10ms. For SSDs, the latency is often lower than 1ms. To increase throughput, etcd batches multiple requests together and submits them to Raft. This batching policy lets etcd attain high throughput despite heavy load. +etcd uses the Raft consensus algorithm to replicate requests among members and reach agreement. Consensus performance, especially commit latency, is limited by two physical constraints: network IO latency and disk IO latency. The minimum time to finish an etcd request is the network Round Trip Time (RTT) between members, plus the time `fdatasync` requires to commit the data to permanent storage. The RTT within a datacenter may be as long as several hundred microseconds. A typical RTT within the United States is around 50ms, and can be as slow as 400ms between continents. The typical fdatasync latency for a spinning disk is about 10ms. For SSDs, the latency is often lower than 1ms. To increase throughput, etcd batches multiple requests together and submits them to Raft. This batching policy lets etcd attain high throughput despite heavy load. There are other sub-systems which impact the overall performance of etcd. Each serialized etcd request must run through etcd’s boltdb-backed MVCC storage engine, which usually takes tens of microseconds to finish. Periodically etcd incrementally snapshots its recently applied requests, merging them back with the previous on-disk snapshot. This process may lead to a latency spike. Although this is usually not a problem on SSDs, it may double the observed latency on HDD. Likewise, inflight compactions can impact etcd’s performance. Fortunately, the impact is often insignificant since the compaction is staggered so it does not compete for resources with regular requests. The RPC system, gRPC, gives etcd a well-defined, extensible API, but it also introduces additional latency, especially for local reads. diff --git a/Documentation/op-guide/recovery.md b/Documentation/op-guide/recovery.md index bb4a9a4ae..e20e14010 100644 --- a/Documentation/op-guide/recovery.md +++ b/Documentation/op-guide/recovery.md @@ -1,4 +1,6 @@ -# Disaster recovery +--- +title: Disaster recovery +--- etcd is designed to withstand machine failures. An etcd cluster automatically recovers from temporary failures (e.g., machine reboots) and tolerates up to *(N-1)/2* permanent failures for a cluster of N members. When a member permanently fails, whether due to hardware failure or disk corruption, it loses access to the cluster. If the cluster permanently loses more than *(N-1)/2* members then it disastrously fails, irrevocably losing quorum. Once quorum is lost, the cluster cannot reach consensus and therefore cannot continue accepting updates. @@ -61,3 +63,9 @@ $ etcd \ ``` Now the restored etcd cluster should be available and serving the keyspace given by the snapshot. + +## Restoring a cluster from membership mis-reconfiguration with wrong URLs + +Previously, etcd panics on [membership mis-reconfiguration with wrong URLs](https://github.com/etcd-io/etcd/issues/9173) (v3.2.15 or later returns [error early in client-side](https://github.com/etcd-io/etcd/pull/9174) before etcd server panic). + +Recommended way is restore from [snapshot](#snapshotting-the-keyspace). `--force-new-cluster` can be used to overwrite cluster membership while keeping existing application data, but is strongly discouraged because it will panic if other members from previous cluster are still alive. Make sure to save snapshot periodically. diff --git a/Documentation/op-guide/runtime-configuration.md b/Documentation/op-guide/runtime-configuration.md index 678e40d1e..969667072 100644 --- a/Documentation/op-guide/runtime-configuration.md +++ b/Documentation/op-guide/runtime-configuration.md @@ -1,4 +1,6 @@ -# Runtime reconfiguration +--- +title: Runtime reconfiguration +--- etcd comes with support for incremental runtime reconfiguration, which allows users to update the membership of the cluster at run time. @@ -100,7 +102,7 @@ Adding a member is a two step process: `etcdctl` adds a new member to the cluster by specifying the member's [name][conf-name] and [advertised peer URLs][conf-adv-peer]: ```sh -$ etcdctl member add infra3 http://10.0.1.13:2380 +$ etcdctl member add infra3 --peer-urls=http://10.0.1.13:2380 added member 9bf1b35fc7761a23 to cluster ETCD_NAME="infra3" diff --git a/Documentation/op-guide/runtime-reconf-design.md b/Documentation/op-guide/runtime-reconf-design.md index 3632301c4..a3a0a68ee 100644 --- a/Documentation/op-guide/runtime-reconf-design.md +++ b/Documentation/op-guide/runtime-reconf-design.md @@ -1,4 +1,6 @@ -# Design of runtime reconfiguration +--- +title: Design of runtime reconfiguration +--- Runtime reconfiguration is one of the hardest and most error prone features in a distributed system, especially in a consensus based system like etcd. @@ -6,11 +8,11 @@ Read on to learn about the design of etcd's runtime reconfiguration commands and ## Two phase config changes keep the cluster safe -In etcd, every runtime reconfiguration has to go through [two phases][add-member] for safety reasons. For example, to add a member, first inform cluster of new configuration and then start the new member. +In etcd, every runtime reconfiguration has to go through [two phases][add-member] for safety reasons. For example, to add a member, first inform the cluster of the new configuration and then start the new member. Phase 1 - Inform cluster of new configuration -To add a member into etcd cluster, make an API call to request a new member to be added to the cluster. This is the only way to add a new member into an existing cluster. The API call returns when the cluster agrees on the configuration change. +To add a member into an etcd cluster, make an API call to request a new member to be added to the cluster. This is the only way to add a new member into an existing cluster. The API call returns when the cluster agrees on the configuration change. Phase 2 - Start new member @@ -28,19 +30,19 @@ If a cluster permanently loses a majority of its members, a new cluster will nee It is entirely possible to force removing the failed members from the existing cluster to recover. However, we decided not to support this method since it bypasses the normal consensus committing phase, which is unsafe. If the member to remove is not actually dead or force removed through different members in the same cluster, etcd will end up with a diverged cluster with same clusterID. This is very dangerous and hard to debug/fix afterwards. -With a correct deployment, the possibility of permanent majority lose is very low. But it is a severe enough problem that worth special care. We strongly suggest reading the [disaster recovery documentation][disaster-recovery] and preparing for permanent majority lose before putting etcd into production. +With a correct deployment, the possibility of permanent majority loss is very low. But it is a severe enough problem that is worth special care. We strongly suggest reading the [disaster recovery documentation][disaster-recovery] and preparing for permanent majority loss before putting etcd into production. ## Do not use public discovery service for runtime reconfiguration -The public discovery service should only be used for bootstrapping a cluster. To join member into an existing cluster, use runtime reconfiguration API. +The public discovery service should only be used for bootstrapping a cluster. To join member into an existing cluster, use the runtime reconfiguration API. -Discovery service is designed for bootstrapping an etcd cluster in the cloud environment, when the IP addresses of all the members are not known beforehand. After successfully bootstrapping a cluster, the IP addresses of all the members are known. Technically, the discovery service should no longer be needed. +The discovery service is designed for bootstrapping an etcd cluster in a cloud environment, when the IP addresses of all the members are not known beforehand. After successfully bootstrapping a cluster, the IP addresses of all the members are known. Technically, the discovery service should no longer be needed. It seems that using public discovery service is a convenient way to do runtime reconfiguration, after all discovery service already has all the cluster configuration information. However relying on public discovery service brings troubles: 1. it introduces external dependencies for the entire life-cycle of the cluster, not just bootstrap time. If there is a network issue between the cluster and public discovery service, the cluster will suffer from it. -2. public discovery service must reflect correct runtime configuration of the cluster during it life-cycle. It has to provide security mechanism to avoid bad actions, and it is hard. +2. public discovery service must reflect correct runtime configuration of the cluster during its life-cycle. It has to provide security mechanisms to avoid bad actions, and it is hard. 3. public discovery service has to keep tens of thousands of cluster configurations. Our public discovery service backend is not ready for that workload. diff --git a/Documentation/op-guide/security.md b/Documentation/op-guide/security.md index 8cb199196..305cbb2fe 100644 --- a/Documentation/op-guide/security.md +++ b/Documentation/op-guide/security.md @@ -1,4 +1,6 @@ -# Transport security model +--- +title: Transport security model +--- etcd supports automatic TLS as well as authentication through client certificates for both clients to server as well as peer (server to server / cluster) communication. @@ -38,6 +40,8 @@ The peer options work the same way as the client-to-server options: If either a client-to-server or peer certificate is supplied the key must also be set. All of these configuration options are also available through the environment variables, `ETCD_CA_FILE`, `ETCD_PEER_CA_FILE` and so on. +`--cipher-suites`: Comma-separated list of supported TLS cipher suites between server/client and peers (empty will be auto-populated by Go). Available from v3.2.22+, v3.3.7+, and v3.4+. + ## Example 1: Client-to-server transport security with HTTPS For this, have a CA certificate (`ca.crt`) and signed key pair (`server.crt`, `server.key`) ready. @@ -122,6 +126,49 @@ And also the response from the server: } ``` +Specify cipher suites to block [weak TLS cipher suites](https://github.com/etcd-io/etcd/issues/8320). + +TLS handshake would fail when client hello is requested with invalid cipher suites. + +For instance: + +```bash +$ etcd \ + --cert-file ./server.crt \ + --key-file ./server.key \ + --trusted-ca-file ./ca.crt \ + --cipher-suites TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 +``` + +Then, client requests must specify one of the cipher suites specified in the server: + +```bash +# valid cipher suite +$ curl \ + --cacert ./ca.crt \ + --cert ./server.crt \ + --key ./server.key \ + -L [CLIENT-URL]/metrics \ + --ciphers ECDHE-RSA-AES128-GCM-SHA256 + +# request succeeds +etcd_server_version{server_version="3.2.22"} 1 +... +``` + +```bash +# invalid cipher suite +$ curl \ + --cacert ./ca.crt \ + --cert ./server.crt \ + --key ./server.key \ + -L [CLIENT-URL]/metrics \ + --ciphers ECDHE-RSA-DES-CBC3-SHA + +# request fails with +(35) error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure +``` + ## Example 3: Transport security & client certificates in a cluster etcd supports the same model as above for **peer communication**, that means the communication between etcd members in a cluster. @@ -195,9 +242,9 @@ When client authentication is enabled for an etcd member, the administrator must ## Notes for TLS authentication -Since [v3.2.0](https://github.com/coreos/etcd/blob/master/CHANGELOG-3.2.md#v320-2017-06-09), [TLS certificates get reloaded on every client connection](https://github.com/coreos/etcd/pull/7829). This is useful when replacing expiry certs without stopping etcd servers; it can be done by overwriting old certs with new ones. Refreshing certs for every connection should not have too much overhead, but can be improved in the future, with caching layer. Example tests can be found [here](https://github.com/coreos/etcd/blob/b041ce5d514a4b4aaeefbffb008f0c7570a18986/integration/v3_grpc_test.go#L1601-L1757). +Since [v3.2.0](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.2.md#v320-2017-06-09), [TLS certificates get reloaded on every client connection](https://github.com/etcd-io/etcd/pull/7829). This is useful when replacing expiry certs without stopping etcd servers; it can be done by overwriting old certs with new ones. Refreshing certs for every connection should not have too much overhead, but can be improved in the future, with caching layer. Example tests can be found [here](https://github.com/coreos/etcd/blob/b041ce5d514a4b4aaeefbffb008f0c7570a18986/integration/v3_grpc_test.go#L1601-L1757). -Since [v3.2.0](https://github.com/coreos/etcd/blob/master/CHANGELOG-3.2.md#v320-2017-06-09), [server denies incoming peer certs with wrong IP `SAN`](https://github.com/coreos/etcd/pull/7687). For instance, if peer cert contains any IP addresses in Subject Alternative Name (SAN) field, server authenticates a peer only when the remote IP address matches one of those IP addresses. This is to prevent unauthorized endpoints from joining the cluster. For example, peer B's CSR (with `cfssl`) is: +Since [v3.2.0](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.2.md#v320-2017-06-09), [server denies incoming peer certs with wrong IP `SAN`](https://github.com/etcd-io/etcd/pull/7687). For instance, if peer cert contains any IP addresses in Subject Alternative Name (SAN) field, server authenticates a peer only when the remote IP address matches one of those IP addresses. This is to prevent unauthorized endpoints from joining the cluster. For example, peer B's CSR (with `cfssl`) is: ```json { @@ -223,7 +270,7 @@ Since [v3.2.0](https://github.com/coreos/etcd/blob/master/CHANGELOG-3.2.md#v320- when peer B's actual IP address is `10.138.0.2`, not `10.138.0.27`. When peer B tries to join the cluster, peer A will reject B with the error `x509: certificate is valid for 10.138.0.27, not 10.138.0.2`, because B's remote IP address does not match the one in Subject Alternative Name (SAN) field. -Since [v3.2.0](https://github.com/coreos/etcd/blob/master/CHANGELOG-3.2.md#v320-2017-06-09), [server resolves TLS `DNSNames` when checking `SAN`](https://github.com/coreos/etcd/pull/7767). For instance, if peer cert contains only DNS names (no IP addresses) in Subject Alternative Name (SAN) field, server authenticates a peer only when forward-lookups (`dig b.com`) on those DNS names have matching IP with the remote IP address. For example, peer B's CSR (with `cfssl`) is: +Since [v3.2.0](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.2.md#v320-2017-06-09), [server resolves TLS `DNSNames` when checking `SAN`](https://github.com/etcd-io/etcd/pull/7767). For instance, if peer cert contains only DNS names (no IP addresses) in Subject Alternative Name (SAN) field, server authenticates a peer only when forward-lookups (`dig b.com`) on those DNS names have matching IP with the remote IP address. For example, peer B's CSR (with `cfssl`) is: ```json { @@ -235,7 +282,7 @@ Since [v3.2.0](https://github.com/coreos/etcd/blob/master/CHANGELOG-3.2.md#v320- when peer B's remote IP address is `10.138.0.2`. When peer B tries to join the cluster, peer A looks up the incoming host `b.com` to get the list of IP addresses (e.g. `dig b.com`). And rejects B if the list does not contain the IP `10.138.0.2`, with the error `tls: 10.138.0.2 does not match any of DNSNames ["b.com"]`. -Since [v3.2.2](https://github.com/coreos/etcd/blob/master/CHANGELOG-3.2.md#v322-2017-07-07), [server accepts connections if IP matches, without checking DNS entries](https://github.com/coreos/etcd/pull/8223). For instance, if peer cert contains IP addresses and DNS names in Subject Alternative Name (SAN) field, and the remote IP address matches one of those IP addresses, server just accepts connection without further checking the DNS names. For example, peer B's CSR (with `cfssl`) is: +Since [v3.2.2](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.2.md#v322-2017-07-07), [server accepts connections if IP matches, without checking DNS entries](https://github.com/etcd-io/etcd/pull/8223). For instance, if peer cert contains IP addresses and DNS names in Subject Alternative Name (SAN) field, and the remote IP address matches one of those IP addresses, server just accepts connection without further checking the DNS names. For example, peer B's CSR (with `cfssl`) is: ```json { @@ -246,9 +293,9 @@ Since [v3.2.2](https://github.com/coreos/etcd/blob/master/CHANGELOG-3.2.md#v322- ], ``` -when peer B's remote IP address is `10.138.0.2` and `invalid.domain` is a invalid host. When peer B tries to join the cluster, peer A successfully authenticates B, since Subject Alternative Name (SAN) field has a valid matching IP address. See [issue#8206](https://github.com/coreos/etcd/issues/8206) for more detail. +when peer B's remote IP address is `10.138.0.2` and `invalid.domain` is a invalid host. When peer B tries to join the cluster, peer A successfully authenticates B, since Subject Alternative Name (SAN) field has a valid matching IP address. See [issue#8206](https://github.com/etcd-io/etcd/issues/8206) for more detail. -Since [v3.2.5](https://github.com/coreos/etcd/blob/master/CHANGELOG-3.2.md#v325-2017-08-04), [server supports reverse-lookup on wildcard DNS `SAN`](https://github.com/coreos/etcd/pull/8281). For instance, if peer cert contains only DNS names (no IP addresses) in Subject Alternative Name (SAN) field, server first reverse-lookups the remote IP address to get a list of names mapping to that address (e.g. `nslookup IPADDR`). Then accepts the connection if those names have a matching name with peer cert's DNS names (either by exact or wildcard match). If none is matched, server forward-lookups each DNS entry in peer cert (e.g. look up `example.default.svc` when the entry is `*.example.default.svc`), and accepts connection only when the host's resolved addresses have the matching IP address with the peer's remote IP address. For example, peer B's CSR (with `cfssl`) is: +Since [v3.2.5](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.2.md#v325-2017-08-04), [server supports reverse-lookup on wildcard DNS `SAN`](https://github.com/etcd-io/etcd/pull/8281). For instance, if peer cert contains only DNS names (no IP addresses) in Subject Alternative Name (SAN) field, server first reverse-lookups the remote IP address to get a list of names mapping to that address (e.g. `nslookup IPADDR`). Then accepts the connection if those names have a matching name with peer cert's DNS names (either by exact or wildcard match). If none is matched, server forward-lookups each DNS entry in peer cert (e.g. look up `example.default.svc` when the entry is `*.example.default.svc`), and accepts connection only when the host's resolved addresses have the matching IP address with the peer's remote IP address. For example, peer B's CSR (with `cfssl`) is: ```json { @@ -259,9 +306,9 @@ Since [v3.2.5](https://github.com/coreos/etcd/blob/master/CHANGELOG-3.2.md#v325- ], ``` -when peer B's remote IP address is `10.138.0.2`. When peer B tries to join the cluster, peer A reverse-lookup the IP `10.138.0.2` to get the list of host names. And either exact or wildcard match the host names with peer B's cert DNS names in Subject Alternative Name (SAN) field. If none of reverse/forward lookups worked, it returns an error `"tls: "10.138.0.2" does not match any of DNSNames ["*.example.default.svc","*.example.default.svc.cluster.local"]`. See [issue#8268](https://github.com/coreos/etcd/issues/8268) for more detail. +when peer B's remote IP address is `10.138.0.2`. When peer B tries to join the cluster, peer A reverse-lookup the IP `10.138.0.2` to get the list of host names. And either exact or wildcard match the host names with peer B's cert DNS names in Subject Alternative Name (SAN) field. If none of reverse/forward lookups worked, it returns an error `"tls: "10.138.0.2" does not match any of DNSNames ["*.example.default.svc","*.example.default.svc.cluster.local"]`. See [issue#8268](https://github.com/etcd-io/etcd/issues/8268) for more detail. -[v3.3.0](https://github.com/coreos/etcd/blob/master/CHANGELOG-3.3.md) adds [`etcd --peer-cert-allowed-cn`](https://github.com/coreos/etcd/pull/8616) flag to support [CN(Common Name)-based auth for inter-peer connections](https://github.com/coreos/etcd/issues/8262). Kubernetes TLS bootstrapping involves generating dynamic certificates for etcd members and other system components (e.g. API server, kubelet, etc.). Maintaining different CAs for each component provides tighter access control to etcd cluster but often tedious. When `--peer-cert-allowed-cn` flag is specified, node can only join with matching common name even with shared CAs. For example, each member in 3-node cluster is set up with CSRs (with `cfssl`) as below: +[v3.3.0](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.3.md) adds [`etcd --peer-cert-allowed-cn`](https://github.com/etcd-io/etcd/pull/8616) flag to support [CN(Common Name)-based auth for inter-peer connections](https://github.com/etcd-io/etcd/issues/8262). Kubernetes TLS bootstrapping involves generating dynamic certificates for etcd members and other system components (e.g. API server, kubelet, etc.). Maintaining different CAs for each component provides tighter access control to etcd cluster but often tedious. When `--peer-cert-allowed-cn` flag is specified, node can only join with matching common name even with shared CAs. For example, each member in 3-node cluster is set up with CSRs (with `cfssl`) as below: ```json { @@ -321,6 +368,35 @@ I | embed: serving client requests on 127.0.0.1:22379 I | embed: serving client requests on 127.0.0.1:2379 ``` +[v3.2.19](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.2.md) and [v3.3.4](https://github.com/etcd-io/etcd/blob/master/CHANGELOG-3.3.md) fixes TLS reload when [certificate SAN field only includes IP addresses but no domain names](https://github.com/etcd-io/etcd/issues/9541). For example, a member is set up with CSRs (with `cfssl`) as below: + +```json +{ + "CN": "etcd.local", + "hosts": [ + "127.0.0.1" + ], +``` + +In Go, server calls `(*tls.Config).GetCertificate` for TLS reload if and only if server's `(*tls.Config).Certificates` field is not empty, or `(*tls.ClientHelloInfo).ServerName` is not empty with a valid SNI from the client. Previously, etcd always populates `(*tls.Config).Certificates` on the initial client TLS handshake, as non-empty. Thus, client was always expected to supply a matching SNI in order to pass the TLS verification and to trigger `(*tls.Config).GetCertificate` to reload TLS assets. + +However, a certificate whose SAN field does [not include any domain names but only IP addresses](https://github.com/etcd-io/etcd/issues/9541) would request `*tls.ClientHelloInfo` with an empty `ServerName` field, thus failing to trigger the TLS reload on initial TLS handshake; this becomes a problem when expired certificates need to be replaced online. + +Now, `(*tls.Config).Certificates` is created empty on initial TLS client handshake, first to trigger `(*tls.Config).GetCertificate`, and then to populate rest of the certificates on every new TLS connection, even when client SNI is empty (e.g. cert only includes IPs). + +## Notes for Host Whitelist + +`etcd --host-whitelist` flag specifies acceptable hostnames from HTTP client requests. Client origin policy protects against ["DNS Rebinding"](https://en.wikipedia.org/wiki/DNS_rebinding) attacks to insecure etcd servers. That is, any website can simply create an authorized DNS name, and direct DNS to `"localhost"` (or any other address). Then, all HTTP endpoints of etcd server listening on `"localhost"` becomes accessible, thus vulnerable to DNS rebinding attacks. See [CVE-2018-5702](https://bugs.chromium.org/p/project-zero/issues/detail?id=1447#c2) for more detail. + +Client origin policy works as follows: + +1. If client connection is secure via HTTPS, allow any hostnames. +2. If client connection is not secure and `"HostWhitelist"` is not empty, only allow HTTP requests whose Host field is listed in whitelist. + +Note that the client origin policy is enforced whether authentication is enabled or not, for tighter controls. + +By default, `etcd --host-whitelist` and `embed.Config.HostWhitelist` are set *empty* to allow all hostnames. Note that when specifying hostnames, loopback addresses are not added automatically. To allow loopback interfaces, add them to whitelist manually (e.g. `"localhost"`, `"127.0.0.1"`, etc.). + ## Frequently asked questions ### I'm seeing a SSLv3 alert handshake failure when using TLS client authentication? diff --git a/Documentation/op-guide/supported-platform.md b/Documentation/op-guide/supported-platform.md index 37affd7c9..31df649fe 100644 --- a/Documentation/op-guide/supported-platform.md +++ b/Documentation/op-guide/supported-platform.md @@ -1,4 +1,6 @@ -# Supported systems +--- +title: Supported systems +--- ## Current support @@ -6,7 +8,7 @@ The following table lists etcd support status for common architectures and opera | Architecture | Operating System | Status | Maintainers | | ------------ | ---------------- | ------------ | --------------------------- | -| amd64 | Darwin | Experimental | etcd maintainers | +| amd64 | Darwin | Experimental | etcd maintainers | | amd64 | Linux | Stable | etcd maintainers | | amd64 | Windows | Experimental | | | arm64 | Linux | Experimental | @glevand | @@ -14,7 +16,7 @@ The following table lists etcd support status for common architectures and opera | 386 | Linux | Unstable | | | ppc64le | Linux | Stable | etcd maintainers, @mkumatag | -* etcd-maintainers are listed in https://github.com/coreos/etcd/blob/master/MAINTAINERS. +* etcd-maintainers are listed in https://github.com/etcd-io/etcd/blob/master/MAINTAINERS. Experimental platforms appear to work in practice and have some platform specific code in etcd, but do not fully conform to the stable support policy. Unstable platforms have been lightly tested, but less than experimental. Unlisted architecture and operating system pairs are currently unsupported; caveat emptor. diff --git a/Documentation/op-guide/v2-migration.md b/Documentation/op-guide/v2-migration.md index 632a79893..981ace24f 100644 --- a/Documentation/op-guide/v2-migration.md +++ b/Documentation/op-guide/v2-migration.md @@ -1,4 +1,6 @@ -# Migrate applications from using API v2 to API v3 +--- +title: Migrate applications from using API v2 to API v3 +--- The data store v2 is still accessible from the API v2 after upgrading to etcd3. Thus, it will work as before and require no application changes. With etcd 3, applications use the new grpc API v3 to access the mvcc store, which provides more features and improved performance. The mvcc store and the old store v2 are separate and isolated; writes to the store v2 will not affect the mvcc store and, similarly, writes to the mvcc store will not affect the store v2. diff --git a/Documentation/op-guide/versioning.md b/Documentation/op-guide/versioning.md index 192a39ac6..0ee0edec2 100644 --- a/Documentation/op-guide/versioning.md +++ b/Documentation/op-guide/versioning.md @@ -1,4 +1,6 @@ -# Versioning +--- +title: Versioning +--- ## Service versioning diff --git a/Documentation/platforms/_index.md b/Documentation/platforms/_index.md new file mode 100644 index 000000000..64b52761c --- /dev/null +++ b/Documentation/platforms/_index.md @@ -0,0 +1,3 @@ +--- +title: Platforms +--- \ No newline at end of file diff --git a/Documentation/platforms/aws.md b/Documentation/platforms/aws.md index 071b225ef..546df3fae 100644 --- a/Documentation/platforms/aws.md +++ b/Documentation/platforms/aws.md @@ -1,4 +1,6 @@ -# Amazon Web Services +--- +title: Amazon Web Services +--- This guide assumes operational knowledge of Amazon Web Services (AWS), specifically Amazon Elastic Compute Cloud (EC2). This guide provides an introduction to design considerations when designing an etcd deployment on AWS EC2 and how AWS specific features may be utilized in that context. diff --git a/Documentation/platforms/container-linux-systemd.md b/Documentation/platforms/container-linux-systemd.md index b9d964038..d29cef937 100644 --- a/Documentation/platforms/container-linux-systemd.md +++ b/Documentation/platforms/container-linux-systemd.md @@ -1,4 +1,6 @@ -# Container Linux with systemd +--- +title: Container Linux with systemd +--- The following guide shows how to run etcd with [systemd][systemd-docs] under [Container Linux][container-linux-docs]. diff --git a/Documentation/platforms/freebsd.md b/Documentation/platforms/freebsd.md index f781a96ad..353bba254 100644 --- a/Documentation/platforms/freebsd.md +++ b/Documentation/platforms/freebsd.md @@ -1,4 +1,6 @@ -# FreeBSD +--- +title: FreeBSD +--- Starting with version 0.1.2 both etcd and etcdctl have been ported to FreeBSD and can be installed either via packages or ports system. Their versions have been recently updated to 0.2.0 so now etcd and etcdctl can be enjoyed on FreeBSD 10.0 (RC4 as of now) and 9.x, where they have been tested. They might also work when installed from ports on earlier versions of FreeBSD, but it is untested; caveat emptor. diff --git a/Documentation/production-users.md b/Documentation/production-users.md index 08a6b21bc..c6c294637 100644 --- a/Documentation/production-users.md +++ b/Documentation/production-users.md @@ -1,4 +1,6 @@ -# Production users +--- +title: Production users +--- This document tracks people and use cases for etcd in production. By creating a list of production use cases we hope to build a community of advisors that we can reach out to with experience using various etcd applications, operation environments, and cluster sizes. The etcd development team may reach out periodically to check-in on how etcd is working in the field and update this list. @@ -237,3 +239,12 @@ At [Branch][branch], we use kubernetes heavily as our core microservice platform - *Environment*: Bare Metal - *Backups*: None, all data is considered ephemeral. +## Transwarp + +- *Application*: Transwarp Data Cloud, Transwarp Operating System, Transwarp Data Hub, Sophon +- *Launched*: January 2016 +- *Cluster Size*: Multiple clusters, multiple sizes +- *Order of Data Size*: Megabytes +- *Operator*: Trasnwarp Operating System +- *Environment*: Bare Metal, Container +- *Backups*: backup scripts diff --git a/Documentation/reporting_bugs.md b/Documentation/reporting_bugs.md index d9284368a..c64ebf3b0 100644 --- a/Documentation/reporting_bugs.md +++ b/Documentation/reporting_bugs.md @@ -1,4 +1,6 @@ -# Reporting bugs +--- +title: Reporting bugs +--- If any part of the etcd project has bugs or documentation mistakes, please let us know by [opening an issue][etcd-issue]. We treat bugs and mistakes very seriously and believe no issue is too small. Before creating a bug report, please check that an issue reporting the same problem does not already exist. @@ -41,5 +43,5 @@ $ sudo journalctl -u etcd2 Due to an upstream systemd bug, journald may miss the last few log lines when its processes exit. If journalctl says etcd stopped without fatal or panic message, try `sudo journalctl -f -t etcd2` to get full log. -[etcd-issue]: https://github.com/coreos/etcd/issues/new +[etcd-issue]: https://github.com/etcd-io/etcd/issues/new [filing-good-bugs]: http://fantasai.inkedblade.net/style/talks/filing-good-bugs/ diff --git a/Documentation/v2/rfc/v3api.md b/Documentation/rfc/_index.md similarity index 93% rename from Documentation/v2/rfc/v3api.md rename to Documentation/rfc/_index.md index 18567d36b..37b08181a 100644 --- a/Documentation/v2/rfc/v3api.md +++ b/Documentation/rfc/_index.md @@ -1,9 +1,6 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../../docs.md#documentation - - -# Overview +--- +title: etcd v3 API +--- The etcd v3 API is designed to give users a more efficient and cleaner abstraction compared to etcd v2. There are a number of semantic and protocol changes in this new API. For an overview [see Xiang Li's video](https://youtu.be/J5AioGtEPeQ?t=211). @@ -57,6 +54,7 @@ the size in the future a little bit or make it configurable. ## Examples ### Put a key (foo=bar) + ``` // A put is always successful Put( PutRequest { key = foo, value = bar } ) @@ -212,5 +210,5 @@ WatchResponse { ``` -[api-protobuf]: https://github.com/coreos/etcd/blob/release-2.3/etcdserver/etcdserverpb/rpc.proto -[kv-protobuf]: https://github.com/coreos/etcd/blob/release-2.3/storage/storagepb/kv.proto +[api-protobuf]: https://github.com/etcd-io/etcd/blob/master/etcdserver/etcdserverpb/rpc.proto +[kv-protobuf]: https://github.com/etcd-io/etcd/blob/master/mvcc/mvccpb/kv.proto diff --git a/Documentation/rfc/v3api.md b/Documentation/rfc/v3api.md deleted file mode 100644 index 1371347e1..000000000 --- a/Documentation/rfc/v3api.md +++ /dev/null @@ -1,211 +0,0 @@ -# Overview - -The etcd v3 API is designed to give users a more efficient and cleaner abstraction compared to etcd v2. There are a number of semantic and protocol changes in this new API. For an overview [see Xiang Li's video](https://youtu.be/J5AioGtEPeQ?t=211). - -To prove out the design of the v3 API the team has also built [a number of example recipes](https://github.com/coreos/etcd/tree/master/contrib/recipes), there is a [video discussing these recipes too](https://www.youtube.com/watch?v=fj-2RY-3yVU&feature=youtu.be&t=590). - -# Design - -1. Flatten binary key-value space - -2. Keep the event history until compaction - - access to old version of keys - - user controlled history compaction - -3. Support range query - - Pagination support with limit argument - - Support consistency guarantee across multiple range queries - -4. Replace TTL key with Lease - - more efficient/ low cost keep alive - - a logical group of TTL keys - -5. Replace CAS/CAD with multi-object Txn - - MUCH MORE powerful and flexible - -6. Support efficient watching with multiple ranges - -7. RPC API supports the completed set of APIs. - - more efficient than JSON/HTTP - - additional txn/lease support - -8. HTTP API supports a subset of APIs. - - easy for people to try out etcd - - easy for people to write simple etcd application - - -## Notes - -### Request Size Limitation - -The max request size is around 1MB. Since etcd replicates requests in a streaming fashion, a very large -request might block other requests for a long time. The use case for etcd is to store small configuration -values, so we prevent user from submitting large requests. This also applies to Txn requests. We might loosen -the size in the future a little bit or make it configurable. - -## Protobuf Defined API - -[api protobuf][api-protobuf] - -[kv protobuf][kv-protobuf] - -## Examples - -### Put a key (foo=bar) -``` -// A put is always successful -Put( PutRequest { key = foo, value = bar } ) - -PutResponse { - cluster_id = 0x1000, - member_id = 0x1, - revision = 1, - raft_term = 0x1, -} -``` - -### Get a key (assume we have foo=bar) -``` -Get ( RangeRequest { key = foo } ) - -RangeResponse { - cluster_id = 0x1000, - member_id = 0x1, - revision = 1, - raft_term = 0x1, - kvs = { - { - key = foo, - value = bar, - create_revision = 1, - mod_revision = 1, - version = 1; - }, - }, -} -``` - -### Range over a key space (assume we have foo0=bar0… foo100=bar100) -``` -Range ( RangeRequest { key = foo, end_key = foo80, limit = 30 } ) - -RangeResponse { - cluster_id = 0x1000, - member_id = 0x1, - revision = 100, - raft_term = 0x1, - kvs = { - { - key = foo0, - value = bar0, - create_revision = 1, - mod_revision = 1, - version = 1; - }, - ..., - { - key = foo30, - value = bar30, - create_revision = 30, - mod_revision = 30, - version = 1; - }, - }, -} -``` - -### Finish a txn (assume we have foo0=bar0, foo1=bar1) -``` -Txn(TxnRequest { - // mod_revision of foo0 is equal to 1, mod_revision of foo1 is greater than 1 - compare = { - {compareType = equal, key = foo0, mod_revision = 1}, - {compareType = greater, key = foo1, mod_revision = 1}} - }, - // if the comparison succeeds, put foo2 = bar2 - success = {PutRequest { key = foo2, value = success }}, - // if the comparison fails, put foo2=fail - failure = {PutRequest { key = foo2, value = failure }}, -) - -TxnResponse { - cluster_id = 0x1000, - member_id = 0x1, - revision = 3, - raft_term = 0x1, - succeeded = true, - responses = { - // response of PUT foo2=success - { - cluster_id = 0x1000, - member_id = 0x1, - revision = 3, - raft_term = 0x1, - } - } -} -``` - -### Watch on a key/range - -``` -Watch( WatchRequest{ - key = foo, - end_key = fop, // prefix foo - start_revision = 20, - end_revision = 10000, - // server decided notification frequency - progress_notification = true, - } - … // this can be a watch request stream - ) - -// put (foo0=bar0) event at 3 -WatchResponse { - cluster_id = 0x1000, - member_id = 0x1, - revision = 3, - raft_term = 0x1, - event_type = put, - kv = { - key = foo0, - value = bar0, - create_revision = 1, - mod_revision = 1, - version = 1; - }, - } - … - - // a notification at 2000 - WatchResponse { - cluster_id = 0x1000, - member_id = 0x1, - revision = 2000, - raft_term = 0x1, - // nil event as notification - } - - … - - // put (foo0=bar3000) event at 3000 - WatchResponse { - cluster_id = 0x1000, - member_id = 0x1, - revision = 3000, - raft_term = 0x1, - event_type = put, - kv = { - key = foo0, - value = bar3000, - create_revision = 1, - mod_revision = 3000, - version = 2; - }, - } - … - -``` - -[api-protobuf]: https://github.com/coreos/etcd/blob/master/etcdserver/etcdserverpb/rpc.proto -[kv-protobuf]: https://github.com/coreos/etcd/blob/master/mvcc/mvccpb/kv.proto diff --git a/Documentation/tuning.md b/Documentation/tuning.md index 087d39d18..87e016db8 100644 --- a/Documentation/tuning.md +++ b/Documentation/tuning.md @@ -1,4 +1,6 @@ -# Tuning +--- +title: Tuning +--- The default settings in etcd should work well for installations on a local network where the average network latency is low. However, when using etcd across multiple data centers or over networks with high latency, the heartbeat interval and election timeout settings may need tuning. @@ -71,12 +73,12 @@ dropped MsgAppResp to 247ae21ff9436b2d since streamMsg's sending buffer is full These errors may be resolved by prioritizing etcd's peer traffic over its client traffic. On Linux, peer traffic can be prioritized by using the traffic control mechanism: -``` +```sh tc qdisc add dev eth0 root handle 1: prio bands 3 tc filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip sport 2380 0xffff flowid 1:1 tc filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip dport 2380 0xffff flowid 1:1 -tc filter add dev eth0 parent 1: protocol ip prio 2 u32 match ip sport 2739 0xffff flowid 1:1 -tc filter add dev eth0 parent 1: protocol ip prio 2 u32 match ip dport 2739 0xffff flowid 1:1 +tc filter add dev eth0 parent 1: protocol ip prio 2 u32 match ip sport 2379 0xffff flowid 1:1 +tc filter add dev eth0 parent 1: protocol ip prio 2 u32 match ip dport 2379 0xffff flowid 1:1 ``` [ping]: https://en.wikipedia.org/wiki/Ping_(networking_utility) diff --git a/Documentation/upgrades/_index.md b/Documentation/upgrades/_index.md new file mode 100644 index 000000000..ab2858c3b --- /dev/null +++ b/Documentation/upgrades/_index.md @@ -0,0 +1,3 @@ +--- +title: Upgrading +--- \ No newline at end of file diff --git a/Documentation/upgrades/upgrade_3_0.md b/Documentation/upgrades/upgrade_3_0.md index 7455426b3..36fc061e8 100644 --- a/Documentation/upgrades/upgrade_3_0.md +++ b/Documentation/upgrades/upgrade_3_0.md @@ -1,4 +1,6 @@ -## Upgrade etcd from 2.3 to 3.0 +--- +title: Upgrade etcd from 2.3 to 3.0 +--- In the general case, upgrading from etcd 2.3 to 3.0 can be a zero-downtime, rolling upgrade: - one by one, stop the etcd v2.3 processes and replace them with etcd v3.0 processes @@ -8,7 +10,7 @@ Before [starting an upgrade](#upgrade-procedure), read through the rest of this ### Upgrade checklists -**NOTE:** When [migrating from v2 with no v3 data](https://github.com/coreos/etcd/issues/9480), etcd server v3.2+ panics when etcd restores from existing snapshots but no v3 `ETCD_DATA_DIR/member/snap/db` file. This happens when the server had migrated from v2 with no previous v3 data. This also prevents accidental v3 data loss (e.g. `db` file might have been moved). etcd requires that post v3 migration can only happen with v3 data. Do not upgrade to newer v3 versions until v3.0 server contains v3 data. +**NOTE:** When [migrating from v2 with no v3 data](https://github.com/etcd-io/etcd/issues/9480), etcd server v3.2+ panics when etcd restores from existing snapshots but no v3 `ETCD_DATA_DIR/member/snap/db` file. This happens when the server had migrated from v2 with no previous v3 data. This also prevents accidental v3 data loss (e.g. `db` file might have been moved). etcd requires that post v3 migration can only happen with v3 data. Do not upgrade to newer v3 versions until v3.0 server contains v3 data. #### Upgrade requirements @@ -124,8 +126,8 @@ $ ETCDCTL_API=3 etcdctl endpoint health ## Known Issues -- etcd < v3.1 does not work properly if built with Go > v1.7. See [Issue 6951](https://github.com/coreos/etcd/issues/6951) for additional information. +- etcd < v3.1 does not work properly if built with Go > v1.7. See [Issue 6951](https://github.com/etcd-io/etcd/issues/6951) for additional information. - If an error such as `transport: http2Client.notifyError got notified that the client transport was broken unexpected EOF.` shows up in the etcd server logs, be sure etcd is a pre-built release or built with (etcd v3.1+ & go v1.7+) or (etcd <v3.1 & go v1.6.x). -- Adding a v3 node to v2.3 cluster during upgrades is not supported and could trigger panics. See [Issue 7249](https://github.com/coreos/etcd/issues/7429) for additional information. Mixed versions of etcd members are only allowed during v3 migration. Finish upgrades before making any membership changes. +- Adding a v3 node to v2.3 cluster during upgrades is not supported and could trigger panics. See [Issue 7249](https://github.com/etcd-io/etcd/issues/7429) for additional information. Mixed versions of etcd members are only allowed during v3 migration. Finish upgrades before making any membership changes. [etcd-contact]: https://groups.google.com/forum/#!forum/etcd-dev diff --git a/Documentation/upgrades/upgrade_3_1.md b/Documentation/upgrades/upgrade_3_1.md index 823fa1b2f..5ab096cbe 100644 --- a/Documentation/upgrades/upgrade_3_1.md +++ b/Documentation/upgrades/upgrade_3_1.md @@ -1,4 +1,6 @@ -## Upgrade etcd from 3.0 to 3.1 +--- +title: Upgrade etcd from 3.0 to 3.1 +--- In the general case, upgrading from etcd 3.0 to 3.1 can be a zero-downtime, rolling upgrade: - one by one, stop the etcd v3.0 processes and replace them with etcd v3.1 processes @@ -8,7 +10,7 @@ Before [starting an upgrade](#upgrade-procedure), read through the rest of this ### Upgrade checklists -**NOTE:** When [migrating from v2 with no v3 data](https://github.com/coreos/etcd/issues/9480), etcd server v3.2+ panics when etcd restores from existing snapshots but no v3 `ETCD_DATA_DIR/member/snap/db` file. This happens when the server had migrated from v2 with no previous v3 data. This also prevents accidental v3 data loss (e.g. `db` file might have been moved). etcd requires that post v3 migration can only happen with v3 data. Do not upgrade to newer v3 versions until v3.0 server contains v3 data. +**NOTE:** When [migrating from v2 with no v3 data](https://github.com/etcd-io/etcd/issues/9480), etcd server v3.2+ panics when etcd restores from existing snapshots but no v3 `ETCD_DATA_DIR/member/snap/db` file. This happens when the server had migrated from v2 with no previous v3 data. This also prevents accidental v3 data loss (e.g. `db` file might have been moved). etcd requires that post v3 migration can only happen with v3 data. Do not upgrade to newer v3 versions until v3.0 server contains v3 data. #### Monitoring diff --git a/Documentation/upgrades/upgrade_3_2.md b/Documentation/upgrades/upgrade_3_2.md index f1b0a8c9f..f99a2afef 100644 --- a/Documentation/upgrades/upgrade_3_2.md +++ b/Documentation/upgrades/upgrade_3_2.md @@ -1,4 +1,6 @@ -## Upgrade etcd from 3.1 to 3.2 +--- +title: Upgrade etcd from 3.1 to 3.2 +--- In the general case, upgrading from etcd 3.1 to 3.2 can be a zero-downtime, rolling upgrade: - one by one, stop the etcd v3.1 processes and replace them with etcd v3.2 processes @@ -8,19 +10,21 @@ Before [starting an upgrade](#upgrade-procedure), read through the rest of this ### Upgrade checklists -**NOTE:** When [migrating from v2 with no v3 data](https://github.com/coreos/etcd/issues/9480), etcd server v3.2+ panics when etcd restores from existing snapshots but no v3 `ETCD_DATA_DIR/member/snap/db` file. This happens when the server had migrated from v2 with no previous v3 data. This also prevents accidental v3 data loss (e.g. `db` file might have been moved). etcd requires that post v3 migration can only happen with v3 data. Do not upgrade to newer v3 versions until v3.0 server contains v3 data. +**NOTE:** When [migrating from v2 with no v3 data](https://github.com/etcd-io/etcd/issues/9480), etcd server v3.2+ panics when etcd restores from existing snapshots but no v3 `ETCD_DATA_DIR/member/snap/db` file. This happens when the server had migrated from v2 with no previous v3 data. This also prevents accidental v3 data loss (e.g. `db` file might have been moved). etcd requires that post v3 migration can only happen with v3 data. Do not upgrade to newer v3 versions until v3.0 server contains v3 data. Highlighted breaking changes in 3.2. -#### Change in default `snapshot-count` value +#### Changed default `snapshot-count` value -The default value of `--snapshot-count` has [changed from from 10,000 to 100,000](https://github.com/coreos/etcd/pull/7160). Higher snapshot count means it holds Raft entries in memory for longer before discarding old entries. It is a trade-off between less frequent snapshotting and [higher memory usage](https://github.com/kubernetes/kubernetes/issues/60589#issuecomment-371977156). Higher `--snapshot-count` will be manifested with higher memory usage, while retaining more Raft entries helps with the availabilities of slow followers: leader is still able to replicate its logs to followers, rather than forcing followers to rebuild its stores from leader snapshots. +Higher `--snapshot-count` holds more Raft entries in memory until snapshot, thus causing [recurrent higher memory usage](https://github.com/kubernetes/kubernetes/issues/60589#issuecomment-371977156). Since leader retains latest Raft entries for longer, a slow follower has more time to catch up before leader snapshot. `--snapshot-count` is a tradeoff between higher memory usage and better availabilities of slow followers. -#### Change in gRPC dependency (>=3.2.10) +Since v3.2, the default value of `--snapshot-count` has [changed from from 10,000 to 100,000](https://github.com/etcd-io/etcd/pull/7160). + +#### Changed gRPC dependency (>=3.2.10) 3.2.10 or later now requires [grpc/grpc-go](https://github.com/grpc/grpc-go/releases) `v1.7.5` (<=3.2.9 requires `v1.2.1`). -##### Deprecate `grpclog.Logger` +##### Deprecated `grpclog.Logger` `grpclog.Logger` has been deprecated in favor of [`grpclog.LoggerV2`](https://github.com/grpc/grpc-go/blob/master/grpclog/loggerv2.go). `clientv3.Logger` is now `grpclog.LoggerV2`. @@ -41,9 +45,9 @@ clientv3.SetLogger(grpclog.NewLoggerV2(os.Stderr, os.Stderr, os.Stderr)) // log.New above cannot be used (not implement grpclog.LoggerV2 interface) ``` -##### Deprecate `grpc.ErrClientConnTimeout` +##### Deprecated `grpc.ErrClientConnTimeout` -Previously, `grpc.ErrClientConnTimeout` error is returned on client dial time-outs. 3.2 instead returns `context.DeadlineExceeded` (see [#8504](https://github.com/coreos/etcd/issues/8504)). +Previously, `grpc.ErrClientConnTimeout` error is returned on client dial time-outs. 3.2 instead returns `context.DeadlineExceeded` (see [#8504](https://github.com/etcd-io/etcd/issues/8504)). Before @@ -70,7 +74,7 @@ if err == context.DeadlineExceeded { } ``` -#### Change in maximum request size limits (>=3.2.10) +#### Changed maximum request size limits (>=3.2.10) 3.2.10 and 3.2.11 allow custom request size limits in server side. >=3.2.12 allows custom request size limits for both server and **client side**. In previous versions(v3.2.10, v3.2.11), client response size was limited to only 4 MiB. @@ -143,9 +147,9 @@ err.Error() == "rpc error: code = ResourceExhausted desc = grpc: received messag **If not specified, client-side send limit defaults to 2 MiB (1.5 MiB + gRPC overhead bytes) and receive limit to `math.MaxInt32`**. Please see [clientv3 godoc](https://godoc.org/github.com/coreos/etcd/clientv3#Config) for more detail. -#### Change in raw gRPC client wrappers +#### Changed raw gRPC client wrappers -3.2.12 or later changes the function signatures of `clientv3` gRPC client wrapper. This change was needed to support [custom `grpc.CallOption` on message size limits](https://github.com/coreos/etcd/pull/9047). +3.2.12 or later changes the function signatures of `clientv3` gRPC client wrapper. This change was needed to support [custom `grpc.CallOption` on message size limits](https://github.com/etcd-io/etcd/pull/9047). Before and after @@ -166,9 +170,9 @@ Before and after +func NewWatchFromWatchClient(wc pb.WatchClient, c *Client) Watcher { ``` -#### Change in `clientv3.Lease.TimeToLive` API +#### Changed `clientv3.Lease.TimeToLive` API -Previously, `clientv3.Lease.TimeToLive` API returned `lease.ErrLeaseNotFound` on non-existent lease ID. 3.2 instead returns TTL=-1 in its response and no error (see [#7305](https://github.com/coreos/etcd/pull/7305)). +Previously, `clientv3.Lease.TimeToLive` API returned `lease.ErrLeaseNotFound` on non-existent lease ID. 3.2 instead returns TTL=-1 in its response and no error (see [#7305](https://github.com/etcd-io/etcd/pull/7305)). Before @@ -188,7 +192,7 @@ resp.TTL == -1 err == nil ``` -#### Change in `clientv3.NewFromConfigFile` +#### Moved `clientv3.NewFromConfigFile` to `clientv3.yaml.NewConfig` `clientv3.NewFromConfigFile` is moved to `yaml.NewConfig`. @@ -210,7 +214,7 @@ clientv3yaml.NewConfig 3.2 now rejects domains names for `--listen-peer-urls` and `--listen-client-urls` (3.1 only prints out warnings), since domain name is invalid for network interface binding. Make sure that those URLs are properly formated as `scheme://IP:port`. -See [issue #6336](https://github.com/coreos/etcd/issues/6336) for more contexts. +See [issue #6336](https://github.com/etcd-io/etcd/issues/6336) for more contexts. ### Server upgrade checklists diff --git a/Documentation/upgrades/upgrade_3_3.md b/Documentation/upgrades/upgrade_3_3.md index 057051dee..a01b935b2 100644 --- a/Documentation/upgrades/upgrade_3_3.md +++ b/Documentation/upgrades/upgrade_3_3.md @@ -1,4 +1,6 @@ -## Upgrade etcd from 3.2 to 3.3 +--- +title: Upgrade etcd from 3.2 to 3.3 +--- In the general case, upgrading from etcd 3.2 to 3.3 can be a zero-downtime, rolling upgrade: - one by one, stop the etcd v3.2 processes and replace them with etcd v3.3 processes @@ -8,11 +10,24 @@ Before [starting an upgrade](#upgrade-procedure), read through the rest of this ### Upgrade checklists -**NOTE:** When [migrating from v2 with no v3 data](https://github.com/coreos/etcd/issues/9480), etcd server v3.2+ panics when etcd restores from existing snapshots but no v3 `ETCD_DATA_DIR/member/snap/db` file. This happens when the server had migrated from v2 with no previous v3 data. This also prevents accidental v3 data loss (e.g. `db` file might have been moved). etcd requires that post v3 migration can only happen with v3 data. Do not upgrade to newer v3 versions until v3.0 server contains v3 data. +**NOTE:** When [migrating from v2 with no v3 data](https://github.com/etcd-io/etcd/issues/9480), etcd server v3.2+ panics when etcd restores from existing snapshots but no v3 `ETCD_DATA_DIR/member/snap/db` file. This happens when the server had migrated from v2 with no previous v3 data. This also prevents accidental v3 data loss (e.g. `db` file might have been moved). etcd requires that post v3 migration can only happen with v3 data. Do not upgrade to newer v3 versions until v3.0 server contains v3 data. Highlighted breaking changes in 3.3. -#### Change in `etcdserver.EtcdServer` struct +#### Changed value type of `etcd --auto-compaction-retention` flag to `string` + +Changed `--auto-compaction-retention` flag to [accept string values](https://github.com/etcd-io/etcd/pull/8563) with [finer granularity](https://github.com/etcd-io/etcd/issues/8503). Now that `--auto-compaction-retention` accepts string values, etcd configuration YAML file `auto-compaction-retention` field must be changed to `string` type. Previously, `--config-file etcd.config.yaml` can have `auto-compaction-retention: 24` field, now must be `auto-compaction-retention: "24"` or `auto-compaction-retention: "24h"`. If configured as `--auto-compaction-mode periodic --auto-compaction-retention "24h"`, the time duration value for `--auto-compaction-retention` flag must be valid for [`time.ParseDuration`](https://golang.org/pkg/time/#ParseDuration) function in Go. + +```diff +# etcd.config.yaml ++auto-compaction-mode: periodic +-auto-compaction-retention: 24 ++auto-compaction-retention: "24" ++# Or ++auto-compaction-retention: "24h" +``` + +#### Changed `etcdserver.EtcdServer.ServerConfig` to `*etcdserver.EtcdServer.ServerConfig` `etcdserver.EtcdServer` has changed the type of its member field `*etcdserver.ServerConfig` to `etcdserver.ServerConfig`. And `etcdserver.NewServer` now takes `etcdserver.ServerConfig`, instead of `*etcdserver.ServerConfig`. @@ -42,7 +57,9 @@ func (e *EtcdServer) Start() error { ... ``` -#### Change in `embed.EtcdServer` struct +#### Added `embed.Config.LogOutput` struct + +**Note that this field has been renamed to `embed.Config.LogOutputs` in `[]string` type in v3.4. Please see [v3.4 upgrade guide](https://github.com/etcd-io/etcd/blob/master/Documentation/upgrades/upgrade_3_4.md) for more details.** Field `LogOutput` is added to `embed.Config`: @@ -65,6 +82,8 @@ WARNING: 2017/11/02 11:35:51 grpc: addrConn.resetTransport failed to create clie From v3.3, gRPC server logs are disabled by default. +**Note that `embed.Config.SetupLogging` method has been deprecated in v3.4. Please see [v3.4 upgrade guide](https://github.com/etcd-io/etcd/blob/master/Documentation/upgrades/upgrade_3_4.md) for more details.** + ```go import "github.com/coreos/etcd/embed" @@ -74,7 +93,7 @@ cfg.SetupLogging() Set `embed.Config.Debug` field to `true` to enable gRPC server logs. -#### Change in `/health` endpoint response +#### Changed `/health` endpoint response Previously, `[endpoint]:[client-port]/health` returned manually marshaled JSON value. 3.3 now defines [`etcdhttp.Health`](https://godoc.org/github.com/coreos/etcd/etcdserver/api/etcdhttp#Health) struct. @@ -85,25 +104,25 @@ $ curl http://localhost:2379/health {"health":"true"} ``` -#### Change in gRPC gateway HTTP endpoints (replaced `/v3alpha` with `/v3beta`) +#### Changed gRPC gateway HTTP endpoints (replaced `/v3alpha` with `/v3beta`) Before ```bash curl -L http://localhost:2379/v3alpha/kv/put \ - -X POST -d '{"key": "Zm9v", "value": "YmFy"}' + -X POST -d '{"key": "Zm9v", "value": "YmFy"}' ``` After ```bash curl -L http://localhost:2379/v3beta/kv/put \ - -X POST -d '{"key": "Zm9v", "value": "YmFy"}' + -X POST -d '{"key": "Zm9v", "value": "YmFy"}' ``` Requests to `/v3alpha` endpoints will redirect to `/v3beta`, and `/v3alpha` will be removed in 3.4 release. -#### Change in maximum request size limits +#### Changed maximum request size limits 3.3 now allows custom request size limits for both server and **client side**. In previous versions(v3.2.10, v3.2.11), client response size was limited to only 4 MiB. @@ -176,9 +195,9 @@ err.Error() == "rpc error: code = ResourceExhausted desc = grpc: received messag **If not specified, client-side send limit defaults to 2 MiB (1.5 MiB + gRPC overhead bytes) and receive limit to `math.MaxInt32`**. Please see [clientv3 godoc](https://godoc.org/github.com/coreos/etcd/clientv3#Config) for more detail. -#### Change in raw gRPC client wrappers +#### Changed raw gRPC client wrapper function signatures -3.3 changes the function signatures of `clientv3` gRPC client wrapper. This change was needed to support [custom `grpc.CallOption` on message size limits](https://github.com/coreos/etcd/pull/9047). +3.3 changes the function signatures of `clientv3` gRPC client wrapper. This change was needed to support [custom `grpc.CallOption` on message size limits](https://github.com/etcd-io/etcd/pull/9047). Before and after @@ -199,7 +218,7 @@ Before and after +func NewWatchFromWatchClient(wc pb.WatchClient, c *Client) Watcher { ``` -#### Change in clientv3 `Snapshot` API error type +#### Changed clientv3 `Snapshot` API error type Previously, clientv3 `Snapshot` API returned raw [`grpc/*status.statusError`] type error. v3.3 now translates those errors to corresponding public error types, to be consistent with other APIs. @@ -245,7 +264,7 @@ _, err = io.Copy(f, rc) err == context.DeadlineExceeded ``` -#### Change in `etcdctl lease timetolive` command output +#### Changed `etcdctl lease timetolive` command output Previously, `lease timetolive LEASE_ID` command on expired lease prints `-1s` for remaining seconds. 3.3 now outputs clearer messages. @@ -262,7 +281,7 @@ After lease 2d8257079fa1bc0c already expired ``` -#### Change in `golang.org/x/net/context` imports +#### Changed `golang.org/x/net/context` imports `clientv3` has deprecated `golang.org/x/net/context`. If a project vendors `golang.org/x/net/context` in other code (e.g. etcd generated protocol buffer code) and imports `github.com/coreos/etcd/clientv3`, it requires Go 1.9+ to compile. @@ -280,11 +299,11 @@ import "context" cli.Put(context.Background(), "f", "v") ``` -#### Change in gRPC dependency +#### Changed gRPC dependency 3.3 now requires [grpc/grpc-go](https://github.com/grpc/grpc-go/releases) `v1.7.5`. -##### Deprecate `grpclog.Logger` +##### Deprecated `grpclog.Logger` `grpclog.Logger` has been deprecated in favor of [`grpclog.LoggerV2`](https://github.com/grpc/grpc-go/blob/master/grpclog/loggerv2.go). `clientv3.Logger` is now `grpclog.LoggerV2`. @@ -305,9 +324,9 @@ clientv3.SetLogger(grpclog.NewLoggerV2(os.Stderr, os.Stderr, os.Stderr)) // log.New above cannot be used (not implement grpclog.LoggerV2 interface) ``` -##### Deprecate `grpc.ErrClientConnTimeout` +##### Deprecated `grpc.ErrClientConnTimeout` -Previously, `grpc.ErrClientConnTimeout` error is returned on client dial time-outs. 3.3 instead returns `context.DeadlineExceeded` (see [#8504](https://github.com/coreos/etcd/issues/8504)). +Previously, `grpc.ErrClientConnTimeout` error is returned on client dial time-outs. 3.3 instead returns `context.DeadlineExceeded` (see [#8504](https://github.com/etcd-io/etcd/issues/8504)). Before @@ -334,7 +353,7 @@ if err == context.DeadlineExceeded { } ``` -#### Change in official container registry +#### Changed official container registry etcd now uses [`gcr.io/etcd-development/etcd`](https://gcr.io/etcd-development/etcd) as a primary container registry, and [`quay.io/coreos/etcd`](https://quay.io/coreos/etcd) as secondary. diff --git a/Documentation/upgrades/upgrade_3_4.md b/Documentation/upgrades/upgrade_3_4.md index 3c0c2ffb3..947ed003f 100644 --- a/Documentation/upgrades/upgrade_3_4.md +++ b/Documentation/upgrades/upgrade_3_4.md @@ -1,4 +1,6 @@ -## Upgrade etcd from 3.3 to 3.4 +--- +title: Upgrade etcd from 3.3 to 3.4 +--- In the general case, upgrading from etcd 3.3 to 3.4 can be a zero-downtime, rolling upgrade: - one by one, stop the etcd v3.3 processes and replace them with etcd v3.4 processes @@ -6,13 +8,34 @@ In the general case, upgrading from etcd 3.3 to 3.4 can be a zero-downtime, roll Before [starting an upgrade](#upgrade-procedure), read through the rest of this guide to prepare. + + ### Upgrade checklists -**NOTE:** When [migrating from v2 with no v3 data](https://github.com/coreos/etcd/issues/9480), etcd server v3.2+ panics when etcd restores from existing snapshots but no v3 `ETCD_DATA_DIR/member/snap/db` file. This happens when the server had migrated from v2 with no previous v3 data. This also prevents accidental v3 data loss (e.g. `db` file might have been moved). etcd requires that post v3 migration can only happen with v3 data. Do not upgrade to newer v3 versions until v3.0 server contains v3 data. +**NOTE:** When [migrating from v2 with no v3 data](https://github.com/etcd-io/etcd/issues/9480), etcd server v3.2+ panics when etcd restores from existing snapshots but no v3 `ETCD_DATA_DIR/member/snap/db` file. This happens when the server had migrated from v2 with no previous v3 data. This also prevents accidental v3 data loss (e.g. `db` file might have been moved). etcd requires that post v3 migration can only happen with v3 data. Do not upgrade to newer v3 versions until v3.0 server contains v3 data. Highlighted breaking changes in 3.4. -#### Change in `etcd` flags +#### Make `ETCDCTL_API=3 etcdctl` default + +`ETCDCTL_API=3` is now the default. + +```diff +etcdctl set foo bar +Error: unknown command "set" for "etcdctl" + +-etcdctl set foo bar ++ETCDCTL_API=2 etcdctl set foo bar +bar + +ETCDCTL_API=3 etcdctl put foo bar +OK + +-ETCDCTL_API=3 etcdctl put foo bar ++etcdctl put foo bar +``` + +#### Deprecated `etcd --ca-file` and `etcd --peer-ca-file` flags `--ca-file` and `--peer-ca-file` flags are deprecated; they have been deprecated since v2.1. @@ -26,7 +49,63 @@ Highlighted breaking changes in 3.4. +etcd --peer-trusted-ca-file ca-peer.crt ``` -#### Change in ``pkg/transport` +#### Promote `etcd_debugging_mvcc_db_total_size_in_bytes` Prometheus metrics + +v3.4 promotes `etcd_debugging_mvcc_db_total_size_in_bytes` Prometheus metrics to `etcd_mvcc_db_total_size_in_bytes`, in order to encourage etcd storage monitoring. + +`etcd_debugging_mvcc_db_total_size_in_bytes` is still served in v3.4 for backward compatibilities. It will be completely deprecated in v3.5. + +```diff +-etcd_debugging_mvcc_db_total_size_in_bytes ++etcd_mvcc_db_total_size_in_bytes +``` + +Note that `etcd_debugging_*` namespace metrics have been marked as experimental. As we improve monitoring guide, we will promote more metrics. + +#### Deprecating `etcd --log-output` flag (now `--log-outputs`) + +Rename [`etcd --log-output` to `--log-outputs`](https://github.com/etcd-io/etcd/pull/9624) to support multiple log outputs. **`etcd --logger=capnslog` does not support multiple log outputs.** + +**`etcd --log-output`** will be deprecated in v3.5. **`etcd --logger=capnslog` will be deprecated in v3.5**. + +```diff +-etcd --log-output=stderr ++etcd --log-outputs=stderr + ++# to write logs to stderr and a.log file at the same time ++# only "--logger=zap" supports multiple writers ++etcd --logger=zap --log-outputs=stderr,a.log +``` + +v3.4 adds `etcd --logger=zap --log-outputs=stderr` support for structured logging and multiple log outputs. Main motivation is to promote automated etcd monitoring, rather than looking back server logs when it starts breaking. Future development will make etcd log as few as possible, and make etcd easier to monitor with metrics and alerts. **`etcd --logger=capnslog` will be deprecated in v3.5**. + +#### Changed `log-outputs` field type in `etcd --config-file` to `[]string` + +Now that `log-outputs` (old field name `log-output`) accepts multiple writers, etcd configuration YAML file `log-outputs` field must be changed to `[]string` type as below: + +```diff + # Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd. +-log-output: default ++log-outputs: [default] +``` + +#### Renamed `embed.Config.LogOutput` to `embed.Config.LogOutputs` + +Renamed [**`embed.Config.LogOutput`** to **`embed.Config.LogOutputs`**](https://github.com/etcd-io/etcd/pull/9624) to support multiple log outputs. And changed [`embed.Config.LogOutput` type from `string` to `[]string`](https://github.com/etcd-io/etcd/pull/9579) to support multiple log outputs. + +```diff +import "github.com/coreos/etcd/embed" + +cfg := &embed.Config{Debug: false} +-cfg.LogOutput = "stderr" ++cfg.LogOutputs = []string{"stderr"} +``` + +#### v3.5 deprecates `capnslog` + +**v3.5 will deprecate `etcd --log-package-levels` flag for `capnslog`**; `etcd --logger=zap --log-outputs=stderr` will the default. **v3.5 will deprecate `[CLIENT-URL]/config/local/log` endpoint.** + +#### Deprecated `pkg/transport.TLSInfo.CAFile` field Deprecated `pkg/transport.TLSInfo.CAFile` field. @@ -45,6 +124,100 @@ if err != nil { } ``` +#### Changed `embed.Config.SnapCount` to `embed.Config.SnapshotCount` + +To be consistent with the flag name `etcd --snapshot-count`, `embed.Config.SnapCount` field has been renamed to `embed.Config.SnapshotCount`: + +```diff +import "github.com/coreos/etcd/embed" + +cfg := embed.NewConfig() +-cfg.SnapCount = 100000 ++cfg.SnapshotCount = 100000 +``` + +#### Changed `etcdserver.ServerConfig.SnapCount` to `etcdserver.ServerConfig.SnapshotCount` + +To be consistent with the flag name `etcd --snapshot-count`, `etcdserver.ServerConfig.SnapCount` field has been renamed to `etcdserver.ServerConfig.SnapshotCount`: + +```diff +import "github.com/coreos/etcd/etcdserver" + +srvcfg := etcdserver.ServerConfig{ +- SnapCount: 100000, ++ SnapshotCount: 100000, +``` + +#### Changed function signature in package `wal` + +Changed `wal` function signatures to support structured logger. + +```diff +import "github.com/coreos/etcd/wal" ++import "go.uber.org/zap" + ++lg, _ = zap.NewProduction() + +-wal.Open(dirpath, snap) ++wal.Open(lg, dirpath, snap) + +-wal.OpenForRead(dirpath, snap) ++wal.OpenForRead(lg, dirpath, snap) + +-wal.Repair(dirpath) ++wal.Repair(lg, dirpath) + +-wal.Create(dirpath, metadata) ++wal.Create(lg, dirpath, metadata) +``` + +#### Deprecated `embed.Config.SetupLogging` + +`embed.Config.SetupLogging` has been removed in order to prevent wrong logging configuration, and now set up automatically. + +```diff +import "github.com/coreos/etcd/embed" + +cfg := &embed.Config{Debug: false} +-cfg.SetupLogging() +``` + +#### Changed gRPC gateway HTTP endpoints (replaced `/v3beta` with `/v3`) + +Before + +```bash +curl -L http://localhost:2379/v3beta/kv/put \ + -X POST -d '{"key": "Zm9v", "value": "YmFy"}' +``` + +After + +```bash +curl -L http://localhost:2379/v3/kv/put \ + -X POST -d '{"key": "Zm9v", "value": "YmFy"}' +``` + +Requests to `/v3beta` endpoints will redirect to `/v3`, and `/v3beta` will be removed in 3.5 release. + +#### Deprecated container image tags + +`latest` and minor version images tags are deprecated: + +```diff +-docker pull gcr.io/etcd-development/etcd:latest ++docker pull gcr.io/etcd-development/etcd:v3.4.0 + +-docker pull gcr.io/etcd-development/etcd:v3.4 ++docker pull gcr.io/etcd-development/etcd:v3.4.0 + +-docker pull gcr.io/etcd-development/etcd:v3.4 ++docker pull gcr.io/etcd-development/etcd:v3.4.1 + +-docker pull gcr.io/etcd-development/etcd:v3.4 ++docker pull gcr.io/etcd-development/etcd:v3.4.2 +``` + ### Server upgrade checklists #### Upgrade requirements @@ -57,7 +230,7 @@ Also, to ensure a smooth rolling upgrade, the running cluster must be healthy. C Before upgrading etcd, always test the services relying on etcd in a staging environment before deploying the upgrade to the production environment. -Before beginning, [backup the etcd data](../op-guide/maintenance.md#snapshot-backup). Should something go wrong with the upgrade, it is possible to use this backup to [downgrade](#downgrade) back to existing etcd version. Please note that the `snapshot` command only backs up the v3 data. For v2 data, see [backing up v2 datastore](../v2/admin_guide.md#backing-up-the-datastore). +Before beginning, [download the snapshot backup](../op-guide/maintenance.md#snapshot-backup). Should something go wrong with the upgrade, it is possible to use this backup to [downgrade](#downgrade) back to existing etcd version. Please note that the `snapshot` command only backs up the v3 data. For v2 data, see [backing up v2 datastore](../v2/admin_guide.md#backing-up-the-datastore). #### Mixed versions @@ -75,97 +248,215 @@ For a much larger total data size, 100MB or more , this one-time process might t If all members have been upgraded to v3.4, the cluster will be upgraded to v3.4, and downgrade from this completed state is **not possible**. If any single member is still v3.3, however, the cluster and its operations remains "v3.3", and it is possible from this mixed cluster state to return to using a v3.3 etcd binary on all members. -Please [backup the data directory](../op-guide/maintenance.md#snapshot-backup) of all etcd members to make downgrading the cluster possible even after it has been completely upgraded. +Please [download the snapshot backup](../op-guide/maintenance.md#snapshot-backup) to make downgrading the cluster possible even after it has been completely upgraded. ### Upgrade procedure This example shows how to upgrade a 3-member v3.3 ectd cluster running on a local machine. -#### 1. Check upgrade requirements +#### Step 1: check upgrade requirements Is the cluster healthy and running v3.3.x? -``` -$ ETCDCTL_API=3 etcdctl endpoint health --endpoints=localhost:2379,localhost:22379,localhost:32379 -localhost:2379 is healthy: successfully committed proposal: took = 6.600684ms -localhost:22379 is healthy: successfully committed proposal: took = 8.540064ms -localhost:32379 is healthy: successfully committed proposal: took = 8.763432ms +```bash +etcdctl --endpoints=localhost:2379,localhost:22379,localhost:32379 endpoint health +<} +WARNING: 2018/05/17 12:45:21 grpc: addrConn.transportMonitor exits due to: grpc: the connection is closing +21.193589 I | raft: 7339c4e5e833c029 [term: 8] received a MsgVote message with higher term from 729934363faa4a24 [term: 9] +21.193626 I | raft: 7339c4e5e833c029 became follower at term 9 +21.193651 I | raft: 7339c4e5e833c029 [logterm: 8, index: 9, vote: 0] cast MsgVote for 729934363faa4a24 [logterm: 8, index: 9] at term 9 +21.193675 I | raft: raft.node: 7339c4e5e833c029 lost leader 7339c4e5e833c029 at term 9 +21.194424 I | raft: raft.node: 7339c4e5e833c029 elected leader 729934363faa4a24 at term 9 +21.292898 I | etcdserver: 7339c4e5e833c029 finished leadership transfer from 7339c4e5e833c029 to 729934363faa4a24 (took 100.436391ms) +21.292975 I | rafthttp: stopping peer 729934363faa4a24... +21.293206 I | rafthttp: closed the TCP streaming connection with peer 729934363faa4a24 (stream MsgApp v2 writer) +21.293225 I | rafthttp: stopped streaming with peer 729934363faa4a24 (writer) +21.293437 I | rafthttp: closed the TCP streaming connection with peer 729934363faa4a24 (stream Message writer) +21.293459 I | rafthttp: stopped streaming with peer 729934363faa4a24 (writer) +21.293514 I | rafthttp: stopped HTTP pipelining with peer 729934363faa4a24 +21.293590 W | rafthttp: lost the TCP streaming connection with peer 729934363faa4a24 (stream MsgApp v2 reader) +21.293610 I | rafthttp: stopped streaming with peer 729934363faa4a24 (stream MsgApp v2 reader) +21.293680 W | rafthttp: lost the TCP streaming connection with peer 729934363faa4a24 (stream Message reader) +21.293700 I | rafthttp: stopped streaming with peer 729934363faa4a24 (stream Message reader) +21.293711 I | rafthttp: stopped peer 729934363faa4a24 +21.293720 I | rafthttp: stopping peer b548c2511513015... +21.293987 I | rafthttp: closed the TCP streaming connection with peer b548c2511513015 (stream MsgApp v2 writer) +21.294063 I | rafthttp: stopped streaming with peer b548c2511513015 (writer) +21.294467 I | rafthttp: closed the TCP streaming connection with peer b548c2511513015 (stream Message writer) +21.294561 I | rafthttp: stopped streaming with peer b548c2511513015 (writer) +21.294742 I | rafthttp: stopped HTTP pipelining with peer b548c2511513015 +21.294867 W | rafthttp: lost the TCP streaming connection with peer b548c2511513015 (stream MsgApp v2 reader) +21.294892 I | rafthttp: stopped streaming with peer b548c2511513015 (stream MsgApp v2 reader) +21.294990 W | rafthttp: lost the TCP streaming connection with peer b548c2511513015 (stream Message reader) +21.295004 E | rafthttp: failed to read b548c2511513015 on stream Message (context canceled) +21.295013 I | rafthttp: peer b548c2511513015 became inactive +21.295024 I | rafthttp: stopped streaming with peer b548c2511513015 (stream Message reader) +21.295035 I | rafthttp: stopped peer b548c2511513015 ``` -It's a good idea at this point to [backup the etcd data](../op-guide/maintenance.md#snapshot-backup) to provide a downgrade path should any problems occur: +#### Step 4: restart the etcd server with same configuration -``` -$ etcdctl snapshot save backup.db +Restart the etcd server with same configuration but with the new etcd binary. + +```diff +-etcd-old --name s1 \ ++etcd-new --name s1 \ + --data-dir /tmp/etcd/s1 \ + --listen-client-urls http://localhost:2379 \ + --advertise-client-urls http://localhost:2379 \ + --listen-peer-urls http://localhost:2380 \ + --initial-advertise-peer-urls http://localhost:2380 \ + --initial-cluster s1=http://localhost:2380,s2=http://localhost:22380,s3=http://localhost:32380 \ + --initial-cluster-token tkn \ ++ --initial-cluster-state new \ ++ --logger zap \ ++ --log-outputs stderr ``` -#### 3. Drop-in etcd v3.4 binary and start the new etcd process +The new v3.4 etcd will publish its information to the cluster. At this point, cluster still operates as v3.3 protocol, which is the lowest common version. -The new v3.4 etcd will publish its information to the cluster: +> `{"level":"info","ts":1526586617.1647713,"caller":"membership/cluster.go:485","msg":"set initial cluster version","cluster-id":"7dee9ba76d59ed53","local-member-id":"7339c4e5e833c029","cluster-version":"3.0"}` -``` -14:14:25.363225 I | etcdserver: published {Name:s1 ClientURLs:[http://localhost:2379]} to cluster a9ededbffcb1b1f1 -``` +> `{"level":"info","ts":1526586617.1648536,"caller":"api/capability.go:76","msg":"enabled capabilities for version","cluster-version":"3.0"}` + +> `{"level":"info","ts":1526586617.1649303,"caller":"membership/cluster.go:473","msg":"updated cluster version","cluster-id":"7dee9ba76d59ed53","local-member-id":"7339c4e5e833c029","from":"3.0","from":"3.3"}` + +> `{"level":"info","ts":1526586617.1649797,"caller":"api/capability.go:76","msg":"enabled capabilities for version","cluster-version":"3.3"}` + +> `{"level":"info","ts":1526586617.2107732,"caller":"etcdserver/server.go:1770","msg":"published local member to cluster through raft","local-member-id":"7339c4e5e833c029","local-member-attributes":"{Name:s1 ClientURLs:[http://localhost:2379]}","request-path":"/0/members/7339c4e5e833c029/attributes","cluster-id":"7dee9ba76d59ed53","publish-timeout":7}` Verify that each member, and then the entire cluster, becomes healthy with the new v3.4 etcd binary: -``` -$ ETCDCTL_API=3 /etcdctl endpoint health --endpoints=localhost:2379,localhost:22379,localhost:32379 -localhost:22379 is healthy: successfully committed proposal: took = 5.540129ms -localhost:32379 is healthy: successfully committed proposal: took = 7.321771ms -localhost:2379 is healthy: successfully committed proposal: took = 10.629901ms +```bash +etcdctl endpoint health --endpoints=localhost:2379,localhost:22379,localhost:32379 +< `{"level":"info","ts":1526586949.0920913,"caller":"api/capability.go:76","msg":"enabled capabilities for version","cluster-version":"3.4"}` +> `{"level":"info","ts":1526586949.0921566,"caller":"etcdserver/server.go:2272","msg":"cluster version is updated","cluster-version":"3.4"}` + +Member 2: + +> `{"level":"info","ts":1526586949.092117,"caller":"membership/cluster.go:473","msg":"updated cluster version","cluster-id":"7dee9ba76d59ed53","local-member-id":"729934363faa4a24","from":"3.3","from":"3.4"}` +> `{"level":"info","ts":1526586949.0923078,"caller":"api/capability.go:76","msg":"enabled capabilities for version","cluster-version":"3.4"}` + +Member 3: + +> `{"level":"info","ts":1526586949.0921423,"caller":"membership/cluster.go:473","msg":"updated cluster version","cluster-id":"7dee9ba76d59ed53","local-member-id":"b548c2511513015","from":"3.3","from":"3.4"}` +> `{"level":"info","ts":1526586949.0922918,"caller":"api/capability.go:76","msg":"enabled capabilities for version","cluster-version":"3.4"}` + + +```bash +endpoint health --endpoints=localhost:2379,localhost:22379,localhost:32379 +<127.0.0.1:32380: use of closed network connection"} +{"level":"info","ts":1526587299.1778402,"caller":"rafthttp/stream.go:459","msg":"stopped stream reader with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"7339c4e5e833c029","remote-peer-id":"b548c2511513015"} +{"level":"warn","ts":1526587299.1780295,"caller":"rafthttp/stream.go:436","msg":"lost TCP streaming connection with remote peer","stream-reader-type":"stream Message","local-member-id":"7339c4e5e833c029","remote-peer-id":"b548c2511513015","error":"read tcp 127.0.0.1:34634->127.0.0.1:32380: use of closed network connection"} +{"level":"info","ts":1526587299.1780987,"caller":"rafthttp/stream.go:459","msg":"stopped stream reader with remote peer","stream-reader-type":"stream Message","local-member-id":"7339c4e5e833c029","remote-peer-id":"b548c2511513015"} +{"level":"info","ts":1526587299.1781602,"caller":"rafthttp/peer.go:340","msg":"stopped remote peer","remote-peer-id":"b548c2511513015"} +{"level":"info","ts":1526587299.1781986,"caller":"rafthttp/peer.go:333","msg":"stopping remote peer","remote-peer-id":"729934363faa4a24"} +{"level":"warn","ts":1526587299.1802843,"caller":"rafthttp/stream.go:291","msg":"closed TCP streaming connection with remote peer","stream-writer-type":"stream MsgApp v2","remote-peer-id":"729934363faa4a24"} +{"level":"warn","ts":1526587299.1803446,"caller":"rafthttp/stream.go:301","msg":"stopped TCP streaming connection with remote peer","stream-writer-type":"stream MsgApp v2","remote-peer-id":"729934363faa4a24"} +{"level":"warn","ts":1526587299.1824749,"caller":"rafthttp/stream.go:291","msg":"closed TCP streaming connection with remote peer","stream-writer-type":"stream Message","remote-peer-id":"729934363faa4a24"} +{"level":"warn","ts":1526587299.18255,"caller":"rafthttp/stream.go:301","msg":"stopped TCP streaming connection with remote peer","stream-writer-type":"stream Message","remote-peer-id":"729934363faa4a24"} +{"level":"info","ts":1526587299.18261,"caller":"rafthttp/pipeline.go:86","msg":"stopped HTTP pipelining with remote peer","local-member-id":"7339c4e5e833c029","remote-peer-id":"729934363faa4a24"} +{"level":"warn","ts":1526587299.1827736,"caller":"rafthttp/stream.go:436","msg":"lost TCP streaming connection with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"7339c4e5e833c029","remote-peer-id":"729934363faa4a24","error":"read tcp 127.0.0.1:51482->127.0.0.1:22380: use of closed network connection"} +{"level":"info","ts":1526587299.182845,"caller":"rafthttp/stream.go:459","msg":"stopped stream reader with remote peer","stream-reader-type":"stream MsgApp v2","local-member-id":"7339c4e5e833c029","remote-peer-id":"729934363faa4a24"} +{"level":"warn","ts":1526587299.1830168,"caller":"rafthttp/stream.go:436","msg":"lost TCP streaming connection with remote peer","stream-reader-type":"stream Message","local-member-id":"7339c4e5e833c029","remote-peer-id":"729934363faa4a24","error":"context canceled"} +{"level":"warn","ts":1526587299.1831107,"caller":"rafthttp/peer_status.go:65","msg":"peer became inactive","peer-id":"729934363faa4a24","error":"failed to read 729934363faa4a24 on stream Message (context canceled)"} +{"level":"info","ts":1526587299.1831737,"caller":"rafthttp/stream.go:459","msg":"stopped stream reader with remote peer","stream-reader-type":"stream Message","local-member-id":"7339c4e5e833c029","remote-peer-id":"729934363faa4a24"} +{"level":"info","ts":1526587299.1832306,"caller":"rafthttp/peer.go:340","msg":"stopped remote peer","remote-peer-id":"729934363faa4a24"} +{"level":"warn","ts":1526587299.1837125,"caller":"rafthttp/http.go:424","msg":"failed to find remote peer in cluster","local-member-id":"7339c4e5e833c029","remote-peer-id-stream-handler":"7339c4e5e833c029","remote-peer-id-from":"b548c2511513015","cluster-id":"7dee9ba76d59ed53"} +{"level":"warn","ts":1526587299.1840093,"caller":"rafthttp/http.go:424","msg":"failed to find remote peer in cluster","local-member-id":"7339c4e5e833c029","remote-peer-id-stream-handler":"7339c4e5e833c029","remote-peer-id-from":"b548c2511513015","cluster-id":"7dee9ba76d59ed53"} +{"level":"warn","ts":1526587299.1842315,"caller":"rafthttp/http.go:424","msg":"failed to find remote peer in cluster","local-member-id":"7339c4e5e833c029","remote-peer-id-stream-handler":"7339c4e5e833c029","remote-peer-id-from":"729934363faa4a24","cluster-id":"7dee9ba76d59ed53"} +{"level":"warn","ts":1526587299.1844475,"caller":"rafthttp/http.go:424","msg":"failed to find remote peer in cluster","local-member-id":"7339c4e5e833c029","remote-peer-id-stream-handler":"7339c4e5e833c029","remote-peer-id-from":"729934363faa4a24","cluster-id":"7dee9ba76d59ed53"} +{"level":"info","ts":1526587299.2056687,"caller":"embed/etcd.go:473","msg":"stopping serving peer traffic","address":"127.0.0.1:2380"} +{"level":"info","ts":1526587299.205819,"caller":"embed/etcd.go:480","msg":"stopped serving peer traffic","address":"127.0.0.1:2380"} +{"level":"info","ts":1526587299.2058413,"caller":"embed/etcd.go:289","msg":"closed etcd server","name":"s1","data-dir":"/tmp/etcd/s1","advertise-peer-urls":["http://localhost:2380"],"advertise-client-urls":["http://localhost:2379"]} +``` + +#### Step 4: restart the etcd server with same configuration + +Restart the etcd server with same configuration but with the new etcd binary. + +```diff +-etcd-old --name s1 \ ++etcd-new --name s1 \ + --data-dir /tmp/etcd/s1 \ + --listen-client-urls http://localhost:2379 \ + --advertise-client-urls http://localhost:2379 \ + --listen-peer-urls http://localhost:2380 \ + --initial-advertise-peer-urls http://localhost:2380 \ + --initial-cluster s1=http://localhost:2380,s2=http://localhost:22380,s3=http://localhost:32380 \ + --initial-cluster-token tkn \ + --initial-cluster-state new +``` + +The new v3.5 etcd will publish its information to the cluster. At this point, cluster still operates as v3.4 protocol, which is the lowest common version. + +> `{"level":"info","ts":1526586617.1647713,"caller":"membership/cluster.go:485","msg":"set initial cluster version","cluster-id":"7dee9ba76d59ed53","local-member-id":"7339c4e5e833c029","cluster-version":"3.0"}` + +> `{"level":"info","ts":1526586617.1648536,"caller":"api/capability.go:76","msg":"enabled capabilities for version","cluster-version":"3.0"}` + +> `{"level":"info","ts":1526586617.1649303,"caller":"membership/cluster.go:473","msg":"updated cluster version","cluster-id":"7dee9ba76d59ed53","local-member-id":"7339c4e5e833c029","from":"3.0","from":"3.4"}` + +> `{"level":"info","ts":1526586617.1649797,"caller":"api/capability.go:76","msg":"enabled capabilities for version","cluster-version":"3.4"}` + +> `{"level":"info","ts":1526586617.2107732,"caller":"etcdserver/server.go:1770","msg":"published local member to cluster through raft","local-member-id":"7339c4e5e833c029","local-member-attributes":"{Name:s1 ClientURLs:[http://localhost:2379]}","request-path":"/0/members/7339c4e5e833c029/attributes","cluster-id":"7dee9ba76d59ed53","publish-timeout":7}` + +Verify that each member, and then the entire cluster, becomes healthy with the new v3.5 etcd binary: + +```bash +etcdctl endpoint health --endpoints=localhost:2379,localhost:22379,localhost:32379 +< `{"level":"info","ts":1526586949.0920913,"caller":"api/capability.go:76","msg":"enabled capabilities for version","cluster-version":"3.5"}` +> `{"level":"info","ts":1526586949.0921566,"caller":"etcdserver/server.go:2272","msg":"cluster version is updated","cluster-version":"3.5"}` + +Member 2: + +> `{"level":"info","ts":1526586949.092117,"caller":"membership/cluster.go:473","msg":"updated cluster version","cluster-id":"7dee9ba76d59ed53","local-member-id":"729934363faa4a24","from":"3.4","from":"3.5"}` +> `{"level":"info","ts":1526586949.0923078,"caller":"api/capability.go:76","msg":"enabled capabilities for version","cluster-version":"3.5"}` + +Member 3: + +> `{"level":"info","ts":1526586949.0921423,"caller":"membership/cluster.go:473","msg":"updated cluster version","cluster-id":"7dee9ba76d59ed53","local-member-id":"b548c2511513015","from":"3.4","from":"3.5"}` +> `{"level":"info","ts":1526586949.0922918,"caller":"api/capability.go:76","msg":"enabled capabilities for version","cluster-version":"3.5"}` + + +```bash +endpoint health --endpoints=localhost:2379,localhost:22379,localhost:32379 +< backup.snap -``` - -Now, import the snapshot into your new cluster: - -``` -etcdctl --endpoint new_cluster.example.com import --snap backup.snap -``` - -If you have a large amount of data, you can specify more concurrent works to copy data in parallel by using `-c` flag. -If you have hidden keys to copy, you can use `--hidden` flag to specify. For example fleet uses `/_coreos.com/fleet` so to import those keys use `--hidden /_coreos.com`. - -And the data will quickly copy into the new cluster: - -``` -entering dir: / -entering dir: /foo -entering dir: /foo/bar -copying key: /foo/bar/1 1 -entering dir: / -entering dir: /foo2 -entering dir: /foo2/bar2 -copying key: /foo2/bar2/2 2 -``` diff --git a/Documentation/v2/README.md b/Documentation/v2/README.md deleted file mode 100644 index 76e54ff64..000000000 --- a/Documentation/v2/README.md +++ /dev/null @@ -1,85 +0,0 @@ -# Documentation - -etcd is a distributed key-value store designed to reliably and quickly preserve and provide access to critical data. It enables reliable distributed coordination through distributed locking, leader elections, and write barriers. An etcd cluster is intended for high availability and permanent data storage and retrieval. - -This is the etcd v2 documentation set. For more recent versions, please see the [etcd v3 guides][etcd-v3]. - -## Communicating with etcd v2 - -Reading and writing into the etcd keyspace is done via a simple, RESTful HTTP API, or using language-specific libraries that wrap the HTTP API with higher level primitives. - -### Reading and Writing - - - [Client API Documentation][api] - - [Libraries, Tools, and Language Bindings][libraries] - - [Admin API Documentation][admin-api] - - [Members API][members-api] - -### Security, Auth, Access control - - - [Security Model][security] - - [Auth and Security][auth_api] - - [Authentication Guide][authentication] - -## etcd v2 Cluster Administration - -Configuration values are distributed within the cluster for your applications to read. Values can be changed programmatically and smart applications can reconfigure automatically. You'll never again have to run a configuration management tool on every machine in order to change a single config value. - -### General Info - - - [etcd Proxies][proxy] - - [Production Users][production-users] - - [Admin Guide][admin_guide] - - [Configuration Flags][configuration] - - [Frequently Asked Questions][faq] - -### Initial Setup - - - [Tuning etcd Clusters][tuning] - - [Discovery Service Protocol][discovery_protocol] - - [Running etcd under Docker][docker_guide] - -### Live Reconfiguration - - - [Runtime Configuration][runtime-configuration] - -### Debugging etcd - - - [Metrics Collection][metrics] - - [Error Code][errorcode] - - [Reporting Bugs][reporting_bugs] - -### Migration - - - [Upgrade etcd to 2.3][upgrade_2_3] - - [Upgrade etcd to 2.2][upgrade_2_2] - - [Upgrade to etcd 2.1][upgrade_2_1] - - [Snapshot Migration (0.4.x to 2.x)][04_to_2_snapshot_migration] - - [Backward Compatibility][backward_compatibility] - - -[etcd-v3]: ../docs.md -[api]: api.md -[libraries]: libraries-and-tools.md -[admin-api]: other_apis.md -[members-api]: members_api.md -[security]: security.md -[auth_api]: auth_api.md -[authentication]: authentication.md -[proxy]: proxy.md -[production-users]: production-users.md -[admin_guide]: admin_guide.md -[configuration]: configuration.md -[faq]: faq.md -[tuning]: tuning.md -[discovery_protocol]: discovery_protocol.md -[docker_guide]: docker_guide.md -[runtime-configuration]: runtime-configuration.md -[metrics]: metrics.md -[errorcode]: errorcode.md -[reporting_bugs]: reporting_bugs.md -[upgrade_2_3]: upgrade_2_3.md -[upgrade_2_2]: upgrade_2_2.md -[upgrade_2_1]: upgrade_2_1.md -[04_to_2_snapshot_migration]: 04_to_2_snapshot_migration.md -[backward_compatibility]: backward_compatibility.md diff --git a/Documentation/v2/admin_guide.md b/Documentation/v2/admin_guide.md deleted file mode 100644 index b09a2ffba..000000000 --- a/Documentation/v2/admin_guide.md +++ /dev/null @@ -1,317 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Administration - -## Data Directory - -### Lifecycle - -When first started, etcd stores its configuration into a data directory specified by the data-dir configuration parameter. -Configuration is stored in the write ahead log and includes: the local member ID, cluster ID, and initial cluster configuration. -The write ahead log and snapshot files are used during member operation and to recover after a restart. - -Having a dedicated disk to store wal files can improve the throughput and stabilize the cluster. -It is highly recommended to dedicate a wal disk and set `--wal-dir` to point to a directory on that device for a production cluster deployment. - -If a member’s data directory is ever lost or corrupted then the user should [remove][remove-a-member] the etcd member from the cluster using `etcdctl` tool. - -A user should avoid restarting an etcd member with a data directory from an out-of-date backup. -Using an out-of-date data directory can lead to inconsistency as the member had agreed to store information via raft then re-joins saying it needs that information again. -For maximum safety, if an etcd member suffers any sort of data corruption or loss, it must be removed from the cluster. -Once removed the member can be re-added with an empty data directory. - -### Contents - -The data directory has two sub-directories in it: - -1. wal: write ahead log files are stored here. For details see the [wal package documentation][wal-pkg] -2. snap: log snapshots are stored here. For details see the [snap package documentation][snap-pkg] - -If `--wal-dir` flag is set, etcd will write the write ahead log files to the specified directory instead of data directory. - -## Cluster Management - -### Lifecycle - -If you are spinning up multiple clusters for testing it is recommended that you specify a unique initial-cluster-token for the different clusters. -This can protect you from cluster corruption in case of mis-configuration because two members started with different cluster tokens will refuse members from each other. - -### Monitoring - -It is important to monitor your production etcd cluster for healthy information and runtime metrics. - -#### Health Monitoring - -At lowest level, etcd exposes health information via HTTP at `/health` in JSON format. If it returns `{"health":"true"}`, then the cluster is healthy. - -``` -$ curl -L http://127.0.0.1:2379/health - -{"health":"true"} -``` - -You can also use etcdctl to check the cluster-wide health information. It will contact all the members of the cluster and collect the health information for you. - -``` -$./etcdctl cluster-health -member 8211f1d0f64f3269 is healthy: got healthy result from http://127.0.0.1:12379 -member 91bc3c398fb3c146 is healthy: got healthy result from http://127.0.0.1:22379 -member fd422379fda50e48 is healthy: got healthy result from http://127.0.0.1:32379 -cluster is healthy -``` - -#### Runtime Metrics - -etcd uses [Prometheus][prometheus] for metrics reporting in the server. You can read more through the runtime metrics [doc][metrics]. - -### Debugging - -Debugging a distributed system can be difficult. etcd provides several ways to make debug -easier. - -#### Enabling Debug Logging - -When you want to debug etcd without stopping it, you can enable debug logging at runtime. -etcd exposes logging configuration at `/config/local/log`. - -``` -$ curl http://127.0.0.1:2379/config/local/log -XPUT -d '{"Level":"DEBUG"}' -$ # debug logging enabled -$ -$ curl http://127.0.0.1:2379/config/local/log -XPUT -d '{"Level":"INFO"}' -$ # debug logging disabled -``` - -#### Debugging Variables - -Debug variables are exposed for real-time debugging purposes. Developers who are familiar with etcd can utilize these variables to debug unexpected behavior. etcd exposes debug variables via HTTP at `/debug/vars` in JSON format. The debug variables contains -`cmdline`, `file_descriptor_limit`, `memstats` and `raft.status`. - -`cmdline` is the command line arguments passed into etcd. - -`file_descriptor_limit` is the max number of file descriptors etcd can utilize. - -`memstats` is explained in detail in the [Go runtime documentation][golang-memstats]. - -`raft.status` is useful when you want to debug low level raft issues if you are familiar with raft internals. In most cases, you do not need to check `raft.status`. - -```json -{ -"cmdline": ["./etcd"], -"file_descriptor_limit": 0, -"memstats": {"Alloc":4105744,"TotalAlloc":42337320,"Sys":12560632,"...":"..."}, -"raft.status": {"id":"ce2a822cea30bfca","term":5,"vote":"ce2a822cea30bfca","commit":23509,"lead":"ce2a822cea30bfca","raftState":"StateLeader","progress":{"ce2a822cea30bfca":{"match":23509,"next":23510,"state":"ProgressStateProbe"}}} -} -``` - -### Optimal Cluster Size - -The recommended etcd cluster size is 3, 5 or 7, which is decided by the fault tolerance requirement. A 7-member cluster can provide enough fault tolerance in most cases. While larger cluster provides better fault tolerance the write performance reduces since data needs to be replicated to more machines. - -#### Fault Tolerance Table - -It is recommended to have an odd number of members in a cluster. Having an odd cluster size doesn't change the number needed for majority, but you gain a higher tolerance for failure by adding the extra member. You can see this in practice when comparing even and odd sized clusters: - -| Cluster Size | Majority | Failure Tolerance | -|--------------|------------|-------------------| -| 1 | 1 | 0 | -| 2 | 2 | 0 | -| 3 | 2 | **1** | -| 4 | 3 | 1 | -| 5 | 3 | **2** | -| 6 | 4 | 2 | -| 7 | 4 | **3** | -| 8 | 5 | 3 | -| 9 | 5 | **4** | - -As you can see, adding another member to bring the size of cluster up to an odd size is always worth it. During a network partition, an odd number of members also guarantees that there will almost always be a majority of the cluster that can continue to operate and be the source of truth when the partition ends. - -#### Changing Cluster Size - -After your cluster is up and running, adding or removing members is done via [runtime reconfiguration][runtime-reconfig], which allows the cluster to be modified without downtime. The `etcdctl` tool has `member list`, `member add` and `member remove` commands to complete this process. - -### Member Migration - -When there is a scheduled machine maintenance or retirement, you might want to migrate an etcd member to another machine without losing the data and changing the member ID. - -The data directory contains all the data to recover a member to its point-in-time state. To migrate a member: - -* Stop the member process. -* Copy the data directory of the now-idle member to the new machine. -* Update the peer URLs for the replaced member to reflect the new machine according to the [runtime reconfiguration instructions][update-a-member]. -* Start etcd on the new machine, using the same configuration and the copy of the data directory. - -This example will walk you through the process of migrating the infra1 member to a new machine: - -|Name|Peer URL| -|------|--------------| -|infra0|10.0.1.10:2380| -|infra1|10.0.1.11:2380| -|infra2|10.0.1.12:2380| - -```sh -$ export ETCDCTL_ENDPOINT=http://10.0.1.10:2379,http://10.0.1.11:2379,http://10.0.1.12:2379 -``` - -```sh -$ etcdctl member list -84194f7c5edd8b37: name=infra0 peerURLs=http://10.0.1.10:2380 clientURLs=http://127.0.0.1:2379,http://10.0.1.10:2379 -b4db3bf5e495e255: name=infra1 peerURLs=http://10.0.1.11:2380 clientURLs=http://127.0.0.1:2379,http://10.0.1.11:2379 -bc1083c870280d44: name=infra2 peerURLs=http://10.0.1.12:2380 clientURLs=http://127.0.0.1:2379,http://10.0.1.12:2379 -``` - -#### Stop the member etcd process - -```sh -$ ssh 10.0.1.11 -``` - -```sh -$ kill `pgrep etcd` -``` - -#### Copy the data directory of the now-idle member to the new machine - -``` -$ tar -cvzf infra1.etcd.tar.gz %data_dir% -``` - -```sh -$ scp infra1.etcd.tar.gz 10.0.1.13:~/ -``` - -#### Update the peer URLs for that member to reflect the new machine - -```sh -$ curl http://10.0.1.10:2379/v2/members/b4db3bf5e495e255 -XPUT \ --H "Content-Type: application/json" -d '{"peerURLs":["http://10.0.1.13:2380"]}' -``` - -Or use `etcdctl member update` command - -```sh -$ etcdctl member update b4db3bf5e495e255 http://10.0.1.13:2380 -``` - -#### Start etcd on the new machine, using the same configuration and the copy of the data directory - -```sh -$ ssh 10.0.1.13 -``` - -```sh -$ tar -xzvf infra1.etcd.tar.gz -C %data_dir% -``` - -``` -etcd -name infra1 \ --listen-peer-urls http://10.0.1.13:2380 \ --listen-client-urls http://10.0.1.13:2379,http://127.0.0.1:2379 \ --advertise-client-urls http://10.0.1.13:2379,http://127.0.0.1:2379 -``` - -### Disaster Recovery - -etcd is designed to be resilient to machine failures. An etcd cluster can automatically recover from any number of temporary failures (for example, machine reboots), and a cluster of N members can tolerate up to _(N-1)/2_ permanent failures (where a member can no longer access the cluster, due to hardware failure or disk corruption). However, in extreme circumstances, a cluster might permanently lose enough members such that quorum is irrevocably lost. For example, if a three-node cluster suffered two simultaneous and unrecoverable machine failures, it would be normally impossible for the cluster to restore quorum and continue functioning. - -To recover from such scenarios, etcd provides functionality to backup and restore the datastore and recreate the cluster without data loss. - -#### Backing up the datastore - -**Note:** Windows users must stop etcd before running the backup command. - -The first step of the recovery is to backup the data directory and wal directory, if stored separately, on a functioning etcd node. To do this, use the `etcdctl backup` command, passing in the original data (and wal) directory used by etcd. For example: - -```sh - etcdctl backup \ - --data-dir %data_dir% \ - [--wal-dir %wal_dir%] \ - --backup-dir %backup_data_dir% - [--backup-wal-dir %backup_wal_dir%] -``` - -This command will rewrite some of the metadata contained in the backup (specifically, the node ID and cluster ID), which means that the node will lose its former identity. In order to recreate a cluster from the backup, you will need to start a new, single-node cluster. The metadata is rewritten to prevent the new node from inadvertently being joined onto an existing cluster. - -#### Restoring a backup - -To restore a backup using the procedure created above, start etcd with the `-force-new-cluster` option and pointing to the backup directory. This will initialize a new, single-member cluster with the default advertised peer URLs, but preserve the entire contents of the etcd data store. Continuing from the previous example: - -```sh - etcd \ - -data-dir=%backup_data_dir% \ - [-wal-dir=%backup_wal_dir%] \ - -force-new-cluster \ - ... -``` - -Now etcd should be available on this node and serving the original datastore. - -Once you have verified that etcd has started successfully, shut it down and move the data and wal, if stored separately, back to the previous location (you may wish to make another copy as well to be safe): - -```sh - pkill etcd - rm -fr %data_dir% - rm -fr %wal_dir% - mv %backup_data_dir% %data_dir% - mv %backup_wal_dir% %wal_dir% - etcd \ - -data-dir=%data_dir% \ - [-wal-dir=%wal_dir%] \ - ... -``` - -#### Restoring the cluster - -Now that the node is running successfully, [change its advertised peer URLs][update-a-member], as the `--force-new-cluster` option has set the peer URL to the default listening on localhost. - -You can then add more nodes to the cluster and restore resiliency. See the [add a new member][add-a-member] guide for more details. - -**Note:** If you are trying to restore your cluster using old failed etcd nodes, please make sure you have stopped old etcd instances and removed their old data directories specified by the data-dir configuration parameter. - -### Client Request Timeout - -etcd sets different timeouts for various types of client requests. The timeout value is not tunable now, which will be improved soon (https://github.com/coreos/etcd/issues/2038). - -#### Get requests - -Timeout is not set for get requests, because etcd serves the result locally in a non-blocking way. - -**Note**: QuorumGet request is a different type, which is mentioned in the following sections. - -#### Watch requests - -Timeout is not set for watch requests. etcd will not stop a watch request until client cancels it, or the connection is broken. - -#### Delete, Put, Post, QuorumGet requests - -The default timeout is 5 seconds. It should be large enough to allow all key modifications if the majority of cluster is functioning. - -If the request times out, it indicates two possibilities: - -1. the server the request sent to was not functioning at that time. -2. the majority of the cluster is not functioning. - -If timeout happens several times continuously, administrators should check status of cluster and resolve it as soon as possible. - -### Best Practices - -#### Maximum OS threads - -By default, etcd uses the default configuration of the Go 1.4 runtime, which means that at most one operating system thread will be used to execute code simultaneously. (Note that this default behavior [has changed in Go 1.5][golang1.5-runtime]). - -When using etcd in heavy-load scenarios on machines with multiple cores it will usually be desirable to increase the number of threads that etcd can utilize. To do this, simply set the environment variable GOMAXPROCS to the desired number when starting etcd. For more information on this variable, see the [Go runtime documentation][golang-runtime]. - -[add-a-member]: runtime-configuration.md#add-a-new-member -[golang1.5-runtime]: https://golang.org/doc/go1.5#runtime -[golang-memstats]: https://golang.org/pkg/runtime/#MemStats -[golang-runtime]: https://golang.org/pkg/runtime -[metrics]: metrics.md -[prometheus]: http://prometheus.io/ -[remove-a-member]: runtime-configuration.md#remove-a-member -[runtime-reconfig]: runtime-configuration.md#cluster-reconfiguration-operations -[snap-pkg]: http://godoc.org/github.com/coreos/etcd/snap -[update-a-member]: runtime-configuration.md#update-a-member -[wal-pkg]: http://godoc.org/github.com/coreos/etcd/wal diff --git a/Documentation/v2/api.md b/Documentation/v2/api.md deleted file mode 100644 index 367873df0..000000000 --- a/Documentation/v2/api.md +++ /dev/null @@ -1,1155 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# etcd API - -## Running a Single Machine Cluster - -These examples will use a single member cluster to show you the basics of the etcd REST API. -Let's start etcd: - -```sh -./bin/etcd -``` - -This will bring up etcd listening on the IANA assigned ports and listening on localhost. -The IANA assigned ports for etcd are 2379 for client communication and 2380 for server-to-server communication. - -## Getting the etcd version - -The etcd version of a specific instance can be obtained from the `/version` endpoint. - -```sh -curl -L http://127.0.0.1:2379/version -``` - -## Key Space Operations - -The primary API of etcd is a hierarchical key space. -The key space consists of directories and keys which are generically referred to as "nodes". - -### Setting the value of a key - -Let's set the first key-value pair in the datastore. -In this case the key is `/message` and the value is `Hello world`. - -```sh -curl http://127.0.0.1:2379/v2/keys/message -XPUT -d value="Hello world" -``` - -```json -{ - "action": "set", - "node": { - "createdIndex": 2, - "key": "/message", - "modifiedIndex": 2, - "value": "Hello world" - } -} -``` - -The response object contains several attributes: - -1. `action`: the action of the request that was just made. -The request attempted to modify `node.value` via a `PUT` HTTP request, thus the value of action is `set`. - -2. `node.key`: the HTTP path to which the request was made. -We set `/message` to `Hello world`, so the key field is `/message`. -etcd uses a file-system-like structure to represent the key-value pairs, therefore all keys start with `/`. - -3. `node.value`: the value of the key after resolving the request. -In this case, a successful request was made that attempted to change the node's value to `Hello world`. - -4. `node.createdIndex`: an index is a unique, monotonically-incrementing integer created for each change to etcd. -This specific index reflects the point in the etcd state member at which a given key was created. -You may notice that in this example the index is `2` even though it is the first request you sent to the server. -This is because there are internal commands that also change the state behind the scenes, like adding and syncing servers. - -5. `node.modifiedIndex`: like `node.createdIndex`, this attribute is also an etcd index. -Actions that cause the value to change include `set`, `delete`, `update`, `create`, `compareAndSwap` and `compareAndDelete`. -Since the `get` and `watch` commands do not change state in the store, they do not change the value of `node.modifiedIndex`. - - -### Response Headers - -etcd includes a few HTTP headers in responses that provide global information about the etcd cluster that serviced a request: - -``` -X-Etcd-Index: 35 -X-Raft-Index: 5398 -X-Raft-Term: 1 -``` - -* `X-Etcd-Index` is the current etcd index as explained above. When request is a watch on key space, `X-Etcd-Index` is the current etcd index when the watch starts, which means that the watched event may happen after `X-Etcd-Index`. -* `X-Raft-Index` is similar to the etcd index but is for the underlying raft protocol. -* `X-Raft-Term` is an integer that will increase whenever an etcd master election happens in the cluster. If this number is increasing rapidly, you may need to tune the election timeout. See the [tuning][tuning] section for details. - -### Get the value of a key - -We can get the value that we just set in `/message` by issuing a `GET` request: - -```sh -curl http://127.0.0.1:2379/v2/keys/message -``` - -```json -{ - "action": "get", - "node": { - "createdIndex": 2, - "key": "/message", - "modifiedIndex": 2, - "value": "Hello world" - } -} -``` - - -### Changing the value of a key - -You can change the value of `/message` from `Hello world` to `Hello etcd` with another `PUT` request to the key: - -```sh -curl http://127.0.0.1:2379/v2/keys/message -XPUT -d value="Hello etcd" -``` - -```json -{ - "action": "set", - "node": { - "createdIndex": 3, - "key": "/message", - "modifiedIndex": 3, - "value": "Hello etcd" - }, - "prevNode": { - "createdIndex": 2, - "key": "/message", - "value": "Hello world", - "modifiedIndex": 2 - } -} -``` - -Here we introduce a new field: `prevNode`. The `prevNode` field represents what the state of a given node was before resolving the request at hand. The `prevNode` field follows the same format as the `node`, and is omitted in the event that there was no previous state for a given node. - -### Deleting a key - -You can remove the `/message` key with a `DELETE` request: - -```sh -curl http://127.0.0.1:2379/v2/keys/message -XDELETE -``` - -```json -{ - "action": "delete", - "node": { - "createdIndex": 3, - "key": "/message", - "modifiedIndex": 4 - }, - "prevNode": { - "key": "/message", - "value": "Hello etcd", - "modifiedIndex": 3, - "createdIndex": 3 - } -} -``` - - -### Using key TTL - -Keys in etcd can be set to expire after a specified number of seconds. -You can do this by setting a TTL (time to live) on the key when sending a `PUT` request: - -```sh -curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -d ttl=5 -``` - -```json -{ - "action": "set", - "node": { - "createdIndex": 5, - "expiration": "2013-12-04T12:01:21.874888581-08:00", - "key": "/foo", - "modifiedIndex": 5, - "ttl": 5, - "value": "bar" - } -} -``` - -Note the two new fields in response: - -1. The `expiration` is the time at which this key will expire and be deleted. - -2. The `ttl` is the specified time to live for the key, in seconds. - -_NOTE_: Keys can only be expired by a cluster leader, so if a member gets disconnected from the cluster, its keys will not expire until it rejoins. - -Now you can try to get the key by sending a `GET` request: - -```sh -curl http://127.0.0.1:2379/v2/keys/foo -``` - -If the TTL has expired, the key will have been deleted, and you will be returned a 100. - -```json -{ - "cause": "/foo", - "errorCode": 100, - "index": 6, - "message": "Key not found" -} -``` - -The TTL can be unset to avoid expiration through update operation: - -```sh -curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -d ttl= -d prevExist=true -``` - -```json -{ - "action": "update", - "node": { - "createdIndex": 5, - "key": "/foo", - "modifiedIndex": 6, - "value": "bar" - }, - "prevNode": { - "createdIndex": 5, - "expiration": "2013-12-04T12:01:21.874888581-08:00", - "key": "/foo", - "modifiedIndex": 5, - "ttl": 3, - "value": "bar" - } -} -``` - -### Refreshing key TTL - -Keys in etcd can be refreshed without notifying current watchers. - -This can be achieved by setting the refresh to true when updating a TTL. - -You cannot update the value of a key when refreshing it. - -```sh -curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -d ttl=5 -curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d ttl=5 -d refresh=true -d prevExist=true -``` - -```json -{ - "action": "set", - "node": { - "createdIndex": 5, - "expiration": "2013-12-04T12:01:21.874888581-08:00", - "key": "/foo", - "modifiedIndex": 5, - "ttl": 5, - "value": "bar" - } -} -{ - "action":"update", - "node":{ - "key":"/foo", - "value":"bar", - "expiration": "2013-12-04T12:01:26.874888581-08:00", - "ttl":5, - "modifiedIndex":6, - "createdIndex":5 - }, - "prevNode":{ - "key":"/foo", - "value":"bar", - "expiration":"2013-12-04T12:01:21.874888581-08:00", - "ttl":3, - "modifiedIndex":5, - "createdIndex":5 - } -} -``` - -### Waiting for a change - -We can watch for a change on a key and receive a notification by using long polling. -This also works for child keys by passing `recursive=true` in curl. - -In one terminal, we send a `GET` with `wait=true` : - -```sh -curl http://127.0.0.1:2379/v2/keys/foo?wait=true -``` - -Now we are waiting for any changes at path `/foo`. - -In another terminal, we set a key `/foo` with value `bar`: - -```sh -curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -``` - -The first terminal should get the notification and return with the same response as the set request: - -```json -{ - "action": "set", - "node": { - "createdIndex": 7, - "key": "/foo", - "modifiedIndex": 7, - "value": "bar" - }, - "prevNode": { - "createdIndex": 6, - "key": "/foo", - "modifiedIndex": 6, - "value": "bar" - } -} -``` - -However, the watch command can do more than this. -Using the index, we can watch for commands that have happened in the past. -This is useful for ensuring you don't miss events between watch commands. -Typically, we watch again from the `modifiedIndex` + 1 of the node we got. - -Let's try to watch for the set command of index 7 again: - -```sh -curl 'http://127.0.0.1:2379/v2/keys/foo?wait=true&waitIndex=7' -``` - -The watch command returns immediately with the same response as previously. - -If we were to restart the watch from index 8 with: - -```sh -curl 'http://127.0.0.1:2379/v2/keys/foo?wait=true&waitIndex=8' -``` - -Then even if etcd is on index 9 or 800, the first event to occur to the `/foo` -key between 8 and the current index will be returned. - -**Note**: etcd only keeps the responses of the most recent 1000 events across all etcd keys. -It is recommended to send the response to another thread to process immediately -instead of blocking the watch while processing the result. - -#### Watch from cleared event index - -If we miss all the 1000 events, we need to recover the current state of the -watching key space through a get and then start to watch from the -`X-Etcd-Index` + 1. - -For example, we set `/other="bar"` for 2000 times and try to wait from index 8. - -```sh -curl 'http://127.0.0.1:2379/v2/keys/foo?wait=true&waitIndex=8' -``` - -We get the index is outdated response, since we miss the 1000 events kept in etcd. - -``` -{"errorCode":401,"message":"The event in requested index is outdated and cleared","cause":"the requested history has been cleared [1008/8]","index":2007} -``` - -To start watch, first we need to fetch the current state of key `/foo`: - -```sh -curl 'http://127.0.0.1:2379/v2/keys/foo' -vv -``` - -``` -< HTTP/1.1 200 OK -< Content-Type: application/json -< X-Etcd-Cluster-Id: 7e27652122e8b2ae -< X-Etcd-Index: 2007 -< X-Raft-Index: 2615 -< X-Raft-Term: 2 -< Date: Mon, 05 Jan 2015 18:54:43 GMT -< Transfer-Encoding: chunked -< -{"action":"get","node":{"key":"/foo","value":"bar","modifiedIndex":7,"createdIndex":7}} -``` - -Unlike watches we use the `X-Etcd-Index` + 1 of the response as a `waitIndex` -instead of the node's `modifiedIndex` + 1 for two reasons: - -1. The `X-Etcd-Index` is always greater than or equal to the `modifiedIndex` when - getting a key because `X-Etcd-Index` is the current etcd index, and the `modifiedIndex` - is the index of an event already stored in etcd. -2. None of the events represented by indexes between `modifiedIndex` and - `X-Etcd-Index` will be related to the key being fetched. - -Using the `modifiedIndex` + 1 is functionally equivalent for subsequent -watches, but since it is smaller than the `X-Etcd-Index` + 1, we may receive a -`401 EventIndexCleared` error immediately. - -So the first watch after the get should be: - -```sh -curl 'http://127.0.0.1:2379/v2/keys/foo?wait=true&waitIndex=2008' -``` - -#### Connection being closed prematurely - -The server may close a long polling connection before emitting any events. -This can happen due to a timeout or the server being shutdown. -Since the HTTP header is sent immediately upon accepting the connection, the response will be seen as empty: `200 OK` and empty body. -The clients should be prepared to deal with this scenario and retry the watch. - -### Atomically Creating In-Order Keys - -Using `POST` on a directory, you can create keys with key names that are created in-order. -This can be used in a variety of useful patterns, like implementing queues of keys which need to be processed in strict order. -An example use case would be ensuring clients get fair access to a mutex. - -Creating an in-order key is easy: - -```sh -curl http://127.0.0.1:2379/v2/keys/queue -XPOST -d value=Job1 -``` - -```json -{ - "action": "create", - "node": { - "createdIndex": 6, - "key": "/queue/00000000000000000006", - "modifiedIndex": 6, - "value": "Job1" - } -} -``` - -If you create another entry some time later, it is guaranteed to have a key name that is greater than the previous key. -Also note the key names use the global etcd index, so the next key can be more than `previous + 1`. - -```sh -curl http://127.0.0.1:2379/v2/keys/queue -XPOST -d value=Job2 -``` - -```json -{ - "action": "create", - "node": { - "createdIndex": 29, - "key": "/queue/00000000000000000029", - "modifiedIndex": 29, - "value": "Job2" - } -} -``` - -To enumerate the in-order keys as a sorted list, use the "sorted" parameter. - -```sh -curl -s 'http://127.0.0.1:2379/v2/keys/queue?recursive=true&sorted=true' -``` - -```json -{ - "action": "get", - "node": { - "createdIndex": 2, - "dir": true, - "key": "/queue", - "modifiedIndex": 2, - "nodes": [ - { - "createdIndex": 2, - "key": "/queue/00000000000000000002", - "modifiedIndex": 2, - "value": "Job1" - }, - { - "createdIndex": 3, - "key": "/queue/00000000000000000003", - "modifiedIndex": 3, - "value": "Job2" - } - ] - } -} -``` - - -### Using a directory TTL - -Like keys, directories in etcd can be set to expire after a specified number of seconds. -You can do this by setting a TTL (time to live) on a directory when it is created with a `PUT`: - -```sh -curl http://127.0.0.1:2379/v2/keys/dir -XPUT -d ttl=30 -d dir=true -``` - -```json -{ - "action": "set", - "node": { - "createdIndex": 17, - "dir": true, - "expiration": "2013-12-11T10:37:33.689275857-08:00", - "key": "/dir", - "modifiedIndex": 17, - "ttl": 30 - } -} -``` - -The directory's TTL can be refreshed by making an update. -You can do this by making a PUT with `prevExist=true` and a new TTL. - -```sh -curl http://127.0.0.1:2379/v2/keys/dir -XPUT -d ttl=30 -d dir=true -d prevExist=true -``` - -Keys that are under this directory work as usual, but when the directory expires, a watcher on a key under the directory will get an expire event: - -```sh -curl 'http://127.0.0.1:2379/v2/keys/dir?wait=true' -``` - -```json -{ - "action": "expire", - "node": { - "createdIndex": 8, - "key": "/dir", - "modifiedIndex": 15 - }, - "prevNode": { - "createdIndex": 8, - "key": "/dir", - "dir":true, - "modifiedIndex": 17, - "expiration": "2013-12-11T10:39:35.689275857-08:00" - } -} -``` - - -### Atomic Compare-and-Swap - -etcd can be used as a centralized coordination service in a cluster, and `CompareAndSwap` (CAS) is the most basic operation used to build a distributed lock service. - -This command will set the value of a key only if the client-provided conditions are equal to the current conditions. - -*Note that `CompareAndSwap` does not work with [directories][directories]. If an attempt is made to `CompareAndSwap` a directory, a 102 "Not a file" error will be returned.* - -The current comparable conditions are: - -1. `prevValue` - checks the previous value of the key. - -2. `prevIndex` - checks the previous modifiedIndex of the key. - -3. `prevExist` - checks existence of the key: if `prevExist` is true, it is an `update` request; if `prevExist` is `false`, it is a `create` request. - -Here is a simple example. -Let's create a key-value pair first: `foo=one`. - -```sh -curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=one -``` - -```json -{ - "action":"set", - "node":{ - "key":"/foo", - "value":"one", - "modifiedIndex":4, - "createdIndex":4 - } -} -``` - -Specifying `noValueOnSuccess` option skips returning the node as value. - -```sh -curl http://127.0.0.1:2379/v2/keys/foo?noValueOnSuccess=true -XPUT -d value=one -# {"action":"set"} -``` - -Now let's try some invalid `CompareAndSwap` commands. - -Trying to set this existing key with `prevExist=false` fails as expected: -```sh -curl http://127.0.0.1:2379/v2/keys/foo?prevExist=false -XPUT -d value=three -``` - -The error code explains the problem: - -```json -{ - "cause": "/foo", - "errorCode": 105, - "index": 39776, - "message": "Key already exists" -} -``` - -Now let's provide a `prevValue` parameter: - -```sh -curl http://127.0.0.1:2379/v2/keys/foo?prevValue=two -XPUT -d value=three -``` - -This will try to compare the previous value of the key and the previous value we provided. If they are equal, the value of the key will change to three. - -```json -{ - "cause": "[two != one]", - "errorCode": 101, - "index": 8, - "message": "Compare failed" -} -``` - -which means `CompareAndSwap` failed. `cause` explains why the test failed. -Note: the condition prevIndex=0 always passes. - -Let's try a valid condition: - -```sh -curl http://127.0.0.1:2379/v2/keys/foo?prevValue=one -XPUT -d value=two -``` - -The response should be: - -```json -{ - "action": "compareAndSwap", - "node": { - "createdIndex": 8, - "key": "/foo", - "modifiedIndex": 9, - "value": "two" - }, - "prevNode": { - "createdIndex": 8, - "key": "/foo", - "modifiedIndex": 8, - "value": "one" - } -} -``` - -We successfully changed the value from "one" to "two" since we gave the correct previous value. - -### Atomic Compare-and-Delete - -This command will delete a key only if the client-provided conditions are equal to the current conditions. - -*Note that `CompareAndDelete` does not work with [directories]. If an attempt is made to `CompareAndDelete` a directory, a 102 "Not a file" error will be returned.* - -The current comparable conditions are: - -1. `prevValue` - checks the previous value of the key. - -2. `prevIndex` - checks the previous modifiedIndex of the key. - -Here is a simple example. Let's first create a key: `foo=one`. - -```sh -curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=one -``` - -Now let's try some `CompareAndDelete` commands. - -Trying to delete the key with `prevValue=two` fails as expected: -```sh -curl http://127.0.0.1:2379/v2/keys/foo?prevValue=two -XDELETE -``` - -The error code explains the problem: - -```json -{ - "errorCode": 101, - "message": "Compare failed", - "cause": "[two != one]", - "index": 8 -} -``` - -As does a `CompareAndDelete` with a mismatched `prevIndex`: - -```sh -curl http://127.0.0.1:2379/v2/keys/foo?prevIndex=1 -XDELETE -``` - -```json -{ - "errorCode": 101, - "message": "Compare failed", - "cause": "[1 != 8]", - "index": 8 -} -``` - -And now a valid `prevValue` condition: - -```sh -curl http://127.0.0.1:2379/v2/keys/foo?prevValue=one -XDELETE -``` - -The successful response will look something like: - -```json -{ - "action": "compareAndDelete", - "node": { - "key": "/foo", - "modifiedIndex": 9, - "createdIndex": 8 - }, - "prevNode": { - "key": "/foo", - "value": "one", - "modifiedIndex": 8, - "createdIndex": 8 - } -} -``` - -### Creating Directories - -In most cases, directories for a key are automatically created. -But there are cases where you will want to create a directory or remove one. - -Creating a directory is just like a key except you cannot provide a value and must add the `dir=true` parameter. - -```sh -curl http://127.0.0.1:2379/v2/keys/dir -XPUT -d dir=true -``` -```json -{ - "action": "set", - "node": { - "createdIndex": 30, - "dir": true, - "key": "/dir", - "modifiedIndex": 30 - } -} -``` - - -### Listing a directory - -In etcd we can store two types of things: keys and directories. -Keys store a single string value. -Directories store a set of keys and/or other directories. - -In this example, let's first create some keys: - -We already have `/foo=two` so now we'll create another one called `/foo_dir/foo` with the value of `bar`: - -```sh -curl http://127.0.0.1:2379/v2/keys/foo_dir/foo -XPUT -d value=bar -``` - -```json -{ - "action": "set", - "node": { - "createdIndex": 2, - "key": "/foo_dir/foo", - "modifiedIndex": 2, - "value": "bar" - } -} -``` - -Now we can list the keys under root `/`: - -```sh -curl http://127.0.0.1:2379/v2/keys/ -``` - -We should see the response as an array of items: - -```json -{ - "action": "get", - "node": { - "key": "/", - "dir": true, - "nodes": [ - { - "key": "/foo_dir", - "dir": true, - "modifiedIndex": 2, - "createdIndex": 2 - }, - { - "key": "/foo", - "value": "two", - "modifiedIndex": 1, - "createdIndex": 1 - } - ] - } -} -``` - -Here we can see `/foo` is a key-value pair under `/` and `/foo_dir` is a directory. -We can also recursively get all the contents under a directory by adding `recursive=true`. - -```sh -curl http://127.0.0.1:2379/v2/keys/?recursive=true -``` - -```json -{ - "action": "get", - "node": { - "key": "/", - "dir": true, - "nodes": [ - { - "key": "/foo_dir", - "dir": true, - "nodes": [ - { - "key": "/foo_dir/foo", - "value": "bar", - "modifiedIndex": 2, - "createdIndex": 2 - } - ], - "modifiedIndex": 2, - "createdIndex": 2 - }, - { - "key": "/foo", - "value": "two", - "modifiedIndex": 1, - "createdIndex": 1 - } - ] - } -} -``` - - -### Deleting a Directory - -Now let's try to delete the directory `/foo_dir`. - -You can remove an empty directory using the `DELETE` verb and the `dir=true` parameter. - -```sh -curl 'http://127.0.0.1:2379/v2/keys/foo_dir?dir=true' -XDELETE -``` -```json -{ - "action": "delete", - "node": { - "createdIndex": 30, - "dir": true, - "key": "/foo_dir", - "modifiedIndex": 31 - }, - "prevNode": { - "createdIndex": 30, - "key": "/foo_dir", - "dir": true, - "modifiedIndex": 30 - } -} -``` - -To delete a directory that holds keys, you must add `recursive=true`. - -```sh -curl http://127.0.0.1:2379/v2/keys/dir?recursive=true -XDELETE -``` - -```json -{ - "action": "delete", - "node": { - "createdIndex": 10, - "dir": true, - "key": "/dir", - "modifiedIndex": 11 - }, - "prevNode": { - "createdIndex": 10, - "dir": true, - "key": "/dir", - "modifiedIndex": 10 - } -} -``` - - -### Creating a hidden node - -We can create a hidden key-value pair or directory by add a `_` prefix. -The hidden item will not be listed when sending a `GET` request for a directory. - -First we'll add a hidden key named `/_message`: - -```sh -curl http://127.0.0.1:2379/v2/keys/_message -XPUT -d value="Hello hidden world" -``` - -```json -{ - "action": "set", - "node": { - "createdIndex": 3, - "key": "/_message", - "modifiedIndex": 3, - "value": "Hello hidden world" - } -} -``` - -Next we'll add a regular key named `/message`: - -```sh -curl http://127.0.0.1:2379/v2/keys/message -XPUT -d value="Hello world" -``` - -```json -{ - "action": "set", - "node": { - "createdIndex": 4, - "key": "/message", - "modifiedIndex": 4, - "value": "Hello world" - } -} -``` - -Now let's try to get a listing of keys under the root directory, `/`: - -```sh -curl http://127.0.0.1:2379/v2/keys/ -``` - -```json -{ - "action": "get", - "node": { - "dir": true, - "key": "/", - "nodes": [ - { - "createdIndex": 2, - "dir": true, - "key": "/foo_dir", - "modifiedIndex": 2 - }, - { - "createdIndex": 4, - "key": "/message", - "modifiedIndex": 4, - "value": "Hello world" - } - ] - } -} -``` - -Here we see the `/message` key but our hidden `/_message` key is not returned. - -### Setting a key from a file - -You can also use etcd to store small configuration files, JSON documents, XML documents, etc directly. -For example you can use curl to upload a simple text file and encode it: - -``` -echo "Hello\nWorld" > afile.txt -curl http://127.0.0.1:2379/v2/keys/afile -XPUT --data-urlencode value@afile.txt -``` - -```json -{ - "action": "get", - "node": { - "createdIndex": 2, - "key": "/afile", - "modifiedIndex": 2, - "value": "Hello\nWorld\n" - } -} -``` - -### Read Linearization - -If you want a read that is fully linearized you can use a `quorum=true` GET. -The read will take a very similar path to a write and will have a similar -speed. If you are unsure if you need this feature feel free to email etcd-dev -for advice. - -## Statistics - -An etcd cluster keeps track of a number of statistics including latency, bandwidth and uptime. -These are exposed via the statistics endpoint to understand the internal health of a cluster. - -### Leader Statistics - -The leader has a view of the entire cluster and keeps track of two interesting statistics: latency to each peer in the cluster, and the number of failed and successful Raft RPC requests. -You can grab these statistics from the `/v2/stats/leader` endpoint: - -```sh -curl http://127.0.0.1:2379/v2/stats/leader -``` - -```json -{ - "followers": { - "6e3bd23ae5f1eae0": { - "counts": { - "fail": 0, - "success": 745 - }, - "latency": { - "average": 0.017039507382550306, - "current": 0.000138, - "maximum": 1.007649, - "minimum": 0, - "standardDeviation": 0.05289178277920594 - } - }, - "a8266ecf031671f3": { - "counts": { - "fail": 0, - "success": 735 - }, - "latency": { - "average": 0.012124141496598642, - "current": 0.000559, - "maximum": 0.791547, - "minimum": 0, - "standardDeviation": 0.04187900156583733 - } - } - }, - "leader": "924e2e83e93f2560" -} -``` - - -### Self Statistics - -Each node keeps a number of internal statistics: - -- `id`: the unique identifier for the member -- `leaderInfo.leader`: id of the current leader member -- `leaderInfo.uptime`: amount of time the leader has been leader -- `name`: this member's name -- `recvAppendRequestCnt`: number of append requests this node has processed -- `recvBandwidthRate`: number of bytes per second this node is receiving (follower only) -- `recvPkgRate`: number of requests per second this node is receiving (follower only) -- `sendAppendRequestCnt`: number of requests that this node has sent -- `sendBandwidthRate`: number of bytes per second this node is sending (leader only). This value is undefined on single member clusters. -- `sendPkgRate`: number of requests per second this node is sending (leader only). This value is undefined on single member clusters. -- `state`: either leader or follower -- `startTime`: the time when this node was started - -This is an example response from a follower member: - -```sh -curl http://127.0.0.1:2379/v2/stats/self -``` - -```json -{ - "id": "eca0338f4ea31566", - "leaderInfo": { - "leader": "8a69d5f6b7814500", - "startTime": "2014-10-24T13:15:51.186620747-07:00", - "uptime": "10m59.322358947s" - }, - "name": "node3", - "recvAppendRequestCnt": 5944, - "recvBandwidthRate": 570.6254930219969, - "recvPkgRate": 9.00892789741075, - "sendAppendRequestCnt": 0, - "startTime": "2014-10-24T13:15:50.072007085-07:00", - "state": "StateFollower" -} -``` - -And this is an example response from a leader member: - -```sh -curl http://127.0.0.1:2379/v2/stats/self -``` - -```json -{ - "id": "924e2e83e93f2560", - "leaderInfo": { - "leader": "924e2e83e93f2560", - "startTime": "2015-02-09T11:38:30.177534688-08:00", - "uptime": "9m33.891343412s" - }, - "name": "infra3", - "recvAppendRequestCnt": 0, - "sendAppendRequestCnt": 6535, - "sendBandwidthRate": 824.1758351191694, - "sendPkgRate": 11.111234716807138, - "startTime": "2015-02-09T11:38:28.972034204-08:00", - "state": "StateLeader" -} -``` - - -### Store Statistics - -The store statistics include information about the operations that this node has handled. -Note that v2 `store Statistics` is stored in-memory. When a member stops, store statistics will reset on restart. - -Operations that modify the store's state like create, delete, set and update are seen by the entire cluster and the number will increase on all nodes. -Operations like get and watch are node local and will only be seen on this node. - -```sh -curl http://127.0.0.1:2379/v2/stats/store -``` - -```json -{ - "compareAndSwapFail": 0, - "compareAndSwapSuccess": 0, - "createFail": 0, - "createSuccess": 2, - "deleteFail": 0, - "deleteSuccess": 0, - "expireCount": 0, - "getsFail": 4, - "getsSuccess": 75, - "setsFail": 2, - "setsSuccess": 4, - "updateFail": 0, - "updateSuccess": 0, - "watchers": 0 -} -``` - -## Cluster Config - -See the [members API][members-api] for details on the cluster management. - -[directories]: #listing-a-directory -[members-api]: members_api.md -[tuning]: tuning.md diff --git a/Documentation/v2/api_v3.md b/Documentation/v2/api_v3.md deleted file mode 100644 index e59a04e75..000000000 --- a/Documentation/v2/api_v3.md +++ /dev/null @@ -1,97 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# etcd3 API - -TODO: API doc - -## Data Model - -etcd is designed to reliably store infrequently updated data and provide reliable watch queries. etcd exposes previous versions of key-value pairs to support inexpensive snapshots and watch history events (“time travel queries”). A persistent, multi-version, concurrency-control data model is a good fit for these use cases. - -etcd stores data in a multiversion [persistent][persistent-ds] key-value store. The persistent key-value store preserves the previous version of a key-value pair when its value is superseded with new data. The key-value store is effectively immutable; its operations do not update the structure in-place, but instead always generates a new updated structure. All past versions of keys are still accessible and watchable after modification. To prevent the data store from growing indefinitely over time from maintaining old versions, the store may be compacted to shed the oldest versions of superseded data. - -### Logical View - -The store’s logical view is a flat binary key space. The key space has a lexically sorted index on byte string keys so range queries are inexpensive. - -The key space maintains multiple revisions. Each atomic mutative operation (e.g., a transaction operation may contain multiple operations) creates a new revision on the key space. All data held by previous revisions remains unchanged. Old versions of key can still be accessed through previous revisions. Likewise, revisions are indexed as well; ranging over revisions with watchers is efficient. If the store is compacted to recover space, revisions before the compact revision will be removed. - -A key’s lifetime spans a generation. Each key may have one or multiple generations. Creating a key increments the generation of that key, starting at 1 if the key never existed. Deleting a key generates a key tombstone, concluding the key’s current generation. Each modification of a key creates a new version of the key. Once a compaction happens, any generation ended before the given revision will be removed and values set before the compaction revision except the latest one will be removed. - -### Physical View - -etcd stores the physical data as key-value pairs in a persistent [b+tree][b+tree]. Each revision of the store’s state only contains the delta from its previous revision to be efficient. A single revision may correspond to multiple keys in the tree. - -The key of key-value pair is a 3-tuple (major, sub, type). Major is the store revision holding the key. Sub differentiates among keys within the same revision. Type is an optional suffix for special value (e.g., `t` if the value contains a tombstone). The value of the key-value pair contains the modification from previous revision, thus one delta from previous revision. The b+tree is ordered by key in lexical byte-order. Ranged lookups over revision deltas are fast; this enables quickly finding modifications from one specific revision to another. Compaction removes out-of-date keys-value pairs. - -etcd also keeps a secondary in-memory [btree][btree] index to speed up range queries over keys. The keys in the btree index are the keys of the store exposed to user. The value is a pointer to the modification of the persistent b+tree. Compaction removes dead pointers. - -## KV API Guarantees - -etcd is a consistent and durable key value store with mini-transaction(TODO: link to txn doc when we have it) support. The key value store is exposed through the KV APIs. etcd tries to ensure the strongest consistency and durability guarantees for a distributed system. This specification enumerates the KV API guarantees made by etcd. - -### APIs to consider - -* Read APIs - * range - * watch -* Write APIs - * put - * delete -* Combination (read-modify-write) APIs - * txn - -### etcd Specific Definitions - -#### operation completed - -An etcd operation is considered complete when it is committed through consensus, and therefore “executed” -- permanently stored -- by the etcd storage engine. The client knows an operation is completed when it receives a response from the etcd server. Note that the client may be uncertain about the status of an operation if it times out, or there is a network disruption between the client and the etcd member. etcd may also abort operations when there is a leader election. etcd does not send `abort` responses to clients’ outstanding requests in this event. - -#### revision - -An etcd operation that modifies the key value store is assigned with a single increasing revision. A transaction operation might modify the key value store multiple times, but only one revision is assigned. The revision attribute of a key value pair that modified by the operation has the same value as the revision of the operation. The revision can be used as a logical clock for key value store. A key value pair that has a larger revision is modified after a key value pair with a smaller revision. Two key value pairs that have the same revision are modified by an operation "concurrently". - -### Guarantees Provided - -#### Atomicity - -All API requests are atomic; an operation either completes entirely or not at all. For watch requests, all events generated by one operation will be in one watch response. Watch never observes partial events for a single operation. - -#### Consistency - -All API calls ensure [sequential consistency][seq_consistency], the strongest consistency guarantee available from distributed systems. No matter which etcd member server a client makes requests to, a client reads the same events in the same order. If two members complete the same number of operations, the state of the two members is consistent. - -For watch operations, etcd guarantees to return the same value for the same key across all members for the same revision. For range operations, etcd has a similar guarantee for [linearized][Linearizability] access; serialized access may be behind the quorum state, so that the later revision is not yet available. - -As with all distributed systems, it is impossible for etcd to ensure [strict consistency][strict_consistency]. etcd does not guarantee that it will return to a read the “most recent” value (as measured by a wall clock when a request is completed) available on any cluster member. - -#### Isolation - -etcd ensures [serializable isolation][serializable_isolation], which is the highest isolation level available in distributed systems. Read operations will never observe any intermediate data. - -#### Durability - -Any completed operations are durable. All accessible data is also durable data. A read will never return data that has not been made durable. - -#### Linearizability - -Linearizability (also known as Atomic Consistency or External Consistency) is a consistency level between strict consistency and sequential consistency. - -For linearizability, suppose each operation receives a timestamp from a loosely synchronized global clock. Operations are linearized if and only if they always complete as though they were executed in a sequential order and each operation appears to complete in the order specified by the program. Likewise, if an operation’s timestamp precedes another, that operation must also precede the other operation in the sequence. - -For example, consider a client completing a write at time point 1 (*t1*). A client issuing a read at *t2* (for *t2* > *t1*) should receive a value at least as recent as the previous write, completed at *t1*. However, the read might actually complete only by *t3*, and the returned value, current at *t2* when the read began, might be "stale" by *t3*. - -etcd does not ensure linearizability for watch operations. Users are expected to verify the revision of watch responses to ensure correct ordering. - -etcd ensures linearizability for all other operations by default. Linearizability comes with a cost, however, because linearized requests must go through the Raft consensus process. To obtain lower latencies and higher throughput for read requests, clients can configure a request’s consistency mode to `serializable`, which may access stale data with respect to quorum, but removes the performance penalty of linearized accesses' reliance on live consensus. - -[persistent-ds]: https://en.wikipedia.org/wiki/Persistent_data_structure -[btree]: https://en.wikipedia.org/wiki/B-tree -[b+tree]: https://en.wikipedia.org/wiki/B%2B_tree -[seq_consistency]: https://en.wikipedia.org/wiki/Consistency_model#Sequential_consistency -[strict_consistency]: https://en.wikipedia.org/wiki/Consistency_model#Strict_consistency -[serializable_isolation]: https://en.wikipedia.org/wiki/Isolation_(database_systems)#Serializable -[Linearizability]: #linearizability diff --git a/Documentation/v2/auth_api.md b/Documentation/v2/auth_api.md deleted file mode 100644 index 225ba3a63..000000000 --- a/Documentation/v2/auth_api.md +++ /dev/null @@ -1,516 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# v2 Auth and Security - -## etcd Resources -There are three types of resources in etcd - -1. permission resources: users and roles in the user store -2. key-value resources: key-value pairs in the key-value store -3. settings resources: security settings, auth settings, and dynamic etcd cluster settings (election/heartbeat) - -### Permission Resources - -#### Users -A user is an identity to be authenticated. Each user can have multiple roles. The user has a capability (such as reading or writing) on the resource if one of the roles has that capability. - -A user named `root` is required before authentication can be enabled, and it always has the ROOT role. The ROOT role can be granted to multiple users, but `root` is required for recovery purposes. - -#### Roles -Each role has exact one associated Permission List. An permission list exists for each permission on key-value resources. - -The special static ROOT (named `root`) role has a full permissions on all key-value resources, the permission to manage user resources and settings resources. Only the ROOT role has the permission to manage user resources and modify settings resources. The ROOT role is built-in and does not need to be created. - -There is also a special GUEST role, named 'guest'. These are the permissions given to unauthenticated requests to etcd. This role will be created automatically, and by default allows access to the full keyspace due to backward compatibility. (etcd did not previously authenticate any actions.). This role can be modified by a ROOT role holder at any time, to reduce the capabilities of unauthenticated users. - -#### Permissions - -There are two types of permissions, `read` and `write`. All management and settings require the ROOT role. - -A Permission List is a list of allowed patterns for that particular permission (read or write). Only ALLOW prefixes are supported. DENY becomes more complicated and is TBD. - -### Key-Value Resources -A key-value resource is a key-value pairs in the store. Given a list of matching patterns, permission for any given key in a request is granted if any of the patterns in the list match. - -Only prefixes or exact keys are supported. A prefix permission string ends in `*`. -A permission on `/foo` is for that exact key or directory, not its children or recursively. `/foo*` is a prefix that matches `/foo` recursively, and all keys thereunder, and keys with that prefix (eg. `/foobar`. Contrast to the prefix `/foo/*`). `*` alone is permission on the full keyspace. - -### Settings Resources - -Specific settings for the cluster as a whole. This can include adding and removing cluster members, enabling or disabling authentication, replacing certificates, and any other dynamic configuration by the administrator (holder of the ROOT role). - -## v2 Auth - -### Basic Auth -We only support [Basic Auth][basic-auth] for the first version. Client needs to attach the basic auth to the HTTP Authorization Header. - -### Authorization field for operations -Added to requests to /v2/keys, /v2/auth -Add code 401 Unauthorized to the set of responses from the v2 API -Authorization: Basic {encoded string} - -### Future Work -Other types of auth can be considered for the future (eg, signed certs, public keys) but the `Authorization:` header allows for other such types - -### Things out of Scope for etcd Permissions - -* Pluggable AUTH backends like LDAP (other Authorization tokens generated by LDAP et al may be a possibility) -* Very fine-grained access controls (eg: users modifying keys outside work hours) - - - -## API endpoints - -An Error JSON corresponds to: -{ - "name": "ErrErrorName", - "description" : "The longer helpful description of the error." -} - -#### Enable and Disable Authentication - -**Get auth status** - -GET /v2/auth/enable - - Sent Headers: - Possible Status Codes: - 200 OK - 200 Body: - { - "enabled": true - } - - -**Enable auth** - -PUT /v2/auth/enable - - Sent Headers: - Put Body: (empty) - Possible Status Codes: - 200 OK - 400 Bad Request (if root user has not been created) - 409 Conflict (already enabled) - 200 Body: (empty) - -**Disable auth** - -DELETE /v2/auth/enable - - Sent Headers: - Authorization: Basic - Possible Status Codes: - 200 OK - 401 Unauthorized (if not a root user) - 409 Conflict (already disabled) - 200 Body: (empty) - - -#### Users - -The User JSON object is formed as follows: - -``` -{ - "user": "userName", - "password": "password", - "roles": [ - "role1", - "role2" - ], - "grant": [], - "revoke": [] -} -``` - -Password is only passed when necessary. - -**Get a List of Users** - -GET/HEAD /v2/auth/users - - Sent Headers: - Authorization: Basic - Possible Status Codes: - 200 OK - 401 Unauthorized - 200 Headers: - Content-type: application/json - 200 Body: - { - "users": [ - { - "user": "alice", - "roles": [ - { - "role": "root", - "permissions": { - "kv": { - "read": ["/*"], - "write": ["/*"] - } - } - } - ] - }, - { - "user": "bob", - "roles": [ - { - "role": "guest", - "permissions": { - "kv": { - "read": ["/*"], - "write": ["/*"] - } - } - } - ] - } - ] - } - -**Get User Details** - -GET/HEAD /v2/auth/users/alice - - Sent Headers: - Authorization: Basic - Possible Status Codes: - 200 OK - 401 Unauthorized - 404 Not Found - 200 Headers: - Content-type: application/json - 200 Body: - { - "user" : "alice", - "roles" : [ - { - "role": "fleet", - "permissions" : { - "kv" : { - "read": [ "/fleet/" ], - "write": [ "/fleet/" ] - } - } - }, - { - "role": "etcd", - "permissions" : { - "kv" : { - "read": [ "/*" ], - "write": [ "/*" ] - } - } - } - ] - } - -**Create Or Update A User** - -A user can be created with initial roles, if filled in. However, no roles are required; only the username and password fields - -PUT /v2/auth/users/charlie - - Sent Headers: - Authorization: Basic - Put Body: - JSON struct, above, matching the appropriate name - * Starting password and roles when creating. - * Grant/Revoke/Password filled in when updating (to grant roles, revoke roles, or change the password). - Possible Status Codes: - 200 OK - 201 Created - 400 Bad Request - 401 Unauthorized - 404 Not Found (update non-existent users) - 409 Conflict (when granting duplicated roles or revoking non-existent roles) - 200 Headers: - Content-type: application/json - 200 Body: - JSON state of the user - -**Remove A User** - -DELETE /v2/auth/users/charlie - - Sent Headers: - Authorization: Basic - Possible Status Codes: - 200 OK - 401 Unauthorized - 403 Forbidden (remove root user when auth is enabled) - 404 Not Found - 200 Headers: - 200 Body: (empty) - -#### Roles - -A full role structure may look like this. A Permission List structure is used for the "permissions", "grant", and "revoke" keys. -``` -{ - "role" : "fleet", - "permissions" : { - "kv" : { - "read" : [ "/fleet/" ], - "write": [ "/fleet/" ] - } - }, - "grant" : {"kv": {...}}, - "revoke": {"kv": {...}} -} -``` - -**Get Role Details** - -GET/HEAD /v2/auth/roles/fleet - - Sent Headers: - Authorization: Basic - Possible Status Codes: - 200 OK - 401 Unauthorized - 404 Not Found - 200 Headers: - Content-type: application/json - 200 Body: - { - "role" : "fleet", - "permissions" : { - "kv" : { - "read": [ "/fleet/" ], - "write": [ "/fleet/" ] - } - } - } - -**Get a list of Roles** - -GET/HEAD /v2/auth/roles - - Sent Headers: - Authorization: Basic - Possible Status Codes: - 200 OK - 401 Unauthorized - 200 Headers: - Content-type: application/json - 200 Body: - { - "roles": [ - { - "role": "fleet", - "permissions": { - "kv": { - "read": ["/fleet/"], - "write": ["/fleet/"] - } - } - }, - { - "role": "etcd", - "permissions": { - "kv": { - "read": ["/*"], - "write": ["/*"] - } - } - }, - { - "role": "quay", - "permissions": { - "kv": { - "read": ["/*"], - "write": ["/*"] - } - } - } - ] - } - -**Create Or Update A Role** - -PUT /v2/auth/roles/rkt - - Sent Headers: - Authorization: Basic - Put Body: - Initial desired JSON state, including the role name for verification and: - * Starting permission set if creating - * Granted/Revoked permission set if updating - Possible Status Codes: - 200 OK - 201 Created - 400 Bad Request - 401 Unauthorized - 404 Not Found (update non-existent roles) - 409 Conflict (when granting duplicated permission or revoking non-existent permission) - 200 Body: - JSON state of the role - -**Remove A Role** - -DELETE /v2/auth/roles/rkt - - Sent Headers: - Authorization: Basic - Possible Status Codes: - 200 OK - 401 Unauthorized - 403 Forbidden (remove root) - 404 Not Found - 200 Headers: - 200 Body: (empty) - - -## Example Workflow - -Let's walk through an example to show two tenants (applications, in our case) using etcd permissions. - -### Create root role - -``` -PUT /v2/auth/users/root - Put Body: - {"user" : "root", "password": "betterRootPW!"} -``` - -### Enable auth - -``` -PUT /v2/auth/enable -``` - -### Modify guest role (revoke write permission) - -``` -PUT /v2/auth/roles/guest - Headers: - Authorization: Basic - Put Body: - { - "role" : "guest", - "revoke" : { - "kv" : { - "write": [ - "/*" - ] - } - } - } -``` - - -### Create Roles for the Applications - -Create the rkt role fully specified: - -``` -PUT /v2/auth/roles/rkt - Headers: - Authorization: Basic - Body: - { - "role" : "rkt", - "permissions" : { - "kv": { - "read": [ - "/rkt/*" - ], - "write": [ - "/rkt/*" - ] - } - } - } -``` - -But let's make fleet just a basic role for now: - -``` -PUT /v2/auth/roles/fleet - Headers: - Authorization: Basic - Body: - { - "role" : "fleet" - } -``` - -### Optional: Grant some permissions to the roles - -Well, we finally figured out where we want fleet to live. Let's fix it. -(Note that we avoided this in the rkt case. So this step is optional.) - - -``` -PUT /v2/auth/roles/fleet - Headers: - Authorization: Basic - Put Body: - { - "role" : "fleet", - "grant" : { - "kv" : { - "read": [ - "/rkt/fleet", - "/fleet/*" - ] - } - } - } -``` - -### Create Users - -Same as before, let's use rocket all at once and fleet separately - -``` -PUT /v2/auth/users/rktuser - Headers: - Authorization: Basic - Body: - {"user" : "rktuser", "password" : "rktpw", "roles" : ["rkt"]} -``` - -``` -PUT /v2/auth/users/fleetuser - Headers: - Authorization: Basic - Body: - {"user" : "fleetuser", "password" : "fleetpw"} -``` - -### Optional: Grant Roles to Users - -Likewise, let's explicitly grant fleetuser access. - -``` -PUT /v2/auth/users/fleetuser - Headers: - Authorization: Basic - Body: - {"user": "fleetuser", "grant": ["fleet"]} -``` - -#### Start to use fleetuser and rktuser - - -For example: - -``` -PUT /v2/keys/rkt/RktData - Headers: - Authorization: Basic - Body: - value=launch -``` - -Reads and writes outside the prefixes granted will fail with a 401 Unauthorized. - -[basic-auth]: https://en.wikipedia.org/wiki/Basic_access_authentication diff --git a/Documentation/v2/authentication.md b/Documentation/v2/authentication.md deleted file mode 100644 index 05adf0600..000000000 --- a/Documentation/v2/authentication.md +++ /dev/null @@ -1,185 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Authentication Guide - -## Overview - -Authentication -- having users and roles in etcd -- was added in etcd 2.1. This guide will help you set up basic authentication in etcd. - -etcd before 2.1 was a completely open system; anyone with access to the API could change keys. In order to preserve backward compatibility and upgradability, this feature is off by default. - -For a full discussion of the RESTful API, see [the authentication API documentation][auth-api] - -## Special Users and Roles - -There is one special user, `root`, and there are two special roles, `root` and `guest`. - -### User `root` - -User `root` must be created before security can be activated. It has the `root` role and allows for the changing of anything inside etcd. The idea behind the `root` user is for recovery purposes -- a password is generated and stored somewhere -- and the root role is granted to the administrator accounts on the system. In the future, for troubleshooting and recovery, we will need to assume some access to the system, and future documentation will assume this root user (though anyone with the role will suffice). - -### Role `root` - -Role `root` cannot be modified, but it may be granted to any user. Having access via the root role not only allows global read-write access (as was the case before 2.1) but allows modification of the authentication policy and all administrative things, like modifying the cluster membership. - -### Role `guest` - -The `guest` role defines the permissions granted to any request that does not provide an authentication. This will be created on security activation (if it doesn't already exist) to have full access to all keys, as was true in etcd 2.0. It may be modified at any time, and cannot be removed. - -## Working with users - -The `user` subcommand for `etcdctl` handles all things having to do with user accounts. - -A listing of users can be found with - -``` -$ etcdctl user list -``` - -Creating a user is as easy as - -``` -$ etcdctl user add myusername -``` - -And there will be prompt for a new password. - -Roles can be granted and revoked for a user with - -``` -$ etcdctl user grant myusername -roles foo,bar,baz -$ etcdctl user revoke myusername -roles bar,baz -``` - -We can look at this user with - -``` -$ etcdctl user get myusername -``` - -And the password for a user can be changed with - -``` -$ etcdctl user passwd myusername -``` - -Which will prompt again for a new password. - -To delete an account, there's always -``` -$ etcdctl user remove myusername -``` - - -## Working with roles - -The `role` subcommand for `etcdctl` handles all things having to do with access controls for particular roles, as were granted to individual users. - -A listing of roles can be found with - -``` -$ etcdctl role list -``` - -A new role can be created with - -``` -$ etcdctl role add myrolename -``` - -A role has no password; we are merely defining a new set of access rights. - -Roles are granted access to various parts of the keyspace, a single path at a time. - -Reading a path is simple; if the path ends in `*`, that key **and all keys prefixed with it**, are granted to holders of this role. If it does not end in `*`, only that key and that key alone is granted. - -Access can be granted as either read, write, or both, as in the following examples: - -``` -# Give read access to keys under the /foo directory -$ etcdctl role grant myrolename -path '/foo/*' -read - -# Give write-only access to the key at /foo/bar -$ etcdctl role grant myrolename -path '/foo/bar' -write - -# Give full access to keys under /pub -$ etcdctl role grant myrolename -path '/pub/*' -readwrite -``` - -Beware that - -``` -# Give full access to keys under /pub?? -$ etcdctl role grant myrolename -path '/pub*' -readwrite -``` - -Without the slash may include keys under `/publishing`, for example. To do both, grant `/pub` and `/pub/*` - -To see what's granted, we can look at the role at any time: - -``` -$ etcdctl role get myrolename -``` - -Revocation of permissions is done the same logical way: - -``` -$ etcdctl role revoke myrolename -path '/foo/bar' -write -``` - -As is removing a role entirely - -``` -$ etcdctl role remove myrolename -``` - -## Enabling authentication - -The minimal steps to enabling auth are as follows. The administrator can set up users and roles before or after enabling authentication, as a matter of preference. - -Make sure the root user is created: - -``` -$ etcdctl user add root -New password: -``` - -And enable authentication - -``` -$ etcdctl auth enable -``` - -After this, etcd is running with authentication enabled. To disable it for any reason, use the reciprocal command: - -``` -$ etcdctl -u root:rootpw auth disable -``` - -It would also be good to check what guests (unauthenticated users) are allowed to do: -``` -$ etcdctl -u root:rootpw role get guest -``` - -And modify this role appropriately, depending on your policies. - -## Using `etcdctl` to authenticate - -`etcdctl` supports a similar flag as `curl` for authentication. - -``` -$ etcdctl -u user:password get foo -``` - -or if you prefer to be prompted: - -``` -$ etcdctl -u user get foo -``` - -Otherwise, all `etcdctl` commands remain the same. Users and roles can still be created and modified, but require authentication by a user with the root role. - -[auth-api]: auth_api.md diff --git a/Documentation/v2/backward_compatibility.md b/Documentation/v2/backward_compatibility.md deleted file mode 100644 index 3704325e7..000000000 --- a/Documentation/v2/backward_compatibility.md +++ /dev/null @@ -1,77 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Backward Compatibility - -The main goal of etcd 2.0 release is to improve cluster safety around bootstrapping and dynamic reconfiguration. To do this, we deprecated the old error-prone APIs and provide a new set of APIs. - -The other main focus of this release was a more reliable Raft implementation, but as this change is internal it should not have any notable effects to users. - -## Command Line Flags Changes - -The major flag changes are to mostly related to bootstrapping. The `initial-*` flags provide an improved way to specify the required criteria to start the cluster. The advertised URLs now support a list of values instead of a single value, which allows etcd users to gracefully migrate to the new set of IANA-assigned ports (2379/client and 2380/peers) while maintaining backward compatibility with the old ports. - - - `-addr` is replaced by `-advertise-client-urls`. - - `-bind-addr` is replaced by `-listen-client-urls`. - - `-peer-addr` is replaced by `-initial-advertise-peer-urls`. - - `-peer-bind-addr` is replaced by `-listen-peer-urls`. - - `-peers` is replaced by `-initial-cluster`. - - `-peers-file` is replaced by `-initial-cluster`. - - `-peer-heartbeat-interval` is replaced by `-heartbeat-interval`. - - `-peer-election-timeout` is replaced by `-election-timeout`. - -The documentation of new command line flags can be found at -https://github.com/coreos/etcd/blob/master/Documentation/v2/configuration.md. - -## Data Directory Naming - -The default data dir location has changed from {$hostname}.etcd to {name}.etcd. - -## Key-Value API - -### Read consistency flag - -The consistent flag for read operations is removed in etcd 2.0.0. The normal read operations provides the same consistency guarantees with the 0.4.6 read operations with consistent flag set. - -The read consistency guarantees are: - -The consistent read guarantees the sequential consistency within one client that talks to one etcd server. Read/Write from one client to one etcd member should be observed in order. If one client write a value to an etcd server successfully, it should be able to get the value out of the server immediately. - -Each etcd member will proxy the request to leader and only return the result to user after the result is applied on the local member. Thus after the write succeed, the user is guaranteed to see the value on the member it sent the request to. - -Reads do not provide linearizability. If you want linearizable read, you need to set quorum option to true. - -**Previous behavior** - -We added an option for a consistent read in the old version of etcd since etcd 0.x redirects the write request to the leader. When the user get back the result from the leader, the member it sent the request to originally might not apply the write request yet. With the consistent flag set to true, the client will always send read request to the leader. So one client should be able to see its last write when consistent=true is enabled. There is no order guarantees among different clients. - - -## Standby - -etcd 0.4’s standby mode has been deprecated. [Proxy mode][proxymode] is introduced to solve a subset of problems standby was solving. - -Standby mode was intended for large clusters that had a subset of the members acting in the consensus process. Overall this process was too magical and allowed for operators to back themselves into a corner. - -Proxy mode in 2.0 will provide similar functionality, and with improved control over which machines act as proxies due to the operator specifically configuring them. Proxies also support read only or read/write modes for increased security and durability. - -[proxymode]: proxy.md - -## Discovery Service - -A size key needs to be provided inside a [discovery token][discoverytoken]. - -[discoverytoken]: clustering.md#custom-etcd-discovery-service - -## HTTP Admin API - -`v2/admin` on peer url and `v2/keys/_etcd` are unified under the new [v2/members API][members-api] to better explain which machines are part of an etcd cluster, and to simplify the keyspace for all your use cases. - -[members-api]: members_api.md - -## HTTP Key Value API -- The follower can now transparently proxy write requests to the leader. Clients will no longer see 307 redirections to the leader from etcd. - -- Expiration time is in UTC instead of local time. - diff --git a/Documentation/v2/benchmarks/README.md b/Documentation/v2/benchmarks/README.md deleted file mode 100644 index 881641a79..000000000 --- a/Documentation/v2/benchmarks/README.md +++ /dev/null @@ -1,23 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../../docs.md#documentation - - -# Benchmarks - -etcd benchmarks will be published regularly and tracked for each release below: - -- [etcd v2.1.0-alpha][2.1] -- [etcd v2.2.0-rc][2.2] -- [etcd v3 demo][3.0] - -# Memory Usage Benchmarks - -It records expected memory usage in different scenarios. - -- [etcd v2.2.0-rc][2.2-mem] - -[2.1]: etcd-2-1-0-alpha-benchmarks.md -[2.2]: etcd-2-2-0-rc-benchmarks.md -[2.2-mem]: etcd-2-2-0-rc-memory-benchmarks.md -[3.0]: etcd-3-demo-benchmarks.md diff --git a/Documentation/v2/benchmarks/etcd-2-1-0-alpha-benchmarks.md b/Documentation/v2/benchmarks/etcd-2-1-0-alpha-benchmarks.md deleted file mode 100644 index 1fc808ec4..000000000 --- a/Documentation/v2/benchmarks/etcd-2-1-0-alpha-benchmarks.md +++ /dev/null @@ -1,57 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../../docs.md#documentation - - -## Physical machines - -GCE n1-highcpu-2 machine type - -- 1x dedicated local SSD mounted under /var/lib/etcd -- 1x dedicated slow disk for the OS -- 1.8 GB memory -- 2x CPUs -- etcd version 2.1.0 alpha - -## etcd Cluster - -3 etcd members, each runs on a single machine - -## Testing - -Bootstrap another machine and use the [boom HTTP benchmark tool][boom] to send requests to each etcd member. Check the [benchmark hacking guide][hack-benchmark] for detailed instructions. - -## Performance - -### reading one single key - -| key size in bytes | number of clients | target etcd server | read QPS | 90th Percentile Latency (ms) | -|-------------------|-------------------|--------------------|----------|---------------| -| 64 | 1 | leader only | 1534 | 0.7 | -| 64 | 64 | leader only | 10125 | 9.1 | -| 64 | 256 | leader only | 13892 | 27.1 | -| 256 | 1 | leader only | 1530 | 0.8 | -| 256 | 64 | leader only | 10106 | 10.1 | -| 256 | 256 | leader only | 14667 | 27.0 | -| 64 | 64 | all servers | 24200 | 3.9 | -| 64 | 256 | all servers | 33300 | 11.8 | -| 256 | 64 | all servers | 24800 | 3.9 | -| 256 | 256 | all servers | 33000 | 11.5 | - -### writing one single key - -| key size in bytes | number of clients | target etcd server | write QPS | 90th Percentile Latency (ms) | -|-------------------|-------------------|--------------------|-----------|---------------| -| 64 | 1 | leader only | 60 | 21.4 | -| 64 | 64 | leader only | 1742 | 46.8 | -| 64 | 256 | leader only | 3982 | 90.5 | -| 256 | 1 | leader only | 58 | 20.3 | -| 256 | 64 | leader only | 1770 | 47.8 | -| 256 | 256 | leader only | 4157 | 105.3 | -| 64 | 64 | all servers | 1028 | 123.4 | -| 64 | 256 | all servers | 3260 | 123.8 | -| 256 | 64 | all servers | 1033 | 121.5 | -| 256 | 256 | all servers | 3061 | 119.3 | - -[boom]: https://github.com/rakyll/boom -[hack-benchmark]: ../../../hack/benchmark/ diff --git a/Documentation/v2/benchmarks/etcd-2-2-0-benchmarks.md b/Documentation/v2/benchmarks/etcd-2-2-0-benchmarks.md deleted file mode 100644 index 2989c1a7d..000000000 --- a/Documentation/v2/benchmarks/etcd-2-2-0-benchmarks.md +++ /dev/null @@ -1,77 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../../docs.md#documentation - - -# Benchmarking etcd v2.2.0 - -## Physical Machines - -GCE n1-highcpu-2 machine type - -- 1x dedicated local SSD mounted as etcd data directory -- 1x dedicated slow disk for the OS -- 1.8 GB memory -- 2x CPUs - -## etcd Cluster - -3 etcd 2.2.0 members, each runs on a single machine. - -Detailed versions: - -``` -etcd Version: 2.2.0 -Git SHA: e4561dd -Go Version: go1.5 -Go OS/Arch: linux/amd64 -``` - -## Testing - -Bootstrap another machine, outside of the etcd cluster, and run the [`boom` HTTP benchmark tool][boom] with a connection reuse patch to send requests to each etcd cluster member. See the [benchmark instructions][hack] for the patch and the steps to reproduce our procedures. - -The performance is calulated through results of 100 benchmark rounds. - -## Performance - -### Single Key Read Performance - -| key size in bytes | number of clients | target etcd server | average read QPS | read QPS stddev | average 90th Percentile Latency (ms) | latency stddev | -|-------------------|-------------------|--------------------|------------------|-----------------|--------------------------------------|----------------| -| 64 | 1 | leader only | 2303 | 200 | 0.49 | 0.06 | -| 64 | 64 | leader only | 15048 | 685 | 7.60 | 0.46 | -| 64 | 256 | leader only | 14508 | 434 | 29.76 | 1.05 | -| 256 | 1 | leader only | 2162 | 214 | 0.52 | 0.06 | -| 256 | 64 | leader only | 14789 | 792 | 7.69| 0.48 | -| 256 | 256 | leader only | 14424 | 512 | 29.92 | 1.42 | -| 64 | 64 | all servers | 45752 | 2048 | 2.47 | 0.14 | -| 64 | 256 | all servers | 46592 | 1273 | 10.14 | 0.59 | -| 256 | 64 | all servers | 45332 | 1847 | 2.48| 0.12 | -| 256 | 256 | all servers | 46485 | 1340 | 10.18 | 0.74 | - -### Single Key Write Performance - -| key size in bytes | number of clients | target etcd server | average write QPS | write QPS stddev | average 90th Percentile Latency (ms) | latency stddev | -|-------------------|-------------------|--------------------|------------------|-----------------|--------------------------------------|----------------| -| 64 | 1 | leader only | 55 | 4 | 24.51 | 13.26 | -| 64 | 64 | leader only | 2139 | 125 | 35.23 | 3.40 | -| 64 | 256 | leader only | 4581 | 581 | 70.53 | 10.22 | -| 256 | 1 | leader only | 56 | 4 | 22.37| 4.33 | -| 256 | 64 | leader only | 2052 | 151 | 36.83 | 4.20 | -| 256 | 256 | leader only | 4442 | 560 | 71.59 | 10.03 | -| 64 | 64 | all servers | 1625 | 85 | 58.51 | 5.14 | -| 64 | 256 | all servers | 4461 | 298 | 89.47 | 36.48 | -| 256 | 64 | all servers | 1599 | 94 | 60.11| 6.43 | -| 256 | 256 | all servers | 4315 | 193 | 88.98 | 7.01 | - -## Performance Changes - -- Because etcd now records metrics for each API call, read QPS performance seems to see a minor decrease in most scenarios. This minimal performance impact was judged a reasonable investment for the breadth of monitoring and debugging information returned. - -- Write QPS to cluster leaders seems to be increased by a small margin. This is because the main loop and entry apply loops were decoupled in the etcd raft logic, eliminating several blocks between them. - -- Write QPS to all members seems to be increased by a significant margin, because followers now receive the latest commit index sooner, and commit proposals more quickly. - -[boom]: https://github.com/rakyll/boom -[hack]: ../../../hack/benchmark/ diff --git a/Documentation/v2/benchmarks/etcd-2-2-0-rc-benchmarks.md b/Documentation/v2/benchmarks/etcd-2-2-0-rc-benchmarks.md deleted file mode 100644 index 9170a644b..000000000 --- a/Documentation/v2/benchmarks/etcd-2-2-0-rc-benchmarks.md +++ /dev/null @@ -1,77 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../../docs.md#documentation - - -## Physical machines - -GCE n1-highcpu-2 machine type - -- 1x dedicated local SSD mounted under /var/lib/etcd -- 1x dedicated slow disk for the OS -- 1.8 GB memory -- 2x CPUs - -## etcd Cluster - -3 etcd 2.2.0-rc members, each runs on a single machine. - -Detailed versions: - -``` -etcd Version: 2.2.0-alpha.1+git -Git SHA: 59a5a7e -Go Version: go1.4.2 -Go OS/Arch: linux/amd64 -``` - -Also, we use 3 etcd 2.1.0 alpha-stage members to form cluster to get base performance. etcd's commit head is at [c7146bd5][c7146bd5], which is the same as the one that we use in [etcd 2.1 benchmark][etcd-2.1-benchmark]. - -## Testing - -Bootstrap another machine and use the [boom HTTP benchmark tool][boom] to send requests to each etcd member. Check the [benchmark hacking guide][hack-benchmark] for detailed instructions. - -## Performance - -### reading one single key - -| key size in bytes | number of clients | target etcd server | read QPS | 90th Percentile Latency (ms) | -|-------------------|-------------------|--------------------|----------|---------------| -| 64 | 1 | leader only | 2804 (-5%) | 0.4 (+0%) | -| 64 | 64 | leader only | 17816 (+0%) | 5.7 (-6%) | -| 64 | 256 | leader only | 18667 (-6%) | 20.4 (+2%) | -| 256 | 1 | leader only | 2181 (-15%) | 0.5 (+25%) | -| 256 | 64 | leader only | 17435 (-7%) | 6.0 (+9%) | -| 256 | 256 | leader only | 18180 (-8%) | 21.3 (+3%) | -| 64 | 64 | all servers | 46965 (-4%) | 2.1 (+0%) | -| 64 | 256 | all servers | 55286 (-6%) | 7.4 (+6%) | -| 256 | 64 | all servers | 46603 (-6%) | 2.1 (+5%) | -| 256 | 256 | all servers | 55291 (-6%) | 7.3 (+4%) | - -### writing one single key - -| key size in bytes | number of clients | target etcd server | write QPS | 90th Percentile Latency (ms) | -|-------------------|-------------------|--------------------|-----------|---------------| -| 64 | 1 | leader only | 76 (+22%) | 19.4 (-15%) | -| 64 | 64 | leader only | 2461 (+45%) | 31.8 (-32%) | -| 64 | 256 | leader only | 4275 (+1%) | 69.6 (-10%) | -| 256 | 1 | leader only | 64 (+20%) | 16.7 (-30%) | -| 256 | 64 | leader only | 2385 (+30%) | 31.5 (-19%) | -| 256 | 256 | leader only | 4353 (-3%) | 74.0 (+9%) | -| 64 | 64 | all servers | 2005 (+81%) | 49.8 (-55%) | -| 64 | 256 | all servers | 4868 (+35%) | 81.5 (-40%) | -| 256 | 64 | all servers | 1925 (+72%) | 47.7 (-59%) | -| 256 | 256 | all servers | 4975 (+36%) | 70.3 (-36%) | - -### performance changes explanation - -- read QPS in most scenarios is decreased by 5~8%. The reason is that etcd records store metrics for each store operation. The metrics is important for monitoring and debugging, so this is acceptable. - -- write QPS to leader is increased by 20~30%. This is because we decouple raft main loop and entry apply loop, which avoids them blocking each other. - -- write QPS to all servers is increased by 30~80% because follower could receive latest commit index earlier and commit proposals faster. - -[boom]: https://github.com/rakyll/boom -[c7146bd5]: https://github.com/coreos/etcd/commits/c7146bd5f2c73716091262edc638401bb8229144 -[etcd-2.1-benchmark]: etcd-2-1-0-alpha-benchmarks.md -[hack-benchmark]: ../../../hack/benchmark/ diff --git a/Documentation/v2/benchmarks/etcd-2-2-0-rc-memory-benchmarks.md b/Documentation/v2/benchmarks/etcd-2-2-0-rc-memory-benchmarks.md deleted file mode 100644 index 40c220eaa..000000000 --- a/Documentation/v2/benchmarks/etcd-2-2-0-rc-memory-benchmarks.md +++ /dev/null @@ -1,52 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../../docs.md#documentation - - -## Physical machine - -GCE n1-standard-2 machine type - -- 1x dedicated local SSD mounted under /var/lib/etcd -- 1x dedicated slow disk for the OS -- 7.5 GB memory -- 2x CPUs - -## etcd - -``` -etcd Version: 2.2.0-rc.0+git -Git SHA: 103cb5c -Go Version: go1.5 -Go OS/Arch: linux/amd64 -``` - -## Testing - -Start 3-member etcd cluster, each of which uses 2 cores. - -The length of key name is always 64 bytes, which is a reasonable length of average key bytes. - -## Memory Maximal Usage - -- etcd may use maximal memory if one follower is dead and the leader keeps sending snapshots. -- `max RSS` is the maximal memory usage recorded in 3 runs. - -| value bytes | key number | data size(MB) | max RSS(MB) | max RSS/data rate on leader | -|-------------|-------------|---------------|-------------|-----------------------------| -| 128 | 50000 | 6 | 433 | 72x | -| 128 | 100000 | 12 | 659 | 54x | -| 128 | 200000 | 24 | 1466 | 61x | -| 1024 | 50000 | 48 | 1253 | 26x | -| 1024 | 100000 | 96 | 2344 | 24x | -| 1024 | 200000 | 192 | 4361 | 22x | - -## Data Size Threshold - -- When etcd reaches data size threshold, it may trigger leader election easily and drop part of proposals. -- At most cases, etcd cluster should work smoothly if it doesn't hit the threshold. If it doesn't work well due to insufficient resources, you need to decrease its data size. - -| value bytes | key number limitation | suggested data size threshold(MB) | consumed RSS(MB) | -|-------------|-----------------------|-----------------------------------|------------------| -| 128 | 400K | 48 | 2400 | -| 1024 | 300K | 292 | 6500 | diff --git a/Documentation/v2/benchmarks/etcd-3-demo-benchmarks.md b/Documentation/v2/benchmarks/etcd-3-demo-benchmarks.md deleted file mode 100644 index cb59d173c..000000000 --- a/Documentation/v2/benchmarks/etcd-3-demo-benchmarks.md +++ /dev/null @@ -1,47 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../../docs.md#documentation - - -## Physical machines - -GCE n1-highcpu-2 machine type - -- 1x dedicated local SSD mounted under /var/lib/etcd -- 1x dedicated slow disk for the OS -- 1.8 GB memory -- 2x CPUs -- etcd version 2.2.0 - -## etcd Cluster - -1 etcd member running in v3 demo mode - -## Testing - -Use [etcd v3 benchmark tool][etcd-v3-benchmark]. - -## Performance - -### reading one single key - -| key size in bytes | number of clients | read QPS | 90th Percentile Latency (ms) | -|-------------------|-------------------|----------|---------------| -| 256 | 1 | 2716 | 0.4 | -| 256 | 64 | 16623 | 6.1 | -| 256 | 256 | 16622 | 21.7 | - -The performance is nearly the same as the one with empty server handler. - -### reading one single key after putting - -| key size in bytes | number of clients | read QPS | 90th Percentile Latency (ms) | -|-------------------|-------------------|----------|---------------| -| 256 | 1 | 2269 | 0.5 | -| 256 | 64 | 13582 | 8.6 | -| 256 | 256 | 13262 | 47.5 | - -The performance with empty server handler is not affected by one put. So the -performance downgrade should be caused by storage package. - -[etcd-v3-benchmark]: ../../../tools/benchmark/ diff --git a/Documentation/v2/benchmarks/etcd-3-watch-memory-benchmark.md b/Documentation/v2/benchmarks/etcd-3-watch-memory-benchmark.md deleted file mode 100644 index 56ae1a239..000000000 --- a/Documentation/v2/benchmarks/etcd-3-watch-memory-benchmark.md +++ /dev/null @@ -1,82 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../../docs.md#documentation - - -# Watch Memory Usage Benchmark - -*NOTE*: The watch features are under active development, and their memory usage may change as that development progresses. We do not expect it to significantly increase beyond the figures stated below. - -A primary goal of etcd is supporting a very large number of watchers doing a massively large amount of watching. etcd aims to support O(10k) clients, O(100K) watch streams (O(10) streams per client) and O(10M) total watchings (O(100) watching per stream). The memory consumed by each individual watching accounts for the largest portion of etcd's overall usage, and is therefore the focus of current and future optimizations. - - -Three related components of etcd watch consume physical memory: each `grpc.Conn`, each watch stream, and each instance of the watching activity. `grpc.Conn` maintains the actual TCP connection and other gRPC connection state. Each `grpc.Conn` consumes O(10kb) of memory, and might have multiple watch streams attached. - -Each watch stream is an independent HTTP2 connection which consumes another O(10kb) of memory. -Multiple watchings might share one watch stream. - -Watching is the actual struct that tracks the changes on the key-value store. Each watching should only consume < O(1kb). - -``` - +-------+ - | watch | - +---------> | foo | - | +-------+ - +------+-----+ - | stream | - +--------------> | | - | +------+-----+ +-------+ - | | | watch | - | +---------> | bar | -+-----+------+ +-------+ -| | +------------+ -| conn +-------> | stream | -| | | | -+-----+------+ +------------+ - | - | - | - | +------------+ - +--------------> | stream | - | | - +------------+ -``` - -The theoretical memory consumption of watch can be approximated with the formula: -`memory = c1 * number_of_conn + c2 * avg_number_of_stream_per_conn + c3 * avg_number_of_watch_stream` - -## Testing Environment - -etcd version -- git head https://github.com/coreos/etcd/commit/185097ffaa627b909007e772c175e8fefac17af3 - -GCE n1-standard-2 machine type -- 7.5 GB memory -- 2x CPUs - -## Overall memory usage - -The overall memory usage captures how much [RSS][rss] etcd consumes with the client watchers. While the result may vary by as much as 10%, it is still meaningful, since the goal is to learn about the rough memory usage and the pattern of allocations. - -With the benchmark result, we can calculate roughly that `c1 = 17kb`, `c2 = 18kb` and `c3 = 350bytes`. So each additional client connection consumes 17kb of memory and each additional stream consumes 18kb of memory, and each additional watching only cause 350bytes. A single etcd server can maintain millions of watchings with a few GB of memory in normal case. - - -| clients | streams per client | watchings per stream | total watching | memory usage | -|---------|---------|-----------|----------------|--------------| -| 1k | 1 | 1 | 1k | 50MB | -| 2k | 1 | 1 | 2k | 90MB | -| 5k | 1 | 1 | 5k | 200MB | -| 1k | 10 | 1 | 10k | 217MB | -| 2k | 10 | 1 | 20k | 417MB | -| 5k | 10 | 1 | 50k | 980MB | -| 1k | 50 | 1 | 50k | 1001MB | -| 2k | 50 | 1 | 100k | 1960MB | -| 5k | 50 | 1 | 250k | 4700MB | -| 1k | 50 | 10 | 500k | 1171MB | -| 2k | 50 | 10 | 1M | 2371MB | -| 5k | 50 | 10 | 2.5M | 5710MB | -| 1k | 50 | 100 | 5M | 2380MB | -| 2k | 50 | 100 | 10M | 4672MB | -| 5k | 50 | 100 | 50M | *OOM* | - -[rss]: https://en.wikipedia.org/wiki/Resident_set_size diff --git a/Documentation/v2/benchmarks/etcd-storage-memory-benchmark.md b/Documentation/v2/benchmarks/etcd-storage-memory-benchmark.md deleted file mode 100644 index 3f75b7920..000000000 --- a/Documentation/v2/benchmarks/etcd-storage-memory-benchmark.md +++ /dev/null @@ -1,103 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../../docs.md#documentation - - -# Storage Memory Usage Benchmark - - -Two components of etcd storage consume physical memory. The etcd process allocates an *in-memory index* to speed key lookup. The process's *page cache*, managed by the operating system, stores recently-accessed data from disk for quick re-use. - -The in-memory index holds all the keys in a [B-tree][btree] data structure, along with pointers to the on-disk data (the values). Each key in the B-tree may contain multiple pointers, pointing to different versions of its values. The theoretical memory consumption of the in-memory index can hence be approximated with the formula: - -`N * (c1 + avg_key_size) + N * (avg_versions_of_key) * (c2 + size_of_pointer)` - -where `c1` is the key metadata overhead and `c2` is the version metadata overhead. - -The graph shows the detailed structure of the in-memory index B-tree. - -``` - - - In mem index - - +------------+ - | key || ... | - +--------------+ | || | - | | +------------+ - | | | v1 || ... | - | disk <----------------| || | Tree Node - | | +------------+ - | | | v2 || ... | - | <----------------+ || | - | | +------------+ - +--------------+ +-----+ | | | - | | | | | - | +------------+ - | - | - ^ - ------+ - | ... | - | | - +-----+ - | ... | Tree Node - | | - +-----+ - | ... | - | | - ------+ -``` - -[Page cache memory][pagecache] is managed by the operating system and is not covered in detail in this document. - -## Testing Environment - -etcd version -- git head https://github.com/coreos/etcd/commit/776e9fb7be7eee5e6b58ab977c8887b4fe4d48db - -GCE n1-standard-2 machine type - -- 7.5 GB memory -- 2x CPUs - -## In-memory index memory usage - -In this test, we only benchmark the memory usage of the in-memory index. The goal is to find `c1` and `c2` mentioned above and to understand the hard limit of memory consumption of the storage. - -We calculate the memory usage consumption via the Go runtime.ReadMemStats. We calculate the total allocated bytes difference before creating the index and after creating the index. It cannot perfectly reflect the memory usage of the in-memory index itself but can show the rough consumption pattern. - -| N | versions | key size | memory usage | -|------|----------|----------|--------------| -| 100K | 1 | 64bytes | 22MB | -| 100K | 5 | 64bytes | 39MB | -| 1M | 1 | 64bytes | 218MB | -| 1M | 5 | 64bytes | 432MB | -| 100K | 1 | 256bytes | 41MB | -| 100K | 5 | 256bytes | 65MB | -| 1M | 1 | 256bytes | 409MB | -| 1M | 5 | 256bytes | 506MB | - - -Based on the result, we can calculate `c1=120bytes`, `c2=30bytes`. We only need two sets of data to calculate `c1` and `c2`, since they are the only unknown variable in the formula. The `c1=120bytes` and `c2=30bytes` are the average value of the 4 sets of `c1` and `c2` we calculated. The key metadata overhead is still relatively nontrivial (50%) for small key-value pairs. However, this is a significant improvement over the old store, which had at least 1000% overhead. - -## Overall memory usage - -The overall memory usage captures how much RSS etcd consumes with the storage. The value size should have very little impact on the overall memory usage of etcd, since we keep values on disk and only retain hot values in memory, managed by the OS page cache. - -| N | versions | key size | value size | memory usage | -|------|----------|----------|------------|--------------| -| 100K | 1 | 64bytes | 256bytes | 40MB | -| 100K | 5 | 64bytes | 256bytes | 89MB | -| 1M | 1 | 64bytes | 256bytes | 470MB | -| 1M | 5 | 64bytes | 256bytes | 880MB | -| 100K | 1 | 64bytes | 1KB | 102MB | -| 100K | 5 | 64bytes | 1KB | 164MB | -| 1M | 1 | 64bytes | 1KB | 587MB | -| 1M | 5 | 64bytes | 1KB | 836MB | - -Based on the result, we know the value size does not significantly impact the memory consumption. There is some minor increase due to more data held in the OS page cache. - -[btree]: https://en.wikipedia.org/wiki/B-tree -[pagecache]: https://en.wikipedia.org/wiki/Page_cache - diff --git a/Documentation/v2/branch_management.md b/Documentation/v2/branch_management.md deleted file mode 100644 index 45b273542..000000000 --- a/Documentation/v2/branch_management.md +++ /dev/null @@ -1,31 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Branch Management - -## Guide - -* New development occurs on the [master branch][master]. -* Master branch should always have a green build! -* Backwards-compatible bug fixes should target the master branch and subsequently be ported to stable branches. -* Once the master branch is ready for release, it will be tagged and become the new stable branch. - -The etcd team has adopted a *rolling release model* and supports one stable version of etcd. - -### Master branch - -The `master` branch is our development branch. All new features land here first. - -If you want to try new features, pull `master` and play with it. Note that `master` may not be stable because new features may introduce bugs. - -Before the release of the next stable version, feature PRs will be frozen. We will focus on the testing, bug-fix and documentation for one to two weeks. - -### Stable branches - -All branches with prefix `release-` are considered _stable_ branches. - -After every minor release (http://semver.org/), we will have a new stable branch for that release. We will keep fixing the backwards-compatible bugs for the latest stable release, but not previous releases. The _patch_ release, incorporating any bug fixes, will be once every two weeks, given any patches. - -[master]: https://github.com/coreos/etcd/tree/master diff --git a/Documentation/v2/clustering.md b/Documentation/v2/clustering.md deleted file mode 100644 index f9c3e08f7..000000000 --- a/Documentation/v2/clustering.md +++ /dev/null @@ -1,440 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Clustering Guide - -## Overview - -Starting an etcd cluster statically requires that each member knows another in the cluster. In a number of cases, you might not know the IPs of your cluster members ahead of time. In these cases, you can bootstrap an etcd cluster with the help of a discovery service. - -Once an etcd cluster is up and running, adding or removing members is done via [runtime reconfiguration][runtime-conf]. To better understand the design behind runtime reconfiguration, we suggest you read [the runtime configuration design document][runtime-reconf-design]. - -This guide will cover the following mechanisms for bootstrapping an etcd cluster: - -* [Static](#static) -* [etcd Discovery](#etcd-discovery) -* [DNS Discovery](#dns-discovery) - -Each of the bootstrapping mechanisms will be used to create a three machine etcd cluster with the following details: - -|Name|Address|Hostname| -|------|---------|------------------| -|infra0|10.0.1.10|infra0.example.com| -|infra1|10.0.1.11|infra1.example.com| -|infra2|10.0.1.12|infra2.example.com| - -## Static - -As we know the cluster members, their addresses and the size of the cluster before starting, we can use an offline bootstrap configuration by setting the `initial-cluster` flag. Each machine will get either the following command line or environment variables: - -``` -ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380" -ETCD_INITIAL_CLUSTER_STATE=new -``` - -``` ---initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \ ---initial-cluster-state new -``` - -Note that the URLs specified in `initial-cluster` are the _advertised peer URLs_, i.e. they should match the value of `initial-advertise-peer-urls` on the respective nodes. - -If you are spinning up multiple clusters (or creating and destroying a single cluster) with same configuration for testing purpose, it is highly recommended that you specify a unique `initial-cluster-token` for the different clusters. By doing this, etcd can generate unique cluster IDs and member IDs for the clusters even if they otherwise have the exact same configuration. This can protect you from cross-cluster-interaction, which might corrupt your clusters. - -etcd listens on [`listen-client-urls`][conf-listen-client] to accept client traffic. etcd member advertises the URLs specified in [`advertise-client-urls`][conf-adv-client] to other members, proxies, clients. Please make sure the `advertise-client-urls` are reachable from intended clients. A common mistake is setting `advertise-client-urls` to localhost or leave it as default when you want the remote clients to reach etcd. - -On each machine you would start etcd with these flags: - -``` -$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \ - --listen-peer-urls http://10.0.1.10:2380 \ - --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.10:2379 \ - --initial-cluster-token etcd-cluster-1 \ - --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \ - --initial-cluster-state new -``` -``` -$ etcd --name infra1 --initial-advertise-peer-urls http://10.0.1.11:2380 \ - --listen-peer-urls http://10.0.1.11:2380 \ - --listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.11:2379 \ - --initial-cluster-token etcd-cluster-1 \ - --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \ - --initial-cluster-state new -``` -``` -$ etcd --name infra2 --initial-advertise-peer-urls http://10.0.1.12:2380 \ - --listen-peer-urls http://10.0.1.12:2380 \ - --listen-client-urls http://10.0.1.12:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.12:2379 \ - --initial-cluster-token etcd-cluster-1 \ - --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \ - --initial-cluster-state new -``` - -The command line parameters starting with `--initial-cluster` will be ignored on subsequent runs of etcd. You are free to remove the environment variables or command line flags after the initial bootstrap process. If you need to make changes to the configuration later (for example, adding or removing members to/from the cluster), see the [runtime configuration][runtime-conf] guide. - -### Error Cases - -In the following example, we have not included our new host in the list of enumerated nodes. If this is a new cluster, the node _must_ be added to the list of initial cluster members. - -``` -$ etcd --name infra1 --initial-advertise-peer-urls http://10.0.1.11:2380 \ - --listen-peer-urls https://10.0.1.11:2380 \ - --listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.11:2379 \ - --initial-cluster infra0=http://10.0.1.10:2380 \ - --initial-cluster-state new -etcd: infra1 not listed in the initial cluster config -exit 1 -``` - -In this example, we are attempting to map a node (infra0) on a different address (127.0.0.1:2380) than its enumerated address in the cluster list (10.0.1.10:2380). If this node is to listen on multiple addresses, all addresses _must_ be reflected in the "initial-cluster" configuration directive. - -``` -$ etcd --name infra0 --initial-advertise-peer-urls http://127.0.0.1:2380 \ - --listen-peer-urls http://10.0.1.10:2380 \ - --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.10:2379 \ - --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \ - --initial-cluster-state=new -etcd: error setting up initial cluster: infra0 has different advertised URLs in the cluster and advertised peer URLs list -exit 1 -``` - -If you configure a peer with a different set of configuration and attempt to join this cluster you will get a cluster ID mismatch and etcd will exit. - -``` -$ etcd --name infra3 --initial-advertise-peer-urls http://10.0.1.13:2380 \ - --listen-peer-urls http://10.0.1.13:2380 \ - --listen-client-urls http://10.0.1.13:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.13:2379 \ - --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra3=http://10.0.1.13:2380 \ - --initial-cluster-state=new -etcd: conflicting cluster ID to the target cluster (c6ab534d07e8fcc4 != bc25ea2a74fb18b0). Exiting. -exit 1 -``` - -## Discovery - -In a number of cases, you might not know the IPs of your cluster peers ahead of time. This is common when utilizing cloud providers or when your network uses DHCP. In these cases, rather than specifying a static configuration, you can use an existing etcd cluster to bootstrap a new one. We call this process "discovery". - -There two methods that can be used for discovery: - -* etcd discovery service -* DNS SRV records - -### etcd Discovery - -To better understand the design about discovery service protocol, we suggest you read [this][discovery-proto]. - -#### Lifetime of a Discovery URL - -A discovery URL identifies a unique etcd cluster. Instead of reusing a discovery URL, you should always create discovery URLs for new clusters. - -Moreover, discovery URLs should ONLY be used for the initial bootstrapping of a cluster. To change cluster membership after the cluster is already running, see the [runtime reconfiguration][runtime-conf] guide. - -#### Custom etcd Discovery Service - -Discovery uses an existing cluster to bootstrap itself. If you are using your own etcd cluster you can create a URL like so: - -``` -$ curl -X PUT https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83/_config/size -d value=3 -``` - -By setting the size key to the URL, you create a discovery URL with an expected cluster size of 3. - -If you bootstrap an etcd cluster using discovery service with more than the expected number of etcd members, the extra etcd processes will [fall back][fall-back] to being [proxies][proxy] by default. - -The URL you will use in this case will be `https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83` and the etcd members will use the `https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83` directory for registration as they start. - -**Each member must have a different name flag specified. `Hostname` or `machine-id` can be a good choice. Or discovery will fail due to duplicated name.** - -Now we start etcd with those relevant flags for each member: - -``` -$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \ - --listen-peer-urls http://10.0.1.10:2380 \ - --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.10:2379 \ - --discovery https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83 -``` -``` -$ etcd --name infra1 --initial-advertise-peer-urls http://10.0.1.11:2380 \ - --listen-peer-urls http://10.0.1.11:2380 \ - --listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.11:2379 \ - --discovery https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83 -``` -``` -$ etcd --name infra2 --initial-advertise-peer-urls http://10.0.1.12:2380 \ - --listen-peer-urls http://10.0.1.12:2380 \ - --listen-client-urls http://10.0.1.12:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.12:2379 \ - --discovery https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83 -``` - -This will cause each member to register itself with the custom etcd discovery service and begin the cluster once all machines have been registered. - -#### Public etcd Discovery Service - -If you do not have access to an existing cluster, you can use the public discovery service hosted at `discovery.etcd.io`. You can create a private discovery URL using the "new" endpoint like so: - -``` -$ curl https://discovery.etcd.io/new?size=3 -https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de -``` - -This will create the cluster with an initial expected size of 3 members. If you do not specify a size, a default of 3 will be used. - -If you bootstrap an etcd cluster using discovery service with more than the expected number of etcd members, the extra etcd processes will [fall back][fall-back] to being [proxies][proxy] by default. - -``` -ETCD_DISCOVERY=https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de -``` - -``` --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de -``` - -**Each member must have a different name flag specified. `Hostname` or `machine-id` can be a good choice. Or discovery will fail due to duplicated name.** - -Now we start etcd with those relevant flags for each member: - -``` -$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \ - --listen-peer-urls http://10.0.1.10:2380 \ - --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.10:2379 \ - --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de -``` -``` -$ etcd --name infra1 --initial-advertise-peer-urls http://10.0.1.11:2380 \ - --listen-peer-urls http://10.0.1.11:2380 \ - --listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.11:2379 \ - --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de -``` -``` -$ etcd --name infra2 --initial-advertise-peer-urls http://10.0.1.12:2380 \ - --listen-peer-urls http://10.0.1.12:2380 \ - --listen-client-urls http://10.0.1.12:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.12:2379 \ - --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de -``` - -This will cause each member to register itself with the discovery service and begin the cluster once all members have been registered. - -You can use the environment variable `ETCD_DISCOVERY_PROXY` to cause etcd to use an HTTP proxy to connect to the discovery service. - -#### Error and Warning Cases - -##### Discovery Server Errors - - -``` -$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \ - --listen-peer-urls http://10.0.1.10:2380 \ - --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.10:2379 \ - --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de -etcd: error: the cluster doesn’t have a size configuration value in https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de/_config -exit 1 -``` - -##### User Errors - -This error will occur if the discovery cluster already has the configured number of members, and `discovery-fallback` is explicitly disabled - -``` -$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \ - --listen-peer-urls http://10.0.1.10:2380 \ - --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.10:2379 \ - --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de \ - --discovery-fallback exit -etcd: discovery: cluster is full -exit 1 -``` - -##### Warnings - -This is a harmless warning notifying you that the discovery URL will be -ignored on this machine. - -``` -$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \ - --listen-peer-urls http://10.0.1.10:2380 \ - --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \ - --advertise-client-urls http://10.0.1.10:2379 \ - --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de -etcdserver: discovery token ignored since a cluster has already been initialized. Valid log found at /var/lib/etcd -``` - -### DNS Discovery - -DNS [SRV records][rfc-srv] can be used as a discovery mechanism. -The `-discovery-srv` flag can be used to set the DNS domain name where the discovery SRV records can be found. -The following DNS SRV records are looked up in the listed order: - -* _etcd-server-ssl._tcp.example.com -* _etcd-server._tcp.example.com - -If `_etcd-server-ssl._tcp.example.com` is found then etcd will attempt the bootstrapping process over SSL. - -To help clients discover the etcd cluster, the following DNS SRV records are looked up in the listed order: - -* _etcd-client._tcp.example.com -* _etcd-client-ssl._tcp.example.com - -If `_etcd-client-ssl._tcp.example.com` is found, clients will attempt to communicate with the etcd cluster over SSL. - -#### Create DNS SRV records - -``` -$ dig +noall +answer SRV _etcd-server._tcp.example.com -_etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra0.example.com. -_etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra1.example.com. -_etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra2.example.com. -``` - -``` -$ dig +noall +answer SRV _etcd-client._tcp.example.com -_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra0.example.com. -_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra1.example.com. -_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra2.example.com. -``` - -``` -$ dig +noall +answer infra0.example.com infra1.example.com infra2.example.com -infra0.example.com. 300 IN A 10.0.1.10 -infra1.example.com. 300 IN A 10.0.1.11 -infra2.example.com. 300 IN A 10.0.1.12 -``` - -#### Bootstrap the etcd cluster using DNS - -etcd cluster members can listen on domain names or IP address, the bootstrap process will resolve DNS A records. - -The resolved address in `--initial-advertise-peer-urls` *must match* one of the resolved addresses in the SRV targets. The etcd member reads the resolved address to find out if it belongs to the cluster defined in the SRV records. - -``` -$ etcd --name infra0 \ ---discovery-srv example.com \ ---initial-advertise-peer-urls http://infra0.example.com:2380 \ ---initial-cluster-token etcd-cluster-1 \ ---initial-cluster-state new \ ---advertise-client-urls http://infra0.example.com:2379 \ ---listen-client-urls http://infra0.example.com:2379 \ ---listen-peer-urls http://infra0.example.com:2380 -``` - -``` -$ etcd --name infra1 \ ---discovery-srv example.com \ ---initial-advertise-peer-urls http://infra1.example.com:2380 \ ---initial-cluster-token etcd-cluster-1 \ ---initial-cluster-state new \ ---advertise-client-urls http://infra1.example.com:2379 \ ---listen-client-urls http://infra1.example.com:2379 \ ---listen-peer-urls http://infra1.example.com:2380 -``` - -``` -$ etcd --name infra2 \ ---discovery-srv example.com \ ---initial-advertise-peer-urls http://infra2.example.com:2380 \ ---initial-cluster-token etcd-cluster-1 \ ---initial-cluster-state new \ ---advertise-client-urls http://infra2.example.com:2379 \ ---listen-client-urls http://infra2.example.com:2379 \ ---listen-peer-urls http://infra2.example.com:2380 -``` - -You can also bootstrap the cluster using IP addresses instead of domain names: - -``` -$ etcd --name infra0 \ ---discovery-srv example.com \ ---initial-advertise-peer-urls http://10.0.1.10:2380 \ ---initial-cluster-token etcd-cluster-1 \ ---initial-cluster-state new \ ---advertise-client-urls http://10.0.1.10:2379 \ ---listen-client-urls http://10.0.1.10:2379 \ ---listen-peer-urls http://10.0.1.10:2380 -``` - -``` -$ etcd --name infra1 \ ---discovery-srv example.com \ ---initial-advertise-peer-urls http://10.0.1.11:2380 \ ---initial-cluster-token etcd-cluster-1 \ ---initial-cluster-state new \ ---advertise-client-urls http://10.0.1.11:2379 \ ---listen-client-urls http://10.0.1.11:2379 \ ---listen-peer-urls http://10.0.1.11:2380 -``` - -``` -$ etcd --name infra2 \ ---discovery-srv example.com \ ---initial-advertise-peer-urls http://10.0.1.12:2380 \ ---initial-cluster-token etcd-cluster-1 \ ---initial-cluster-state new \ ---advertise-client-urls http://10.0.1.12:2379 \ ---listen-client-urls http://10.0.1.12:2379 \ ---listen-peer-urls http://10.0.1.12:2380 -``` - -#### etcd proxy configuration - -DNS SRV records can also be used to configure the list of peers for an etcd server running in proxy mode: - -``` -$ etcd --proxy on --discovery-srv example.com -``` - -#### etcd client configuration - -DNS SRV records can also be used to help clients discover the etcd cluster. - -The official [etcd/client][client] supports [DNS Discovery][client-discoverer]. - -`etcdctl` also supports DNS Discovery by specifying the `--discovery-srv` option. - -``` -$ etcdctl --discovery-srv example.com set foo bar -``` - -#### Error Cases - -You might see an error like `cannot find local etcd $name from SRV records.`. That means the etcd member fails to find itself from the cluster defined in SRV records. The resolved address in `--initial-advertise-peer-urls` *must match* one of the resolved addresses in the SRV targets. - -# 0.4 to 2.0+ Migration Guide - -In etcd 2.0 we introduced the ability to listen on more than one address and to advertise multiple addresses. This makes using etcd easier when you have complex networking, such as private and public networks on various cloud providers. - -To make understanding this feature easier, we changed the naming of some flags, but we support the old flags to make the migration from the old to new version easier. - -|Old Flag |New Flag |Migration Behavior | -|-----------------------|-----------------------|---------------------------------------------------------------------------------------| -|-peer-addr |--initial-advertise-peer-urls |If specified, peer-addr will be used as the only peer URL. Error if both flags specified.| -|-addr |--advertise-client-urls |If specified, addr will be used as the only client URL. Error if both flags specified.| -|-peer-bind-addr |--listen-peer-urls |If specified, peer-bind-addr will be used as the only peer bind URL. Error if both flags specified.| -|-bind-addr |--listen-client-urls |If specified, bind-addr will be used as the only client bind URL. Error if both flags specified.| -|-peers |none |Deprecated. The --initial-cluster flag provides a similar concept with different semantics. Please read this guide on cluster startup.| -|-peers-file |none |Deprecated. The --initial-cluster flag provides a similar concept with different semantics. Please read this guide on cluster startup.| - -[client]: ../../client -[client-discoverer]: https://godoc.org/github.com/coreos/etcd/client#Discoverer -[conf-adv-client]: configuration.md#-advertise-client-urls -[conf-listen-client]: configuration.md#-listen-client-urls -[discovery-proto]: discovery_protocol.md -[fall-back]: proxy.md#fallback-to-proxy-mode-with-discovery-service -[proxy]: proxy.md -[rfc-srv]: http://www.ietf.org/rfc/rfc2052.txt -[runtime-conf]: runtime-configuration.md -[runtime-reconf-design]: runtime-reconf-design.md diff --git a/Documentation/v2/configuration.md b/Documentation/v2/configuration.md deleted file mode 100644 index 655fced2b..000000000 --- a/Documentation/v2/configuration.md +++ /dev/null @@ -1,293 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Configuration Flags - -etcd is configurable through command-line flags and environment variables. Options set on the command line take precedence over those from the environment. - -The format of environment variable for flag `--my-flag` is `ETCD_MY_FLAG`. It applies to all flags. - -The [official etcd ports][iana-ports] are 2379 for client requests, and 2380 for peer communication. Some legacy code and documentation still references ports 4001 and 7001, but all new etcd use and discussion should adopt the assigned ports. - -To start etcd automatically using custom settings at startup in Linux, using a [systemd][systemd-intro] unit is highly recommended. - -[systemd-intro]: http://freedesktop.org/wiki/Software/systemd/ - -## Member Flags - -### --name -+ Human-readable name for this member. -+ default: "default" -+ env variable: ETCD_NAME -+ This value is referenced as this node's own entries listed in the `--initial-cluster` flag (Ex: `default=http://localhost:2380` or `default=http://localhost:2380,default=http://localhost:7001`). This needs to match the key used in the flag if you're using [static bootstrapping][build-cluster]. When using discovery, each member must have a unique name. `Hostname` or `machine-id` can be a good choice. - -### --data-dir -+ Path to the data directory. -+ default: "${name}.etcd" -+ env variable: ETCD_DATA_DIR - -### --wal-dir -+ Path to the dedicated wal directory. If this flag is set, etcd will write the WAL files to the walDir rather than the dataDir. This allows a dedicated disk to be used, and helps avoid io competition between logging and other IO operations. -+ default: "" -+ env variable: ETCD_WAL_DIR - -### --snapshot-count -+ Number of committed transactions to trigger a snapshot to disk. -+ default: "10000" -+ env variable: ETCD_SNAPSHOT_COUNT - -### --heartbeat-interval -+ Time (in milliseconds) of a heartbeat interval. -+ default: "100" -+ env variable: ETCD_HEARTBEAT_INTERVAL - -### --election-timeout -+ Time (in milliseconds) for an election to timeout. See [tuning.md](tuning.md#time-parameters) for details. -+ default: "1000" -+ env variable: ETCD_ELECTION_TIMEOUT - -### --listen-peer-urls -+ List of URLs to listen on for peer traffic. This flag tells the etcd to accept incoming requests from its peers on the specified scheme://IP:port combinations. Scheme can be either http or https.If 0.0.0.0 is specified as the IP, etcd listens to the given port on all interfaces. If an IP address is given as well as a port, etcd will listen on the given port and interface. Multiple URLs may be used to specify a number of addresses and ports to listen on. The etcd will respond to requests from any of the listed addresses and ports. -+ default: "http://localhost:2380,http://localhost:7001" -+ env variable: ETCD_LISTEN_PEER_URLS -+ example: "http://10.0.0.1:2380" -+ invalid example: "http://example.com:2380" (domain name is invalid for binding) - -### --listen-client-urls -+ List of URLs to listen on for client traffic. This flag tells the etcd to accept incoming requests from the clients on the specified scheme://IP:port combinations. Scheme can be either http or https. If 0.0.0.0 is specified as the IP, etcd listens to the given port on all interfaces. If an IP address is given as well as a port, etcd will listen on the given port and interface. Multiple URLs may be used to specify a number of addresses and ports to listen on. The etcd will respond to requests from any of the listed addresses and ports. -+ default: "http://localhost:2379,http://localhost:4001" -+ env variable: ETCD_LISTEN_CLIENT_URLS -+ example: "http://10.0.0.1:2379" -+ invalid example: "http://example.com:2379" (domain name is invalid for binding) - -### --max-snapshots -+ Maximum number of snapshot files to retain (0 is unlimited) -+ default: 5 -+ env variable: ETCD_MAX_SNAPSHOTS -+ The default for users on Windows is unlimited, and manual purging down to 5 (or your preference for safety) is recommended. - -### --max-wals -+ Maximum number of wal files to retain (0 is unlimited) -+ default: 5 -+ env variable: ETCD_MAX_WALS -+ The default for users on Windows is unlimited, and manual purging down to 5 (or your preference for safety) is recommended. - -### --cors -+ Comma-separated white list of origins for CORS (cross-origin resource sharing). -+ default: none -+ env variable: ETCD_CORS - -## Clustering Flags - -`--initial` prefix flags are used in bootstrapping ([static bootstrap][build-cluster], [discovery-service bootstrap][discovery] or [runtime reconfiguration][reconfig]) a new member, and ignored when restarting an existing member. - -`--discovery` prefix flags need to be set when using [discovery service][discovery]. - -### --initial-advertise-peer-urls - -+ List of this member's peer URLs to advertise to the rest of the cluster. These addresses are used for communicating etcd data around the cluster. At least one must be routable to all cluster members. These URLs can contain domain names. -+ default: "http://localhost:2380,http://localhost:7001" -+ env variable: ETCD_INITIAL_ADVERTISE_PEER_URLS -+ example: "http://example.com:2380, http://10.0.0.1:2380" - -### --initial-cluster -+ Initial cluster configuration for bootstrapping. -+ default: "default=http://localhost:2380,default=http://localhost:7001" -+ env variable: ETCD_INITIAL_CLUSTER -+ The key is the value of the `--name` flag for each node provided. The default uses `default` for the key because this is the default for the `--name` flag. - -### --initial-cluster-state -+ Initial cluster state ("new" or "existing"). Set to `new` for all members present during initial static or DNS bootstrapping. If this option is set to `existing`, etcd will attempt to join the existing cluster. If the wrong value is set, etcd will attempt to start but fail safely. -+ default: "new" -+ env variable: ETCD_INITIAL_CLUSTER_STATE - -[static bootstrap]: clustering.md#static - -### --initial-cluster-token -+ Initial cluster token for the etcd cluster during bootstrap. -+ default: "etcd-cluster" -+ env variable: ETCD_INITIAL_CLUSTER_TOKEN - -### --advertise-client-urls -+ List of this member's client URLs to advertise to the rest of the cluster. These URLs can contain domain names. -+ default: "http://localhost:2379,http://localhost:4001" -+ env variable: ETCD_ADVERTISE_CLIENT_URLS -+ example: "http://example.com:2379, http://10.0.0.1:2379" -+ Be careful if you are advertising URLs such as http://localhost:2379 from a cluster member and are using the proxy feature of etcd. This will cause loops, because the proxy will be forwarding requests to itself until its resources (memory, file descriptors) are eventually depleted. - -### --discovery -+ Discovery URL used to bootstrap the cluster. -+ default: none -+ env variable: ETCD_DISCOVERY - -### --discovery-srv -+ DNS srv domain used to bootstrap the cluster. -+ default: none -+ env variable: ETCD_DISCOVERY_SRV - -### --discovery-fallback -+ Expected behavior ("exit" or "proxy") when discovery services fails. -+ default: "proxy" -+ env variable: ETCD_DISCOVERY_FALLBACK - -### --discovery-proxy -+ HTTP proxy to use for traffic to discovery service. -+ default: none -+ env variable: ETCD_DISCOVERY_PROXY - -### --strict-reconfig-check -+ Reject reconfiguration requests that would cause quorum loss. -+ default: false -+ env variable: ETCD_STRICT_RECONFIG_CHECK - -## Proxy Flags - -`--proxy` prefix flags configures etcd to run in [proxy mode][proxy]. - -### --proxy -+ Proxy mode setting ("off", "readonly" or "on"). -+ default: "off" -+ env variable: ETCD_PROXY - -### --proxy-failure-wait -+ Time (in milliseconds) an endpoint will be held in a failed state before being reconsidered for proxied requests. -+ default: 5000 -+ env variable: ETCD_PROXY_FAILURE_WAIT - -### --proxy-refresh-interval -+ Time (in milliseconds) of the endpoints refresh interval. -+ default: 30000 -+ env variable: ETCD_PROXY_REFRESH_INTERVAL - -### --proxy-dial-timeout -+ Time (in milliseconds) for a dial to timeout or 0 to disable the timeout -+ default: 1000 -+ env variable: ETCD_PROXY_DIAL_TIMEOUT - -### --proxy-write-timeout -+ Time (in milliseconds) for a write to timeout or 0 to disable the timeout. -+ default: 5000 -+ env variable: ETCD_PROXY_WRITE_TIMEOUT - -### --proxy-read-timeout -+ Time (in milliseconds) for a read to timeout or 0 to disable the timeout. -+ Don't change this value if you use watches because they are using long polling requests. -+ default: 0 -+ env variable: ETCD_PROXY_READ_TIMEOUT - -## Security Flags - -The security flags help to [build a secure etcd cluster][security]. - -### --ca-file - -**DEPRECATED** - -+ Path to the client server TLS CA file. `--ca-file ca.crt` could be replaced by `--trusted-ca-file ca.crt --client-cert-auth` and etcd will perform the same. -+ default: none -+ env variable: ETCD_CA_FILE - -### --cert-file -+ Path to the client server TLS cert file. -+ default: none -+ env variable: ETCD_CERT_FILE - -### --key-file -+ Path to the client server TLS key file. -+ default: none -+ env variable: ETCD_KEY_FILE - -### --client-cert-auth -+ Enable client cert authentication. -+ default: false -+ env variable: ETCD_CLIENT_CERT_AUTH - -### --trusted-ca-file -+ Path to the client server TLS trusted CA cert file. -+ default: none -+ env variable: ETCD_TRUSTED_CA_FILE - -### --peer-ca-file - -**DEPRECATED** - -+ Path to the peer server TLS CA file. `--peer-ca-file ca.crt` could be replaced by `--peer-trusted-ca-file ca.crt --peer-client-cert-auth` and etcd will perform the same. -+ default: none -+ env variable: ETCD_PEER_CA_FILE - -### --peer-cert-file -+ Path to the peer server TLS cert file. -+ default: none -+ env variable: ETCD_PEER_CERT_FILE - -### --peer-key-file -+ Path to the peer server TLS key file. -+ default: none -+ env variable: ETCD_PEER_KEY_FILE - -### --peer-client-cert-auth -+ Enable peer client cert authentication. -+ default: false -+ env variable: ETCD_PEER_CLIENT_CERT_AUTH - -### --peer-trusted-ca-file -+ Path to the peer server TLS trusted CA file. -+ default: none -+ env variable: ETCD_PEER_TRUSTED_CA_FILE - -## Logging Flags - -### --debug -+ Drop the default log level to DEBUG for all subpackages. -+ default: false (INFO for all packages) -+ env variable: ETCD_DEBUG - -### --log-package-levels -+ Set individual etcd subpackages to specific log levels. An example being `etcdserver=WARNING,security=DEBUG` -+ default: none (INFO for all packages) -+ env variable: ETCD_LOG_PACKAGE_LEVELS - - -## Unsafe Flags - -Please be CAUTIOUS when using unsafe flags because it will break the guarantees given by the consensus protocol. -For example, it may panic if other members in the cluster are still alive. -Follow the instructions when using these flags. - -### --force-new-cluster -+ Force to create a new one-member cluster. It commits configuration changes forcing to remove all existing members in the cluster and add itself. It needs to be set to [restore a backup][restore]. -+ default: false -+ env variable: ETCD_FORCE_NEW_CLUSTER - -## Experimental Flags - -### --experimental-v3demo -+ Enable experimental [v3 demo API][rfc-v3]. -+ default: false -+ env variable: ETCD_EXPERIMENTAL_V3DEMO - -## Miscellaneous Flags - -### --version -+ Print the version and exit. -+ default: false - -## Profiling flags - -### --enable-pprof -+ Enable runtime profiling data via HTTP server. Address is at client URL + "/debug/pprof/" -+ default: false - -[build-cluster]: clustering.md#static -[reconfig]: runtime-configuration.md -[discovery]: clustering.md#discovery -[iana-ports]: http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt -[proxy]: proxy.md -[reconfig]: runtime-configuration.md -[restore]: admin_guide.md#restoring-a-backup -[rfc-v3]: rfc/v3api.md -[security]: security.md -[systemd-intro]: http://freedesktop.org/wiki/Software/systemd/ -[tuning]: tuning.md#time-parameters diff --git a/Documentation/v2/dev/release.md b/Documentation/v2/dev/release.md deleted file mode 100644 index bbf061da7..000000000 --- a/Documentation/v2/dev/release.md +++ /dev/null @@ -1,115 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../../docs.md#documentation - - -# etcd release guide - -The guide talks about how to release a new version of etcd. - -The procedure includes some manual steps for sanity checking but it can probably be further scripted. Please keep this document up-to-date if you want to make changes to the release process. - -## Prepare Release - -Set desired version as environment variable for following steps. Here is an example to release 2.1.3: - -``` -export VERSION=v2.1.3 -export PREV_VERSION=v2.1.2 -``` - -All releases version numbers follow the format of [semantic versioning 2.0.0](http://semver.org/). - -### Major, Minor Version Release, or its Pre-release - -- Ensure the relevant milestone on GitHub is complete. All referenced issues should be closed, or moved elsewhere. -- Remove this release from [roadmap](https://github.com/coreos/etcd/blob/master/ROADMAP.md), if necessary. -- Ensure the latest upgrade documentation is available. -- Bump [hardcoded MinClusterVerion in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L29), if necessary. -- Add feature capability maps for the new version, if necessary. - -### Patch Version Release - -- Discuss about commits that are backported to the patch release. The commits should not include merge commits. -- Cherry-pick these commits starting from the oldest one into stable branch. - -## Write Release Note - - -- Write introduction for the new release. For example, what major bug we fix, what new features we introduce or what performance improvement we make. -- Write changelog for the last release. ChangeLog should be straightforward and easy to understand for the end-user. -- Put `[GH XXXX]` at the head of change line to reference Pull Request that introduces the change. Moreover, add a link on it to jump to the Pull Request. - -## Tag Version - -- Bump [hardcoded Version in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L30) to the latest version `${VERSION}`. -- Ensure all tests on CI system are passed. -- Manually check etcd is buildable in Linux, Darwin and Windows. -- Manually check upgrade etcd cluster of previous minor version works well. -- Manually check new features work well. -- Add a signed tag through `git tag -s ${VERSION}`. -- Sanity check tag correctness through `git show tags/$VERSION`. -- Push the tag to GitHub through `git push origin tags/$VERSION`. This assumes `origin` corresponds to "https://github.com/coreos/etcd". - -## Build Release Binaries and Images - -- Ensure `acbuild` is available. -- Ensure `docker` is available. - -Run release script in root directory: - -``` -./scripts/release.sh ${VERSION} -``` - -It generates all release binaries and images under directory ./release. - -## Sign Binaries and Images - -Choose appropriate private key to sign the generated binaries and images. - -The following commands are used for public release sign: - -``` -cd release -# personal GPG is okay for now -for i in etcd-*{.zip,.tar.gz}; do gpg --sign ${i}; done -# use `CoreOS ACI Builder ` secret key -for aci in etcd-${VERSION}.*.aci; do gpg -u 88182190 -a --output ${aci}.asc --detach-sig ${aci}; done -``` - -## Publish Release Page in GitHub - -- Set release title as the version name. -- Follow the format of previous release pages. -- Attach the generated binaries, aci image and signatures. -- Select whether it is a pre-release. -- Publish the release! - -## Publish Docker Image in Quay.io - -- Push docker image: - -``` -docker login quay.io -docker push quay.io/coreos/etcd:${VERSION} -docker push quay.io/coreos/etcd:${VERSION}-${arch} -``` - -- Add `latest` tag to the new image on [quay.io](https://quay.io/repository/coreos/etcd?tag=latest&tab=tags) if this is a stable release. - -## Announce to etcd-dev Googlegroup - -- Follow the format of [previous release emails](https://groups.google.com/forum/#!forum/etcd-dev). -- Make sure to include a list of authors that contributed since the previous release - something like the following might be handy: - -``` -git log ...${PREV_VERSION} --pretty=format:"%an" | sort | uniq | tr '\n' ',' | sed -e 's#,#, #g' -e 's#, $##' -``` - -- Send email to etcd-dev@googlegroups.com - -## Post Release - -- Create new stable branch through `git push origin ${VERSION_MAJOR}.${VERSION_MINOR}` if this is a major stable release. This assumes `origin` corresponds to "https://github.com/coreos/etcd". -- Bump [hardcoded Version in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L30) to the version `${VERSION}+git`. diff --git a/Documentation/v2/discovery_protocol.md b/Documentation/v2/discovery_protocol.md deleted file mode 100644 index b9479ac39..000000000 --- a/Documentation/v2/discovery_protocol.md +++ /dev/null @@ -1,119 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Discovery Service Protocol - -Discovery service protocol helps new etcd member to discover all other members in cluster bootstrap phase using a shared discovery URL. - -Discovery service protocol is _only_ used in cluster bootstrap phase, and cannot be used for runtime reconfiguration or cluster monitoring. - -The protocol uses a new discovery token to bootstrap one _unique_ etcd cluster. Remember that one discovery token can represent only one etcd cluster. As long as discovery protocol on this token starts, even if it fails halfway, it must not be used to bootstrap another etcd cluster. - -The rest of this article will walk through the discovery process with examples that correspond to a self-hosted discovery cluster. The public discovery service, discovery.etcd.io, functions the same way, but with a layer of polish to abstract away ugly URLs, generate UUIDs automatically, and provide some protections against excessive requests. At its core, the public discovery service still uses an etcd cluster as the data store as described in this document. - -## The Protocol Workflow - -The idea of discovery protocol is to use an internal etcd cluster to coordinate bootstrap of a new cluster. First, all new members interact with discovery service and help to generate the expected member list. Then each new member bootstraps its server using this list, which performs the same functionality as -initial-cluster flag. - -In the following example workflow, we will list each step of protocol in curl format for ease of understanding. - -By convention the etcd discovery protocol uses the key prefix `_etcd/registry`. If `http://example.com` hosts an etcd cluster for discovery service, a full URL to discovery keyspace will be `http://example.com/v2/keys/_etcd/registry`. We will use this as the URL prefix in the example. - -### Creating a New Discovery Token - -Generate a unique token that will identify the new cluster. This will be used as a unique prefix in discovery keyspace in the following steps. An easy way to do this is to use `uuidgen`: - -``` -UUID=$(uuidgen) -``` - -### Specifying the Expected Cluster Size - -You need to specify the expected cluster size for this discovery token. The size is used by the discovery service to know when it has found all members that will initially form the cluster. - -``` -curl -X PUT http://example.com/v2/keys/_etcd/registry/${UUID}/_config/size -d value=${cluster_size} -``` - -Usually the cluster size is 3, 5 or 7. Check [optimal cluster size][cluster-size] for more details. - -### Bringing up etcd Processes - -Now that you have your discovery URL, you can use it as `-discovery` flag and bring up etcd processes. Every etcd process will follow this next few steps internally if given a `-discovery` flag. - -### Registering itself - -The first thing for etcd process is to register itself into the discovery URL as a member. This is done by creating member ID as a key in the discovery URL. - -``` -curl -X PUT http://example.com/v2/keys/_etcd/registry/${UUID}/${member_id}?prevExist=false -d value="${member_name}=${member_peer_url_1}&${member_name}=${member_peer_url_2}" -``` - -### Checking the Status - -It checks the expected cluster size and registration status in discovery URL, and decides what the next action is. - -``` -curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID}/_config/size -curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID} -``` - -If registered members are still not enough, it will wait for left members to appear. - -If the number of registered members is bigger than the expected size N, it treats the first N registered members as the member list for the cluster. If the member itself is in the member list, the discovery procedure succeeds and it fetches all peers through the member list. If it is not in the member list, the discovery procedure finishes with the failure that the cluster has been full. - -In etcd implementation, the member may check the cluster status even before registering itself. So it could fail quickly if the cluster has been full. - -### Waiting for All Members - - -The wait process is described in detail in the [etcd API documentation][api]. - -``` -curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID}?wait=true&waitIndex=${current_etcd_index} -``` - -It keeps waiting until finding all members. - -## Public Discovery Service - -CoreOS Inc. hosts a public discovery service at https://discovery.etcd.io/ , which provides some nice features for ease of use. - -### Mask Key Prefix - -Public discovery service will redirect `https://discovery.etcd.io/${UUID}` to etcd cluster behind for the key at `/v2/keys/_etcd/registry`. It masks register key prefix for short and readable discovery url. - -### Get new token - -``` -GET /new - -Sent query: - size=${cluster_size} -Possible status codes: - 200 OK - 400 Bad Request -200 Body: - generated discovery url -``` - -The generation process in the service follows the steps from [Creating a New Discovery Token][new-discovery-token] to [Specifying the Expected Cluster Size][expected-cluster-size]. - -### Check Discovery Status - -``` -GET /${UUID} -``` - -You can check the status for this discovery token, including the machines that have been registered, by requesting the value of the UUID. - -### Open-source repository - -The repository is located at https://github.com/coreos/discovery.etcd.io. You could use it to build your own public discovery service. - -[api]: api.md#waiting-for-a-change -[cluster-size]: admin_guide.md#optimal-cluster-size -[expected-cluster-size]: #specifying-the-expected-cluster-size -[new-discovery-token]: #creating-a-new-discovery-token diff --git a/Documentation/v2/docker_guide.md b/Documentation/v2/docker_guide.md deleted file mode 100644 index 74dd90688..000000000 --- a/Documentation/v2/docker_guide.md +++ /dev/null @@ -1,101 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Running etcd under Docker - -The following guide will show you how to run etcd under Docker using the [static bootstrap process](clustering.md#static). - -## Running etcd in standalone mode - -In order to expose the etcd API to clients outside of the Docker host you'll need use the host IP address when configuring etcd. - -``` -export HostIP="192.168.12.50" -``` - -The following `docker run` command will expose the etcd client API over ports 4001 and 2379, and expose the peer port over 2380. - -This will run the latest release version of etcd. You can specify version if needed (e.g. `quay.io/coreos/etcd:v2.2.0`). - -``` -docker run -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \ - --name etcd quay.io/coreos/etcd:v2.3.8 \ - -name etcd0 \ - -advertise-client-urls http://${HostIP}:2379,http://${HostIP}:4001 \ - -listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \ - -initial-advertise-peer-urls http://${HostIP}:2380 \ - -listen-peer-urls http://0.0.0.0:2380 \ - -initial-cluster-token etcd-cluster-1 \ - -initial-cluster etcd0=http://${HostIP}:2380 \ - -initial-cluster-state new -``` - -Configure etcd clients to use the Docker host IP and one of the listening ports from above. - -``` -etcdctl -C http://192.168.12.50:2379 member list -``` - -``` -etcdctl -C http://192.168.12.50:4001 member list -``` - -## Running a 3 node etcd cluster - -Using Docker to setup a multi-node cluster is very similar to the standalone mode configuration. -The main difference being the value used for the `-initial-cluster` flag, which must contain the peer urls for each etcd member in the cluster. - -**Although the following commands look very similar, note that `-name`, `-advertise-client-urls` and `-initial-advertise-peer-urls` differ for each cluster member** - -### etcd0 - -``` -docker run -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \ - --name etcd quay.io/coreos/etcd:v2.3.8 \ - -name etcd0 \ - -advertise-client-urls http://192.168.12.50:2379,http://192.168.12.50:4001 \ - -listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \ - -initial-advertise-peer-urls http://192.168.12.50:2380 \ - -listen-peer-urls http://0.0.0.0:2380 \ - -initial-cluster-token etcd-cluster-1 \ - -initial-cluster etcd0=http://192.168.12.50:2380,etcd1=http://192.168.12.51:2380,etcd2=http://192.168.12.52:2380 \ - -initial-cluster-state new -``` - -### etcd1 - -``` -docker run -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \ - --name etcd quay.io/coreos/etcd:v2.3.8 \ - -name etcd1 \ - -advertise-client-urls http://192.168.12.51:2379,http://192.168.12.51:4001 \ - -listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \ - -initial-advertise-peer-urls http://192.168.12.51:2380 \ - -listen-peer-urls http://0.0.0.0:2380 \ - -initial-cluster-token etcd-cluster-1 \ - -initial-cluster etcd0=http://192.168.12.50:2380,etcd1=http://192.168.12.51:2380,etcd2=http://192.168.12.52:2380 \ - -initial-cluster-state new -``` - -### etcd2 - -``` -docker run -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \ - --name etcd quay.io/coreos/etcd:v2.3.8 \ - -name etcd2 \ - -advertise-client-urls http://192.168.12.52:2379,http://192.168.12.52:4001 \ - -listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \ - -initial-advertise-peer-urls http://192.168.12.52:2380 \ - -listen-peer-urls http://0.0.0.0:2380 \ - -initial-cluster-token etcd-cluster-1 \ - -initial-cluster etcd0=http://192.168.12.50:2380,etcd1=http://192.168.12.51:2380,etcd2=http://192.168.12.52:2380 \ - -initial-cluster-state new -``` - -Once the cluster has been bootstrapped etcd clients can be configured with a list of etcd members: - -``` -etcdctl -C http://192.168.12.50:2379,http://192.168.12.51:2379,http://192.168.12.52:2379 member list -``` diff --git a/Documentation/v2/errorcode.md b/Documentation/v2/errorcode.md deleted file mode 100644 index 4caf22a5b..000000000 --- a/Documentation/v2/errorcode.md +++ /dev/null @@ -1,47 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Error Code -====== - -This document describes the error code used in key space '/v2/keys'. Feel free to import 'github.com/coreos/etcd/error' to use. - -It's categorized into four groups: - -- Command Related Error - -| name | code | strerror | -|----------------------|------|-----------------------| -| EcodeKeyNotFound | 100 | "Key not found" | -| EcodeTestFailed | 101 | "Compare failed" | -| EcodeNotFile | 102 | "Not a file" | -| EcodeNotDir | 104 | "Not a directory" | -| EcodeNodeExist | 105 | "Key already exists" | -| EcodeRootROnly | 107 | "Root is read only" | -| EcodeDirNotEmpty | 108 | "Directory not empty" | - -- Post Form Related Error - -| name | code | strerror | -|--------------------------|------|------------------------------------------------| -| EcodePrevValueRequired | 201 | "PrevValue is Required in POST form" | -| EcodeTTLNaN | 202 | "The given TTL in POST form is not a number" | -| EcodeIndexNaN | 203 | "The given index in POST form is not a number" | -| EcodeInvalidField | 209 | "Invalid field" | -| EcodeInvalidForm | 210 | "Invalid POST form" | - -- Raft Related Error - -| name | code | strerror | -|-------------------|------|--------------------------| -| EcodeRaftInternal | 300 | "Raft Internal Error" | -| EcodeLeaderElect | 301 | "During Leader Election" | - -- Etcd Related Error - -| name | code | strerror | -|-------------------------|------|--------------------------------------------------------| -| EcodeWatcherCleared | 400 | "watcher is cleared due to etcd recovery" | -| EcodeEventIndexCleared | 401 | "The event in requested index is outdated and cleared" | diff --git a/Documentation/v2/etcd_alert.rules b/Documentation/v2/etcd_alert.rules deleted file mode 100644 index 5493c56b6..000000000 --- a/Documentation/v2/etcd_alert.rules +++ /dev/null @@ -1,121 +0,0 @@ -### General cluster availability ### - -# alert if another failed member will result in an unavailable cluster -ALERT InsufficientMembers - IF count(up{job="etcd"} == 0) > (count(up{job="etcd"}) / 2 - 1) - FOR 3m - LABELS { - severity = "critical" - } - ANNOTATIONS { - summary = "etcd cluster insufficient members", - description = "If one more etcd member goes down the cluster will be unavailable", - } - -### HTTP requests alerts ### - -# alert if more than 1% of requests to an HTTP endpoint have failed with a non 4xx response -ALERT HighNumberOfFailedHTTPRequests - IF sum by(method) (rate(etcd_http_failed_total{job="etcd", code!~"4[0-9]{2}"}[5m])) - / sum by(method) (rate(etcd_http_received_total{job="etcd"}[5m])) > 0.01 - FOR 10m - LABELS { - severity = "warning" - } - ANNOTATIONS { - summary = "a high number of HTTP requests are failing", - description = "{{ $value }}% of requests for {{ $labels.method }} failed on etcd instance {{ $labels.instance }}", - } - -# alert if more than 5% of requests to an HTTP endpoint have failed with a non 4xx response -ALERT HighNumberOfFailedHTTPRequests - IF sum by(method) (rate(etcd_http_failed_total{job="etcd", code!~"4[0-9]{2}"}[5m])) - / sum by(method) (rate(etcd_http_received_total{job="etcd"}[5m])) > 0.05 - FOR 5m - LABELS { - severity = "critical" - } - ANNOTATIONS { - summary = "a high number of HTTP requests are failing", - description = "{{ $value }}% of requests for {{ $labels.method }} failed on etcd instance {{ $labels.instance }}", - } - -# alert if 50% of requests get a 4xx response -ALERT HighNumberOfFailedHTTPRequests - IF sum by(method) (rate(etcd_http_failed_total{job="etcd", code=~"4[0-9]{2}"}[5m])) - / sum by(method) (rate(etcd_http_received_total{job="etcd"}[5m])) > 0.5 - FOR 10m - LABELS { - severity = "critical" - } - ANNOTATIONS { - summary = "a high number of HTTP requests are failing", - description = "{{ $value }}% of requests for {{ $labels.method }} failed with 4xx responses on etcd instance {{ $labels.instance }}", - } - -# alert if the 99th percentile of HTTP requests take more than 150ms -ALERT HTTPRequestsSlow - IF histogram_quantile(0.99, rate(etcd_http_successful_duration_second_bucket[5m])) > 0.15 - FOR 10m - LABELS { - severity = "warning" - } - ANNOTATIONS { - summary = "slow HTTP requests", - description = "on etcd instance {{ $labels.instance }} HTTP requests to {{ $labels.method }} are slow", - } - -### File descriptor alerts ### - -instance:fd_utilization = process_open_fds / process_max_fds - -# alert if file descriptors are likely to exhaust within the next 4 hours -ALERT FdExhaustionClose - IF predict_linear(instance:fd_utilization[1h], 3600 * 4) > 1 - FOR 10m - LABELS { - severity = "warning" - } - ANNOTATIONS { - summary = "file descriptors soon exhausted", - description = "{{ $labels.job }} instance {{ $labels.instance }} will exhaust its file descriptors soon", - } - -# alert if file descriptors are likely to exhaust within the next hour -ALERT FdExhaustionClose - IF predict_linear(instance:fd_utilization[10m], 3600) > 1 - FOR 10m - LABELS { - severity = "critical" - } - ANNOTATIONS { - summary = "file descriptors soon exhausted", - description = "{{ $labels.job }} instance {{ $labels.instance }} will exhaust its file descriptors soon", - } - -### etcd proposal alerts ### - -# alert if there are several failed proposals within an hour -ALERT HighNumberOfFailedProposals - IF increase(etcd_server_proposal_failed_total{job="etcd"}[1h]) > 5 - LABELS { - severity = "warning" - } - ANNOTATIONS { - summary = "a high number of proposals within the etcd cluster are failing", - description = "etcd instance {{ $labels.instance }} has seen {{ $value }} proposal failures within the last hour", - } - -### etcd disk io latency alerts ### - -# alert if 99th percentile of fsync durations is higher than 500ms -ALERT HighFsyncDurations - IF histogram_quantile(0.99, rate(etcd_wal_fsync_durations_seconds_bucket[5m])) > 0.5 - FOR 10m - LABELS { - severity = "warning" - } - ANNOTATIONS { - summary = "high fsync durations", - description = "etcd instance {{ $labels.instance }} fync durations are high", - } diff --git a/Documentation/v2/etcd_alert.rules.yml b/Documentation/v2/etcd_alert.rules.yml deleted file mode 100644 index c9f8686be..000000000 --- a/Documentation/v2/etcd_alert.rules.yml +++ /dev/null @@ -1,91 +0,0 @@ -groups: -- name: etcd_alert.rules - rules: - - alert: InsufficientMembers - expr: count(up{job="etcd"} == 0) > (count(up{job="etcd"}) / 2 - 1) - for: 3m - labels: - severity: critical - annotations: - description: If one more etcd member goes down the cluster will be unavailable - summary: etcd cluster insufficient members - - alert: HighNumberOfFailedHTTPRequests - expr: sum(rate(etcd_http_failed_total{code!~"^(?:4[0-9]{2})$",job="etcd"}[5m])) - BY (method) / sum(rate(etcd_http_received_total{job="etcd"}[5m])) BY (method) - > 0.01 - for: 10m - labels: - severity: warning - annotations: - description: '{{ $value }}% of requests for {{ $labels.method }} failed on etcd - instance {{ $labels.instance }}' - summary: a high number of HTTP requests are failing - - alert: HighNumberOfFailedHTTPRequests - expr: sum(rate(etcd_http_failed_total{code!~"^(?:4[0-9]{2})$",job="etcd"}[5m])) - BY (method) / sum(rate(etcd_http_received_total{job="etcd"}[5m])) BY (method) - > 0.05 - for: 5m - labels: - severity: critical - annotations: - description: '{{ $value }}% of requests for {{ $labels.method }} failed on etcd - instance {{ $labels.instance }}' - summary: a high number of HTTP requests are failing - - alert: HighNumberOfFailedHTTPRequests - expr: sum(rate(etcd_http_failed_total{code=~"^(?:4[0-9]{2})$",job="etcd"}[5m])) - BY (method) / sum(rate(etcd_http_received_total{job="etcd"}[5m])) BY (method) - > 0.5 - for: 10m - labels: - severity: critical - annotations: - description: '{{ $value }}% of requests for {{ $labels.method }} failed with - 4xx responses on etcd instance {{ $labels.instance }}' - summary: a high number of HTTP requests are failing - - alert: HTTPRequestsSlow - expr: histogram_quantile(0.99, rate(etcd_http_successful_duration_second_bucket[5m])) - > 0.15 - for: 10m - labels: - severity: warning - annotations: - description: on etcd instance {{ $labels.instance }} HTTP requests to {{ $labels.method - }} are slow - summary: slow HTTP requests - - record: instance:fd_utilization - expr: process_open_fds / process_max_fds - - alert: FdExhaustionClose - expr: predict_linear(instance:fd_utilization[1h], 3600 * 4) > 1 - for: 10m - labels: - severity: warning - annotations: - description: '{{ $labels.job }} instance {{ $labels.instance }} will exhaust - its file descriptors soon' - summary: file descriptors soon exhausted - - alert: FdExhaustionClose - expr: predict_linear(instance:fd_utilization[10m], 3600) > 1 - for: 10m - labels: - severity: critical - annotations: - description: '{{ $labels.job }} instance {{ $labels.instance }} will exhaust - its file descriptors soon' - summary: file descriptors soon exhausted - - alert: HighNumberOfFailedProposals - expr: increase(etcd_server_proposal_failed_total{job="etcd"}[1h]) > 5 - labels: - severity: warning - annotations: - description: etcd instance {{ $labels.instance }} has seen {{ $value }} proposal - failures within the last hour - summary: a high number of proposals within the etcd cluster are failing - - alert: HighFsyncDurations - expr: histogram_quantile(0.99, rate(etcd_wal_fsync_durations_seconds_bucket[5m])) - > 0.5 - for: 10m - labels: - severity: warning - annotations: - description: etcd instance {{ $labels.instance }} fync durations are high - summary: high fsync durations diff --git a/Documentation/v2/faq.md b/Documentation/v2/faq.md deleted file mode 100644 index c0faa41e0..000000000 --- a/Documentation/v2/faq.md +++ /dev/null @@ -1,89 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# FAQ - -## 1) Why can an etcd client read an old version of data when a majority of the etcd cluster members are down? - -In situations where a client connects to a minority, etcd -favors by default availability over consistency. This means that even though -data might be “out of date”, it is still better to return something versus -nothing. - -In order to confirm that a read is up to date with a majority of the cluster, -the client can use the `quorum=true` parameter on reads of keys. This means -that a majority of the cluster is checked on reads before returning the data, -otherwise the read will timeout and fail. - -## 2) With quorum=false, doesn’t this mean that if my client switched the member it was connected to, that it could experience a logical ordering where the cluster goes backwards in time? - -Yes, but this could be handled at the etcd client implementation via -remembering the last seen index. The “index” is the cluster's single -irrevocable sequence of the entire modification history. The client could -remember the last seen index, and determine via comparing the index returned on -the GET whether or not the state of the key-value pair is before or after its -last seen state. - -## 3) What happens if a watch is registered on a minority member? - -The watch will stay untriggered, even as modifications are occurring in the -majority quorum. This is an open issue, and is being addressed in v3. There are -multiple ways to work around the watch trigger not firing. - -1) build a signaling mechanism independent of etcd. This could be as simple as -a “pulse” to the client to reissue a GET with quorum=true for the most recent -version of the data. - -2) poll on the `/v2/keys` endpoint and check that the raft-index is increasing every -timeout. - -## 4) What is a proxy used for? - -A proxy is a redirection server to the etcd cluster. The proxy handles the -redirection of a client to the current configuration of the etcd cluster. A -typical use case is to start a proxy on a machine, and on first boot up of the -proxy specify both the `--proxy` flag and the `--initial-cluster` flag. - -From there, any etcdctl client that starts up automatically speaks to the local -proxy and the proxy redirects operations to the current configuration of the -cluster it was originally paired with. - -In the v2 spec of etcd, proxies cannot be promoted to members of the cluster. -They also cannot be promoted to followers or at any point become part of the -replication of the etcd cluster itself. - -## 5) How is cluster membership and health handled in etcd v2? - -The design goal of etcd is that reconfiguration is simply an API, and health -monitoring and addition/removal of members is up to the individual application -and their integration with the reconfiguration API. - -Thus, a member that is down, even infinitely, will never be automatically -removed from the etcd cluster member list. - -This makes sense because it's usually an application level / administrative -action to determine whether a reconfiguration should happen based on health. - -For more information, refer to the [runtime reconfiguration design document][runtime-reconf-design]. - -## 6) how does --endpoint work with etcdctl? - -The `--endpoint` flag can specify any number of etcd cluster members in a comma -separated list. This list might be a subset, equal to, or more than the actual -etcd cluster member list itself. - -If only one peer is specified via the `--endpoint` flag, the etcdctl discovers the -rest of the cluster via the member list of that one peer, and then it randomly -chooses a member to use. Again, the client can use the `quorum=true` flag on -reads, which will always fail when using a member in the minority. - -If peers from multiple clusters are specified via the `--endpoint` flag, etcdctl -will randomly choose a peer, and the request will simply get routed to one of -the clusters. This is probably not what you want. - -Note: --peers flag is now deprecated and --endpoint should be used instead, -as it might confuse users to give etcdctl a peerURL. - -[runtime-reconf-design]: runtime-reconf-design.md diff --git a/Documentation/v2/glossary.md b/Documentation/v2/glossary.md deleted file mode 100644 index 70c2d40ee..000000000 --- a/Documentation/v2/glossary.md +++ /dev/null @@ -1,40 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Glossary - -This document defines the various terms used in etcd documentation, command line and source code. - -## Node - -Node is an instance of raft state machine. - -It has a unique identification, and records other nodes' progress internally when it is the leader. - -## Member - -Member is an instance of etcd. It hosts a node, and provides service to clients. - -## Cluster - -Cluster consists of several members. - -The node in each member follows raft consensus protocol to replicate logs. Cluster receives proposals from members, commits them and apply to local store. - -## Peer - -Peer is another member of the same cluster. - -## Proposal - -A proposal is a request (for example a write request, a configuration change request) that needs to go through raft protocol. - -## Client - -Client is a caller of the cluster's HTTP API. - -## Machine (deprecated) - -The alternative of Member in etcd before 2.0 diff --git a/Documentation/v2/internal-protocol-versioning.md b/Documentation/v2/internal-protocol-versioning.md deleted file mode 100644 index 68d716e5f..000000000 --- a/Documentation/v2/internal-protocol-versioning.md +++ /dev/null @@ -1,66 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Versioning - -Goal: We want to be able to upgrade an individual peer in an etcd cluster to a newer version of etcd. -The process will take the form of individual followers upgrading to the latest version until the entire cluster is on the new version. - -Immediate need: etcd is moving too fast to version the internal API right now. -But, we need to keep mixed version clusters from being started by a rolling upgrade process (e.g. the CoreOS developer alpha). - -Longer term need: Having a mixed version cluster where all peers are not running the exact same version of etcd itself but are able to speak one version of the internal protocol. - -Solution: The internal protocol needs to be versioned just as the client protocol is. -Initially during the 0.\*.\* series of etcd releases we won't allow mixed versions at all. - -## Join Control - -We will add a version field to the join command. -But, who decides whether a newly upgraded follower should be able to join a cluster? - -### Leader Controlled - -If the leader controls the version of followers joining the cluster then it compares its version to the version number presented by the follower in the JoinCommand and rejects the join if the number is less than the leader's version number. - -Advantages - -- Leader controls all cluster decisions still - -Disadvantages - -- Follower knows better what versions of the internal protocol it can talk than the leader - - -### Follower Controlled - -A newly upgraded follower should be able to figure out the leaders internal version from a defined internal backwards compatible API endpoint and figure out if it can join the cluster. -If it cannot join the cluster then it simply exits. - -Advantages - -- The follower is running newer code and knows better if it can talk older protocols - -Disadvantages - -- This cluster decision isn't made by the leader - -## Recommendation - -To solve the immediate need and to plan for the future lets do the following: - -- Add Version field to JoinCommand -- Have a joining follower read the Version field of the leader and if its own version doesn't match the leader then sleep for some random interval and retry later to see if the leader has upgraded. - -# Research - -## Zookeeper versioning - -Zookeeper very recently added versioning into the protocol and it doesn't seem to have seen any use yet. -https://issues.apache.org/jira/browse/ZOOKEEPER-1633 - -## doozerd - -doozerd stores the version number of the peers in the datastore for other clients to check, no decisions are made off of this number currently. diff --git a/Documentation/v2/libraries-and-tools.md b/Documentation/v2/libraries-and-tools.md deleted file mode 100644 index 806a5d902..000000000 --- a/Documentation/v2/libraries-and-tools.md +++ /dev/null @@ -1,131 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Libraries and Tools - -**Tools** - -- [etcdctl](https://github.com/coreos/etcd/tree/master/etcdctl) - A command line client for etcd -- [etcd-backup](https://github.com/fanhattan/etcd-backup) - A powerful command line utility for dumping/restoring etcd - Supports v2 -- [etcd-dump](https://npmjs.org/package/etcd-dump) - Command line utility for dumping/restoring etcd. -- [etcd-fs](https://github.com/xetorthio/etcd-fs) - FUSE filesystem for etcd -- [etcddir](https://github.com/rekby/etcddir) - Realtime sync etcd and local directory. Work with windows and linux. -- [etcd-browser](https://github.com/henszey/etcd-browser) - A web-based key/value editor for etcd using AngularJS -- [etcd-lock](https://github.com/datawisesystems/etcd-lock) - Master election & distributed r/w lock implementation using etcd - Supports v2 -- [etcd-console](https://github.com/matishsiao/etcd-console) - A web-base key/value editor for etcd using PHP -- [etcd-viewer](https://github.com/nikfoundas/etcd-viewer) - An etcd key-value store editor/viewer written in Java -- [etcdtool](https://github.com/mickep76/etcdtool) - Export/Import/Edit etcd directory as JSON/YAML/TOML and Validate directory using JSON schema -- [etcd-rest](https://github.com/mickep76/etcd-rest) - Create generic REST API in Go using etcd as a backend with validation using JSON schema -- [etcdsh](https://github.com/kamilhark/etcdsh) - A command line client with support of command history and tab completion. Supports v2 - -**Go libraries** - -- [etcd/client](https://github.com/coreos/etcd/blob/master/client) - the officially maintained Go client -- [go-etcd](https://github.com/coreos/go-etcd) - the deprecated official client. May be useful for older (<2.0.0) versions of etcd. - -**Java libraries** - -- [boonproject/etcd](https://github.com/boonproject/boon/blob/master/etcd/README.md) - Supports v2, Async/Sync and waits -- [justinsb/jetcd](https://github.com/justinsb/jetcd) -- [diwakergupta/jetcd](https://github.com/diwakergupta/jetcd) - Supports v2 -- [jurmous/etcd4j](https://github.com/jurmous/etcd4j) - Supports v2, Async/Sync, waits and SSL -- [AdoHe/etcd4j](http://github.com/AdoHe/etcd4j) - Supports v2 (enhance for real production cluster) - -**Python libraries** - -- [jplana/python-etcd](https://github.com/jplana/python-etcd) - Supports v2 -- [russellhaering/txetcd](https://github.com/russellhaering/txetcd) - a Twisted Python library -- [cholcombe973/autodock](https://github.com/cholcombe973/autodock) - A docker deployment automation tool -- [lisael/aioetcd](https://github.com/lisael/aioetcd) - (Python 3.4+) Asyncio coroutines client (Supports v2) - -**Node libraries** - -- [stianeikeland/node-etcd](https://github.com/stianeikeland/node-etcd) - Supports v2 (w Coffeescript) -- [lavagetto/nodejs-etcd](https://github.com/lavagetto/nodejs-etcd) - Supports v2 -- [deedubs/node-etcd-config](https://github.com/deedubs/node-etcd-config) - Supports v2 - -**Ruby libraries** - -- [iconara/etcd-rb](https://github.com/iconara/etcd-rb) -- [jpfuentes2/etcd-ruby](https://github.com/jpfuentes2/etcd-ruby) -- [ranjib/etcd-ruby](https://github.com/ranjib/etcd-ruby) - Supports v2 - -**C libraries** - -- [jdarcy/etcd-api](https://github.com/jdarcy/etcd-api) - Supports v2 -- [shafreeck/cetcd](https://github.com/shafreeck/cetcd) - Supports v2 - -**C++ libraries** - -- [edwardcapriolo/etcdcpp](https://github.com/edwardcapriolo/etcdcpp) - Supports v2 -- [suryanathan/etcdcpp](https://github.com/suryanathan/etcdcpp) - Supports v2 (with waits) -- [nokia/etcd-cpp-api](https://github.com/nokia/etcd-cpp-api) - Supports v2 -- [nokia/etcd-cpp-apiv3](https://github.com/nokia/etcd-cpp-apiv3) - -**Clojure libraries** - -- [aterreno/etcd-clojure](https://github.com/aterreno/etcd-clojure) -- [dwwoelfel/cetcd](https://github.com/dwwoelfel/cetcd) - Supports v2 -- [rthomas/clj-etcd](https://github.com/rthomas/clj-etcd) - Supports v2 - -**Erlang libraries** - -- [marshall-lee/etcd.erl](https://github.com/marshall-lee/etcd.erl) - -**.Net Libraries** - -- [wangjia184/etcdnet](https://github.com/wangjia184/etcdnet) - Supports v2 -- [drusellers/etcetera](https://github.com/drusellers/etcetera) - -**PHP Libraries** - -- [linkorb/etcd-php](https://github.com/linkorb/etcd-php) - -**Haskell libraries** - -- [wereHamster/etcd-hs](https://github.com/wereHamster/etcd-hs) - -**R libraries** - -- [ropensci/etseed](https://github.com/ropensci/etseed) - -**Tcl libraries** - -- [efrecon/etcd-tcl](https://github.com/efrecon/etcd-tcl) - Supports v2, except wait. - -**Chef Integration** - -- [coderanger/etcd-chef](https://github.com/coderanger/etcd-chef) - -**Chef Cookbook** - -- [spheromak/etcd-cookbook](https://github.com/spheromak/etcd-cookbook) - -**BOSH Releases** - -- [cloudfoundry-community/etcd-boshrelease](https://github.com/cloudfoundry-community/etcd-boshrelease) -- [cloudfoundry/cf-release](https://github.com/cloudfoundry/cf-release/tree/master/jobs/etcd) - -**Projects using etcd** - -- [binocarlos/yoda](https://github.com/binocarlos/yoda) - etcd + ZeroMQ -- [calavera/active-proxy](https://github.com/calavera/active-proxy) - HTTP Proxy configured with etcd -- [derekchiang/etcdplus](https://github.com/derekchiang/etcdplus) - A set of distributed synchronization primitives built upon etcd -- [go-discover](https://github.com/flynn/go-discover) - service discovery in Go -- [gleicon/goreman](https://github.com/gleicon/goreman/tree/etcd) - Branch of the Go Foreman clone with etcd support -- [garethr/hiera-etcd](https://github.com/garethr/hiera-etcd) - Puppet hiera backend using etcd -- [mattn/etcd-vim](https://github.com/mattn/etcd-vim) - SET and GET keys from inside vim -- [mattn/etcdenv](https://github.com/mattn/etcdenv) - "env" shebang with etcd integration -- [kelseyhightower/confd](https://github.com/kelseyhightower/confd) - Manage local app config files using templates and data from etcd -- [configdb](https://git.autistici.org/ai/configdb/tree/master) - A REST relational abstraction on top of arbitrary database backends, aimed at storing configs and inventories. -- [fleet](https://github.com/coreos/fleet) - Distributed init system -- [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes) - Container cluster manager introduced by Google. -- [mailgun/vulcand](https://github.com/mailgun/vulcand) - HTTP proxy that uses etcd as a configuration backend. -- [duedil-ltd/discodns](https://github.com/duedil-ltd/discodns) - Simple DNS nameserver using etcd as a database for names and records. -- [skynetservices/skydns](https://github.com/skynetservices/skydns) - RFC compliant DNS server -- [xordataexchange/crypt](https://github.com/xordataexchange/crypt) - Securely store values in etcd using GPG encryption -- [spf13/viper](https://github.com/spf13/viper) - Go configuration library, reads values from ENV, pflags, files, and etcd with optional encryption -- [lytics/metafora](https://github.com/lytics/metafora) - Go distributed task library -- [ryandoyle/nss-etcd](https://github.com/ryandoyle/nss-etcd) - A GNU libc NSS module for resolving names from etcd. diff --git a/Documentation/v2/members_api.md b/Documentation/v2/members_api.md deleted file mode 100644 index a9ff6a043..000000000 --- a/Documentation/v2/members_api.md +++ /dev/null @@ -1,125 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Members API - -* [List members](#list-members) -* [Add a member](#add-a-member) -* [Delete a member](#delete-a-member) -* [Change the peer urls of a member](#change-the-peer-urls-of-a-member) - -## List members - -Return an HTTP 200 OK response code and a representation of all members in the etcd cluster. - -### Request - -``` -GET /v2/members HTTP/1.1 -``` - -### Example - -```sh -curl http://10.0.0.10:2379/v2/members -``` - -```json -{ - "members": [ - { - "id": "272e204152", - "name": "infra1", - "peerURLs": [ - "http://10.0.0.10:2380" - ], - "clientURLs": [ - "http://10.0.0.10:2379" - ] - }, - { - "id": "2225373f43", - "name": "infra2", - "peerURLs": [ - "http://10.0.0.11:2380" - ], - "clientURLs": [ - "http://10.0.0.11:2379" - ] - }, - ] -} -``` - -## Add a member - -Returns an HTTP 201 response code and the representation of added member with a newly generated a memberID when successful. Returns a string describing the failure condition when unsuccessful. - -If the POST body is malformed an HTTP 400 will be returned. If the member exists in the cluster or existed in the cluster at some point in the past an HTTP 409 will be returned. If any of the given peerURLs exists in the cluster an HTTP 409 will be returned. If the cluster fails to process the request within timeout an HTTP 500 will be returned, though the request may be processed later. - -### Request - -``` -POST /v2/members HTTP/1.1 - -{"peerURLs": ["http://10.0.0.10:2380"]} -``` - -### Example - -```sh -curl http://10.0.0.10:2379/v2/members -XPOST \ --H "Content-Type: application/json" -d '{"peerURLs":["http://10.0.0.10:2380"]}' -``` - -```json -{ - "id": "3777296169", - "peerURLs": [ - "http://10.0.0.10:2380" - ] -} -``` - -## Delete a member - -Remove a member from the cluster. The member ID must be a hex-encoded uint64. -Returns 204 with empty content when successful. Returns a string describing the failure condition when unsuccessful. - -If the member does not exist in the cluster an HTTP 500(TODO: fix this) will be returned. If the cluster fails to process the request within timeout an HTTP 500 will be returned, though the request may be processed later. - -### Request - -``` -DELETE /v2/members/ HTTP/1.1 -``` - -### Example - -```sh -curl http://10.0.0.10:2379/v2/members/272e204152 -XDELETE -``` - -## Change the peer urls of a member - -Change the peer urls of a given member. The member ID must be a hex-encoded uint64. Returns 204 with empty content when successful. Returns a string describing the failure condition when unsuccessful. - -If the POST body is malformed an HTTP 400 will be returned. If the member does not exist in the cluster an HTTP 404 will be returned. If any of the given peerURLs exists in the cluster an HTTP 409 will be returned. If the cluster fails to process the request within timeout an HTTP 500 will be returned, though the request may be processed later. - -### Request - -``` -PUT /v2/members/ HTTP/1.1 - -{"peerURLs": ["http://10.0.0.10:2380"]} -``` - -### Example - -```sh -curl http://10.0.0.10:2379/v2/members/272e204152 -XPUT \ --H "Content-Type: application/json" -d '{"peerURLs":["http://10.0.0.10:2380"]}' -``` - diff --git a/Documentation/v2/metrics.md b/Documentation/v2/metrics.md deleted file mode 100644 index 596c14b64..000000000 --- a/Documentation/v2/metrics.md +++ /dev/null @@ -1,148 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Metrics - -etcd uses [Prometheus][prometheus] for metrics reporting. The metrics can be used for real-time monitoring and debugging. etcd does not persist its metrics; if a member restarts, the metrics will be reset. - -The simplest way to see the available metrics is to cURL the metrics endpoint `/metrics`. The format is described [here](http://prometheus.io/docs/instrumenting/exposition_formats/). - -Follow the [Prometheus getting started doc][prometheus-getting-started] to spin up a Prometheus server to collect etcd metrics. - -The naming of metrics follows the suggested [Prometheus best practices][prometheus-naming]. A metric name has an `etcd` or `etcd_debugging` prefix as its namespace and a subsystem prefix (for example `wal` and `etcdserver`). - -## etcd namespace metrics - -The metrics under the `etcd` prefix are for monitoring and alerting. They are stable high level metrics. If there is any change of these metrics, it will be included in release notes. - -### http requests - -These metrics describe the serving of requests (non-watch events) served by etcd members in non-proxy mode: total -incoming requests, request failures and processing latency (inc. raft rounds for storage). They are useful for tracking - user-generated traffic hitting the etcd cluster . - -All these metrics are prefixed with `etcd_http_` - -| Name | Description | Type | -|--------------------------------|-----------------------------------------------------------------------------------------|--------------------| -| received_total | Total number of events after parsing and auth. | Counter(method) | -| failed_total | Total number of failed events.   | Counter(method,error) | -| successful_duration_seconds | Bucketed handling times of the requests, including raft rounds for writes. | Histogram(method) | - - -Example Prometheus queries that may be useful from these metrics (across all etcd members): - - * `sum(rate(etcd_http_failed_total{job="etcd"}[1m]) by (method) / sum(rate(etcd_http_events_received_total{job="etcd"})[1m]) by (method)` - - Shows the fraction of events that failed by HTTP method across all members, across a time window of `1m`. - - * `sum(rate(etcd_http_received_total{job="etcd",method="GET})[1m]) by (method)` - `sum(rate(etcd_http_received_total{job="etcd",method~="GET})[1m]) by (method)` - - Shows the rate of successful readonly/write queries across all servers, across a time window of `1m`. - - * `histogram_quantile(0.9, sum(rate(etcd_http_successful_duration_seconds{job="etcd",method="GET"}[5m]) ) by (le))` - `histogram_quantile(0.9, sum(rate(etcd_http_successful_duration_seconds{job="etcd",method!="GET"}[5m]) ) by (le))` - - Show the 0.90-tile latency (in seconds) of read/write (respectively) event handling across all members, with a window of `5m`. - -### proxy - -etcd members operating in proxy mode do not directly perform store operations. They forward all requests to cluster instances. - -Tracking the rate of requests coming from a proxy allows one to pin down which machine is performing most reads/writes. - -All these metrics are prefixed with `etcd_proxy_` - -| Name | Description | Type | -|---------------------------|-----------------------------------------------------------------------------------------|--------------------| -| requests_total | Total number of requests by this proxy instance. | Counter(method) | -| handled_total | Total number of fully handled requests, with responses from etcd members. | Counter(method) | -| dropped_total | Total number of dropped requests due to forwarding errors to etcd members.  | Counter(method,error) | -| handling_duration_seconds | Bucketed handling times by HTTP method, including round trip to member instances. | Histogram(method) | - -Example Prometheus queries that may be useful from these metrics (across all etcd servers): - - * `sum(rate(etcd_proxy_handled_total{job="etcd"}[1m])) by (method)` - - Rate of requests (by HTTP method) handled by all proxies, across a window of `1m`. - - * `histogram_quantile(0.9, sum(rate(handling_duration_seconds{job="etcd",method="GET"}[5m])) by (le))` - `histogram_quantile(0.9, sum(rate(handling_duration_seconds{job="etcd",method!="GET"}[5m])) by (le))` - - Show the 0.90-tile latency (in seconds) of handling of user requests across all proxy machines, with a window of `5m`. - - * `sum(rate(etcd_proxy_dropped_total{job="etcd"}[1m])) by (proxying_error)` - - Number of failed request on the proxy. This should be 0, spikes here indicate connectivity issues to the etcd cluster. - -## etcd_debugging namespace metrics - -The metrics under the `etcd_debugging` prefix are for debugging. They are very implementation dependent and volatile. They might be changed or removed without any warning in new etcd releases. Some of the metrics might be moved to the `etcd` prefix when they become more stable. - -### etcdserver - -| Name | Description | Type | -|-----------------------------------------|--------------------------------------------------|-----------| -| proposal_duration_seconds | The latency distributions of committing proposal | Histogram | -| proposals_pending | The current number of pending proposals | Gauge | -| proposals_failed_total | The total number of failed proposals | Counter | - -[Proposal][glossary-proposal] duration (`proposal_duration_seconds`) provides a proposal commit latency histogram. The reported latency reflects network and disk IO delays in etcd. - -Proposals pending (`proposals_pending`) indicates how many proposals are queued for commit. Rising pending proposals suggests there is a high client load or the cluster is unstable. - -Failed proposals (`proposals_failed_total`) are normally related to two issues: temporary failures related to a leader election or longer duration downtime caused by a loss of quorum in the cluster. - -### wal - -| Name | Description | Type | -|------------------------------------|--------------------------------------------------|-----------| -| fsync_duration_seconds | The latency distributions of fsync called by wal | Histogram | -| last_index_saved | The index of the last entry saved by wal | Gauge | - -Abnormally high fsync duration (`fsync_duration_seconds`) indicates disk issues and might cause the cluster to be unstable. - -### snapshot - -| Name | Description | Type | -|--------------------------------------------|------------------------------------------------------------|-----------| -| snapshot_save_total_duration_seconds | The total latency distributions of save called by snapshot | Histogram | - -Abnormally high snapshot duration (`snapshot_save_total_duration_seconds`) indicates disk issues and might cause the cluster to be unstable. - -### rafthttp - -| Name | Description | Type | Labels | -|-----------------------------------|--------------------------------------------|--------------|--------------------------------| -| message_sent_latency_seconds | The latency distributions of messages sent | HistogramVec | sendingType, msgType, remoteID | -| message_sent_failed_total | The total number of failed messages sent | Summary | sendingType, msgType, remoteID | - - -Abnormally high message duration (`message_sent_latency_seconds`) indicates network issues and might cause the cluster to be unstable. - -An increase in message failures (`message_sent_failed_total`) indicates more severe network issues and might cause the cluster to be unstable. - -Label `sendingType` is the connection type to send messages. `message`, `msgapp` and `msgappv2` use HTTP streaming, while `pipeline` does HTTP request for each message. - -Label `msgType` is the type of raft message. `MsgApp` is log replication messages; `MsgSnap` is snapshot install messages; `MsgProp` is proposal forward messages; the others maintain internal raft status. Given large snapshots, a lengthy msgSnap transmission latency should be expected. For other types of messages, given enough network bandwidth, latencies comparable to ping latency should be expected. - -Label `remoteID` is the member ID of the message destination. - -## Prometheus supplied metrics - -The Prometheus client library provides a number of metrics under the `go` and `process` namespaces. There are a few that are particlarly interesting. - -| Name | Description | Type | -|-----------------------------------|--------------------------------------------|--------------| -| process_open_fds | Number of open file descriptors. | Gauge | -| process_max_fds | Maximum number of open file descriptors. | Gauge | - -Heavy file descriptor (`process_open_fds`) usage (i.e., near the process's file descriptor limit, `process_max_fds`) indicates a potential file descriptor exhaustion issue. If the file descriptors are exhausted, etcd may panic because it cannot create new WAL files. - -[glossary-proposal]: glossary.md#proposal -[prometheus]: http://prometheus.io/ -[prometheus-getting-started]: http://prometheus.io/docs/introduction/getting_started/ -[prometheus-naming]: http://prometheus.io/docs/practices/naming/ diff --git a/Documentation/v2/other_apis.md b/Documentation/v2/other_apis.md deleted file mode 100644 index ec21a886c..000000000 --- a/Documentation/v2/other_apis.md +++ /dev/null @@ -1,33 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Miscellaneous APIs - -* [Getting the etcd version](#getting-the-etcd-version) -* [Checking health of an etcd member node](#checking-health-of-an-etcd-member-node) - -## Getting the etcd version - -The etcd version of a specific instance can be obtained from the `/version` endpoint. - -```sh -curl -L http://127.0.0.1:2379/version -``` - -``` -etcd 2.0.12 -``` - -## Checking health of an etcd member node - -etcd provides a `/health` endpoint to verify the health of a particular member. - -```sh -curl http://10.0.0.10:2379/health -``` - -```json -{"health":"true"} -``` diff --git a/Documentation/v2/platforms/freebsd.md b/Documentation/v2/platforms/freebsd.md deleted file mode 100644 index 891ea6f53..000000000 --- a/Documentation/v2/platforms/freebsd.md +++ /dev/null @@ -1,67 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../../docs.md#documentation - - -# FreeBSD - -Starting with version 0.1.2 both etcd and etcdctl have been ported to FreeBSD and can -be installed either via packages or ports system. Their versions have been recently -updated to 0.2.0 so now you can enjoy using etcd and etcdctl on FreeBSD 10.0 (RC4 as -of now) and 9.x where they have been tested. They might also work when installed from -ports on earlier versions of FreeBSD, but your mileage may vary. - -## Installation - -### Using pkgng package system - -1. If you do not have pkg­ng installed, install it with command `pkg` and answering 'Y' -when asked - -2. Update your repository data with `pkg update` - -3. Install etcd with `pkg install coreos-etcd coreos-etcdctl` - -4. Verify successful installation with `pkg info | grep etcd` and you should get: - -``` -r@fbsd­10:/ # pkg info | grep etcd -coreos­etcd­0.2.0              Highly­available key value store and service discovery -coreos­etcdctl­0.2.0           Simple commandline client for etcd -r@fbsd­10:/ # -``` - -5. You’re ready to use etcd and etcdctl! For more information about using pkgng, please -see: http://www.freebsd.org/doc/handbook/pkgng­intro.html -  -### Using ports system - -1. If you do not have ports installed, install with with `portsnap fetch extract` (it -may take some time depending on your hardware and network connection) - -2. Build etcd with `cd /usr/ports/devel/etcd && make install clean`, you -will get an option to build and install documentation and etcdctl with it. - -3. If you haven't installed it with etcdctl, and you would like to install it later, you can build it -with `cd /usr/ports/devel/etcdctl && make install clean` - -4. Verify successful installation with `pkg info | grep etcd` and you should get: -  - -``` -r@fbsd­10:/ # pkg info | grep etcd -coreos­etcd­0.2.0              Highly­available key value store and service discovery -coreos­etcdctl­0.2.0           Simple commandline client for etcd -r@fbsd­10:/ # -``` - -5. You’re ready to use etcd and etcdctl! For more information about using ports system, -please see: https://www.freebsd.org/doc/handbook/ports­using.html - -## Issues - -If you find any issues with the build/install procedure or you've found a problem that -you've verified is local to FreeBSD version only (for example, by not being able to -reproduce it on any other platform, like OSX or Linux), please sent a -problem report using this page for more -information: http://www.freebsd.org/send­pr.html diff --git a/Documentation/v2/production-users.md b/Documentation/v2/production-users.md deleted file mode 100644 index addef2a92..000000000 --- a/Documentation/v2/production-users.md +++ /dev/null @@ -1,56 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Production Users - -This document tracks people and use cases for etcd in production. By creating a list of production use cases we hope to build a community of advisors that we can reach out to with experience using various etcd applications, operation environments, and cluster sizes. The etcd development team may reach out periodically to check-in on your experience and update this list. - -## discovery.etcd.io - -- *Application*: https://github.com/coreos/discovery.etcd.io -- *Launched*: Feb. 2014 -- *Cluster Size*: 5 members, 5 discovery proxies -- *Order of Data Size*: 100s of Megabytes -- *Operator*: CoreOS, brandon.philips@coreos.com -- *Environment*: AWS -- *Backups*: Periodic async to S3 - -discovery.etcd.io is the longest continuously running etcd backed service that we know about. It is the basis of automatic cluster bootstrap and was launched in Feb. 2014: https://coreos.com/blog/etcd-0.3.0-released/. - -## OpenTable - -- *Application*: OpenTable internal service discovery and cluster configuration management -- *Launched*: May 2014 -- *Cluster Size*: 3 members each in 6 independent clusters; approximately 50 nodes reading / writing -- *Order of Data Size*: 10s of MB -- *Operator*: OpenTable, Inc; sschlansker@opentable.com -- *Environment*: AWS, VMWare -- *Backups*: None, all data can be re-created if necessary. - -## cycoresys.com - -- *Application*: multiple -- *Launched*: Jul. 2014 -- *Cluster Size*: 3 members, _n_ proxies -- *Order of Data Size*: 100s of kilobytes -- *Operator*: CyCore Systems, Inc, sys@cycoresys.com -- *Environment*: Baremetal -- *Backups*: Periodic sync to Ceph RadosGW and DigitalOcean VM - -CyCore Systems provides architecture and engineering for computing systems. This cluster provides microservices, virtual machines, databases, storage clusters to a number of clients. It is built on CoreOS machines, with each machine in the cluster running etcd as a peer or proxy. - -## Radius Intelligence - -- *Application*: multiple internal tools, Kubernetes clusters, bootstrappable system configs -- *Launched*: June 2015 -- *Cluster Size*: 2 clusters of 5 and 3 members; approximately a dozen nodes read/write -- *Order of Data Size*: 100s of kilobytes -- *Operator*: Radius Intelligence; jcderr@radius.com -- *Environment*: AWS, CoreOS, Kubernetes -- *Backups*: None, all data can be recreated if necessary. - -Radius Intelligence uses Kubernetes running CoreOS to containerize and scale internal toolsets. Examples include running [JetBrains TeamCity][teamcity] and internal AWS security and cost reporting tools. etcd clusters back these clusters as well as provide some basic environment bootstrapping configuration keys. - -[teamcity]: https://www.jetbrains.com/teamcity/ diff --git a/Documentation/v2/proxy.md b/Documentation/v2/proxy.md deleted file mode 100644 index e96147cbd..000000000 --- a/Documentation/v2/proxy.md +++ /dev/null @@ -1,158 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Proxy - -etcd can run as a transparent proxy. Doing so allows for easy discovery of etcd within your infrastructure, since it can run on each machine as a local service. In this mode, etcd acts as a reverse proxy and forwards client requests to an active etcd cluster. The etcd proxy does not participate in the consensus replication of the etcd cluster, thus it neither increases the resilience nor decreases the write performance of the etcd cluster. - -etcd currently supports two proxy modes: `readwrite` and `readonly`. The default mode is `readwrite`, which forwards both read and write requests to the etcd cluster. A `readonly` etcd proxy only forwards read requests to the etcd cluster, and returns `HTTP 501` to all write requests. - -The proxy will shuffle the list of cluster members periodically to avoid sending all connections to a single member. - -The member list used by an etcd proxy consists of all client URLs advertised in the cluster. These client URLs are specified in each etcd cluster member's `advertise-client-urls` option. - -An etcd proxy examines several command-line options to discover its peer URLs. In order of precedence, these options are `discovery`, `discovery-srv`, and `initial-cluster`. The `initial-cluster` option is set to a comma-separated list of one or more etcd peer URLs used temporarily in order to discover the permanent cluster. - -After establishing a list of peer URLs in this manner, the proxy retrieves the list of client URLs from the first reachable peer. These client URLs are specified by the `advertise-client-urls` option to etcd peers. The proxy then continues to connect to the first reachable etcd cluster member every thirty seconds to refresh the list of client URLs. - -While etcd proxies therefore do not need to be given the `advertise-client-urls` option, as they retrieve this configuration from the cluster, this implies that `initial-cluster` must be set correctly for every proxy, and the `advertise-client-urls` option must be set correctly for every non-proxy, first-order cluster peer. Otherwise, requests to any etcd proxy would be forwarded improperly. Take special care not to set the `advertise-client-urls` option to URLs that point to the proxy itself, as such a configuration will cause the proxy to enter a loop, forwarding requests to itself until resources are exhausted. To correct either case, stop etcd and restart it with the correct URLs. - -[This example Procfile][procfile] illustrates the difference in the etcd peer and proxy command lines used to configure and start a cluster with one proxy under the [goreman process management utility][goreman]. - -To summarize etcd proxy startup and peer discovery: - -1. etcd proxies execute the following steps in order until the cluster *peer-urls* are known: - 1. If `discovery` is set for the proxy, ask the given discovery service for - the *peer-urls*. The *peer-urls* will be the combined - `initial-advertise-peer-urls` of all first-order, non-proxy cluster - members. - 2. If `discovery-srv` is set for the proxy, the *peer-urls* are discovered - from DNS. - 3. If `initial-cluster` is set for the proxy, that will become the value of - *peer-urls*. - 4. Otherwise use the default value of - `http://localhost:2380,http://localhost:7001`. -2. These *peer-urls* are used to contact the (non-proxy) members of the cluster - to find their *client-urls*. The *client-urls* will thus be the combined - `advertise-client-urls` of all cluster members (i.e. non-proxies). -3. Request of clients of the proxy will be forwarded (proxied) to these - *client-urls*. - -Always start the first-order etcd cluster members first, then any proxies. A proxy must be able to reach the cluster members to retrieve its configuration, and will attempt connections somewhat aggressively in the absence of such a channel. Starting the members before any proxy ensures the proxy can discover the client URLs when it later starts. - -## Using an etcd proxy -To start etcd in proxy mode, you need to provide three flags: `proxy`, `listen-client-urls`, and `initial-cluster` (or `discovery`). - -To start a readwrite proxy, set `-proxy on`; To start a readonly proxy, set `-proxy readonly`. - -The proxy will be listening on `listen-client-urls` and forward requests to the etcd cluster discovered from in `initial-cluster` or `discovery` url. - -### Start an etcd proxy with a static configuration -To start a proxy that will connect to a statically defined etcd cluster, specify the `initial-cluster` flag: - -``` -etcd --proxy on \ ---listen-client-urls http://127.0.0.1:2379 \ ---initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 -``` - -### Start an etcd proxy with the discovery service -If you bootstrap an etcd cluster using the [discovery service][discovery-service], you can also start the proxy with the same `discovery`. - -To start a proxy using the discovery service, specify the `discovery` flag. The proxy will wait until the etcd cluster defined at the `discovery` url finishes bootstrapping, and then start to forward the requests. - -``` -etcd --proxy on \ ---listen-client-urls http://127.0.0.1:2379 \ ---discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de \ -``` - -## Fallback to proxy mode with discovery service - -If you bootstrap an etcd cluster using [discovery service][discovery-service] with more than the expected number of etcd members, the extra etcd processes will fall back to being `readwrite` proxies by default. They will forward the requests to the cluster as described above. For example, if you create a discovery url with `size=5`, and start ten etcd processes using that same discovery url, the result will be a cluster with five etcd members and five proxies. Note that this behaviour can be disabled with the `discovery-fallback='exit'` flag. - -## Promote a proxy to a member of etcd cluster - -A Proxy is in the part of etcd cluster that does not participate in consensus. A proxy will not promote itself to an etcd member that participates in consensus automatically in any case. - -If you want to promote a proxy to an etcd member, there are four steps you need to follow: - -- use etcdctl to add the proxy node as an etcd member into the existing cluster -- stop the etcd proxy process or service -- remove the existing proxy data directory -- restart the etcd process with new member configuration - -## Example - -We assume you have a one member etcd cluster with one proxy. The cluster information is listed below: - -|Name|Address| -|------|---------| -|infra0|10.0.1.10| -|proxy0|10.0.1.11| - -This example walks you through a case that you promote one proxy to an etcd member. The cluster will become a two member cluster after finishing the four steps. - -### Add a new member into the existing cluster - -First, use etcdctl to add the member to the cluster, which will output the environment variables need to correctly configure the new member: - -``` bash -$ etcdctl -endpoint http://10.0.1.10:2379 member add infra1 http://10.0.1.11:2380 -added member 9bf1b35fc7761a23 to cluster - -ETCD_NAME="infra1" -ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380" -ETCD_INITIAL_CLUSTER_STATE=existing -``` - -### Stop the proxy process - -Stop the existing proxy so we can wipe its state on disk and reload it with the new configuration: - -``` bash -ps aux | grep etcd -kill %etcd_proxy_pid% -``` - -or (if you are running etcd proxy as etcd service under systemd) - -``` bash -sudo systemctl stop etcd -``` - -### Remove the existing proxy data dir - -``` bash -rm -rf %data_dir%/proxy -``` - -### Start etcd as a new member - -Finally, start the reconfigured member and make sure it joins the cluster correctly: - -``` bash -$ export ETCD_NAME="infra1" -$ export ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380" -$ export ETCD_INITIAL_CLUSTER_STATE=existing -$ etcd --listen-client-urls http://10.0.1.11:2379 \ ---advertise-client-urls http://10.0.1.11:2379 \ ---listen-peer-urls http://10.0.1.11:2380 \ ---initial-advertise-peer-urls http://10.0.1.11:2380 \ ---data-dir %data_dir% -``` - -If you are running etcd under systemd, you should modify the service file with correct configuration and restart the service: - -``` bash -sudo systemd restart etcd -``` - -If an error occurs, check the [add member troubleshooting doc][runtime-configuration]. - -[discovery-service]: clustering.md#discovery -[goreman]: https://github.com/mattn/goreman -[procfile]: https://github.com/coreos/etcd/blob/master/Procfile.v2 -[runtime-configuration]: runtime-configuration.md#error-cases-when-adding-members diff --git a/Documentation/v2/reporting_bugs.md b/Documentation/v2/reporting_bugs.md deleted file mode 100644 index 1f5880faa..000000000 --- a/Documentation/v2/reporting_bugs.md +++ /dev/null @@ -1,50 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Reporting Bugs - -If you find bugs or documentation mistakes in the etcd project, please let us know by [opening an issue][etcd-issue]. We treat bugs and mistakes very seriously and believe no issue is too small. Before creating a bug report, please check that an issue reporting the same problem does not already exist. - -To make your bug report accurate and easy to understand, please try to create bug reports that are: - -- Specific. Include as much details as possible: which version, what environment, what configuration, etc. You can also attach etcd log (the starting log with etcd configuration is especially important). - -- Reproducible. Include the steps to reproduce the problem. We understand some issues might be hard to reproduce, please includes the steps that might lead to the problem. You can also attach the affected etcd data dir and stack strace to the bug report. - -- Isolated. Please try to isolate and reproduce the bug with minimum dependencies. It would significantly slow down the speed to fix a bug if too many dependencies are involved in a bug report. Debugging external systems that rely on etcd is out of scope, but we are happy to point you in the right direction or help you interact with etcd in the correct manner. - -- Unique. Do not duplicate existing bug report. - -- Scoped. One bug per report. Do not follow up with another bug inside one report. - -You might also want to read [Elika Etemad’s article on filing good bug reports][filing-good-bugs] before creating a bug report. - -We might ask you for further information to locate a bug. A duplicated bug report will be closed. - -## Frequently Asked Questions - -### How to get a stack trace - -``` bash -$ kill -QUIT $PID -``` - -### How to get etcd version - -``` bash -$ etcd --version -``` - -### How to get etcd configuration and log when it runs as systemd service ‘etcd2.service’ - -``` bash -$ sudo systemctl cat etcd2 -$ sudo journalctl -u etcd2 -``` - -Due to an upstream systemd bug, journald may miss the last few log lines when its process exit. If journalctl tells you that etcd stops without fatal or panic message, you could try `sudo journalctl -f -t etcd2` to get full log. - -[etcd-issue]: https://github.com/coreos/etcd/issues/new -[filing-good-bugs]: http://fantasai.inkedblade.net/style/talks/filing-good-bugs/ diff --git a/Documentation/v2/runtime-configuration.md b/Documentation/v2/runtime-configuration.md deleted file mode 100644 index a6b57b916..000000000 --- a/Documentation/v2/runtime-configuration.md +++ /dev/null @@ -1,189 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Runtime Reconfiguration - -etcd comes with support for incremental runtime reconfiguration, which allows users to update the membership of the cluster at run time. - -Reconfiguration requests can only be processed when the majority of the cluster members are functioning. It is **highly recommended** to always have a cluster size greater than two in production. It is unsafe to remove a member from a two member cluster. The majority of a two member cluster is also two. If there is a failure during the removal process, the cluster might not able to make progress and need to [restart from majority failure][majority failure]. - -To better understand the design behind runtime reconfiguration, we suggest you read [the runtime reconfiguration document][runtime-reconf]. - -## Reconfiguration Use Cases - -Let's walk through some common reasons for reconfiguring a cluster. Most of these just involve combinations of adding or removing a member, which are explained below under [Cluster Reconfiguration Operations][cluster-reconf]. - -### Cycle or Upgrade Multiple Machines - -If you need to move multiple members of your cluster due to planned maintenance (hardware upgrades, network downtime, etc.), it is recommended to modify members one at a time. - -It is safe to remove the leader, however there is a brief period of downtime while the election process takes place. If your cluster holds more than 50MB, it is recommended to [migrate the member's data directory][member migration]. - -### Change the Cluster Size - -Increasing the cluster size can enhance [failure tolerance][fault tolerance table] and provide better read performance. Since clients can read from any member, increasing the number of members increases the overall read throughput. - -Decreasing the cluster size can improve the write performance of a cluster, with a trade-off of decreased resilience. Writes into the cluster are replicated to a majority of members of the cluster before considered committed. Decreasing the cluster size lowers the majority, and each write is committed more quickly. - -### Replace A Failed Machine - -If a machine fails due to hardware failure, data directory corruption, or some other fatal situation, it should be replaced as soon as possible. Machines that have failed but haven't been removed adversely affect your quorum and reduce the tolerance for an additional failure. - -To replace the machine, follow the instructions for [removing the member][remove member] from the cluster, and then [add a new member][add member] in its place. If your cluster holds more than 50MB, it is recommended to [migrate the failed member's data directory][member migration] if you can still access it. - -### Restart Cluster from Majority Failure - -If the majority of your cluster is lost or all of your nodes have changed IP addresses, then you need to take manual action in order to recover safely. -The basic steps in the recovery process include [creating a new cluster using the old data][disaster recovery], forcing a single member to act as the leader, and finally using runtime configuration to [add new members][add member] to this new cluster one at a time. - -## Cluster Reconfiguration Operations - -Now that we have the use cases in mind, let us lay out the operations involved in each. - -Before making any change, the simple majority (quorum) of etcd members must be available. -This is essentially the same requirement as for any other write to etcd. - -All changes to the cluster are done one at a time: - -* To update a single member peerURLs you will make an update operation -* To replace a single member you will make an add then a remove operation -* To increase from 3 to 5 members you will make two add operations -* To decrease from 5 to 3 you will make two remove operations - -All of these examples will use the `etcdctl` command line tool that ships with etcd. -If you want to use the members API directly you can find the documentation [here][member-api]. - -### Update a Member - -#### Update advertise client URLs - -If you would like to update the advertise client URLs of a member, you can simply restart -that member with updated client urls flag (`--advertise-client-urls`) or environment variable -(`ETCD_ADVERTISE_CLIENT_URLS`). The restarted member will self publish the updated URLs. -A wrongly updated client URL will not affect the health of the etcd cluster. - -#### Update advertise peer URLs - -If you would like to update the advertise peer URLs of a member, you have to first update -it explicitly via member command and then restart the member. The additional action is required -since updating peer URLs changes the cluster wide configuration and can affect the health of the etcd cluster. - -To update the peer URLs, first, we need to find the target member's ID. You can list all members with `etcdctl`: - -```sh -$ etcdctl member list -6e3bd23ae5f1eae0: name=node2 peerURLs=http://localhost:23802 clientURLs=http://127.0.0.1:23792 -924e2e83e93f2560: name=node3 peerURLs=http://localhost:23803 clientURLs=http://127.0.0.1:23793 -a8266ecf031671f3: name=node1 peerURLs=http://localhost:23801 clientURLs=http://127.0.0.1:23791 -``` - -In this example let's `update` a8266ecf031671f3 member ID and change its peerURLs value to http://10.0.1.10:2380 - -```sh -$ etcdctl member update a8266ecf031671f3 http://10.0.1.10:2380 -Updated member with ID a8266ecf031671f3 in cluster -``` - -### Remove a Member - -Let us say the member ID we want to remove is a8266ecf031671f3. -We then use the `remove` command to perform the removal: - -```sh -$ etcdctl member remove a8266ecf031671f3 -Removed member a8266ecf031671f3 from cluster -``` - -The target member will stop itself at this point and print out the removal in the log: - -``` -etcd: this member has been permanently removed from the cluster. Exiting. -``` - -It is safe to remove the leader, however the cluster will be inactive while a new leader is elected. This duration is normally the period of election timeout plus the voting process. - -### Add a New Member - -Adding a member is a two step process: - - * Add the new member to the cluster via the [members API][member-api] or the `etcdctl member add` command. - * Start the new member with the new cluster configuration, including a list of the updated members (existing members + the new member). - -Using `etcdctl` let's add the new member to the cluster by specifying its [name][conf-name] and [advertised peer URLs][conf-adv-peer]: - -```sh -$ etcdctl member add infra3 http://10.0.1.13:2380 -added member 9bf1b35fc7761a23 to cluster - -ETCD_NAME="infra3" -ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380,infra3=http://10.0.1.13:2380" -ETCD_INITIAL_CLUSTER_STATE=existing -``` - -`etcdctl` has informed the cluster about the new member and printed out the environment variables needed to successfully start it. -Now start the new etcd process with the relevant flags for the new member: - -```sh -$ export ETCD_NAME="infra3" -$ export ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380,infra3=http://10.0.1.13:2380" -$ export ETCD_INITIAL_CLUSTER_STATE=existing -$ etcd -listen-client-urls http://10.0.1.13:2379 -advertise-client-urls http://10.0.1.13:2379 -listen-peer-urls http://10.0.1.13:2380 -initial-advertise-peer-urls http://10.0.1.13:2380 -data-dir %data_dir% -``` - -The new member will run as a part of the cluster and immediately begin catching up with the rest of the cluster. - -If you are adding multiple members the best practice is to configure a single member at a time and verify it starts correctly before adding more new members. -If you add a new member to a 1-node cluster, the cluster cannot make progress before the new member starts because it needs two members as majority to agree on the consensus. You will only see this behavior between the time `etcdctl member add` informs the cluster about the new member and the new member successfully establishing a connection to the existing one. - -#### Error Cases When Adding Members - -In the following case we have not included our new host in the list of enumerated nodes. -If this is a new cluster, the node must be added to the list of initial cluster members. - -```sh -$ etcd -name infra3 \ - -initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \ - -initial-cluster-state existing -etcdserver: assign ids error: the member count is unequal -exit 1 -``` - -In this case we give a different address (10.0.1.14:2380) to the one that we used to join the cluster (10.0.1.13:2380). - -```sh -$ etcd -name infra4 \ - -initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380,infra4=http://10.0.1.14:2380 \ - -initial-cluster-state existing -etcdserver: assign ids error: unmatched member while checking PeerURLs -exit 1 -``` - -When we start etcd using the data directory of a removed member, etcd will exit automatically if it connects to any active member in the cluster: - -```sh -$ etcd -etcd: this member has been permanently removed from the cluster. Exiting. -exit 1 -``` - -### Strict Reconfiguration Check Mode (`-strict-reconfig-check`) - -As described in the above, the best practice of adding new members is to configure a single member at a time and verify it starts correctly before adding more new members. This step by step approach is very important because if newly added members is not configured correctly (for example the peer URLs are incorrect), the cluster can lose quorum. The quorum loss happens since the newly added member are counted in the quorum even if that member is not reachable from other existing members. Also quorum loss might happen if there is a connectivity issue or there are operational issues. - -For avoiding this problem, etcd provides an option `-strict-reconfig-check`. If this option is passed to etcd, etcd rejects reconfiguration requests if the number of started members will be less than a quorum of the reconfigured cluster. - -It is recommended to enable this option. However, it is disabled by default because of keeping compatibility. - -[add member]: #add-a-new-member -[cluster-reconf]: #cluster-reconfiguration-operations -[conf-adv-peer]: configuration.md#-initial-advertise-peer-urls -[conf-name]: configuration.md#-name -[disaster recovery]: admin_guide.md#disaster-recovery -[fault tolerance table]: admin_guide.md#fault-tolerance-table -[majority failure]: #restart-cluster-from-majority-failure -[member-api]: members_api.md -[member migration]: admin_guide.md#member-migration -[remove member]: #remove-a-member -[runtime-reconf]: runtime-reconf-design.md diff --git a/Documentation/v2/runtime-reconf-design.md b/Documentation/v2/runtime-reconf-design.md deleted file mode 100644 index 6ee9bd6b3..000000000 --- a/Documentation/v2/runtime-reconf-design.md +++ /dev/null @@ -1,55 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Design of Runtime Reconfiguration - -Runtime reconfiguration is one of the hardest and most error prone features in a distributed system, especially in a consensus based system like etcd. - -Read on to learn about the design of etcd's runtime reconfiguration commands and how we tackled these problems. - -## Two Phase Config Changes Keep you Safe - -In etcd, every runtime reconfiguration has to go through [two phases][add-member] for safety reasons. For example, to add a member you need to first inform cluster of new configuration and then start the new member. - -Phase 1 - Inform cluster of new configuration - -To add a member into etcd cluster, you need to make an API call to request a new member to be added to the cluster. And this is the only way that you can add a new member into an existing cluster. The API call returns when the cluster agrees on the configuration change. - -Phase 2 - Start new member - -To join the new etcd member into the existing cluster, you need to specify the correct `initial-cluster` and set `initial-cluster-state` to `existing`. When the member starts, it will contact the existing cluster first and verify the current cluster configuration matches the expected one specified in `initial-cluster`. When the new member successfully starts, you know your cluster reached the expected configuration. - -By splitting the process into two discrete phases users are forced to be explicit regarding cluster membership changes. This actually gives users more flexibility and makes things easier to reason about. For example, if there is an attempt to add a new member with the same ID as an existing member in an etcd cluster, the action will fail immediately during phase one without impacting the running cluster. Similar protection is provided to prevent adding new members by mistake. If a new etcd member attempts to join the cluster before the cluster has accepted the configuration change, it will not be accepted by the cluster. - -Without the explicit workflow around cluster membership etcd would be vulnerable to unexpected cluster membership changes. For example, if etcd is running under an init system such as systemd, etcd would be restarted after being removed via the membership API, and attempt to rejoin the cluster on startup. This cycle would continue every time a member is removed via the API and systemd is set to restart etcd after failing, which is unexpected. - -We think runtime reconfiguration should be a low frequent operation. We made the decision to keep it explicit and user-driven to ensure configuration safety and keep your cluster always running smoothly under your control. - -## Permanent Loss of Quorum Requires New Cluster - -If a cluster permanently loses a majority of its members, a new cluster will need to be started from an old data directory to recover the previous state. - -It is entirely possible to force removing the failed members from the existing cluster to recover. However, we decided not to support this method since it bypasses the normal consensus committing phase, which is unsafe. If the member to remove is not actually dead or you force to remove different members through different members in the same cluster, you will end up with diverged cluster with same clusterID. This is very dangerous and hard to debug/fix afterwards. - -If you have a correct deployment, the possibility of permanent majority lose is very low. But it is a severe enough problem that worth special care. We strongly suggest you to read the [disaster recovery documentation][disaster-recovery] and prepare for permanent majority lose before you put etcd into production. - -## Do Not Use Public Discovery Service For Runtime Reconfiguration - -The public discovery service should only be used for bootstrapping a cluster. To join member into an existing cluster, you should use runtime reconfiguration API. - -Discovery service is designed for bootstrapping an etcd cluster in the cloud environment, when you do not know the IP addresses of all the members beforehand. After you successfully bootstrap a cluster, the IP addresses of all the members are known. Technically, you should not need the discovery service any more. - -It seems that using public discovery service is a convenient way to do runtime reconfiguration, after all discovery service already has all the cluster configuration information. However relying on public discovery service brings troubles: - -1. it introduces external dependencies for the entire life-cycle of your cluster, not just bootstrap time. If there is a network issue between your cluster and public discovery service, your cluster will suffer from it. - -2. public discovery service must reflect correct runtime configuration of your cluster during it life-cycle. It has to provide security mechanism to avoid bad actions, and it is hard. - -3. public discovery service has to keep tens of thousands of cluster configurations. Our public discovery service backend is not ready for that workload. - -If you want to have a discovery service that supports runtime reconfiguration, the best choice is to build your private one. - -[add-member]: runtime-configuration.md#add-a-new-member -[disaster-recovery]: admin_guide.md#disaster-recovery diff --git a/Documentation/v2/security.md b/Documentation/v2/security.md deleted file mode 100644 index 2fd196fd0..000000000 --- a/Documentation/v2/security.md +++ /dev/null @@ -1,199 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Security Model - -etcd supports SSL/TLS as well as authentication through client certificates, both for clients to server as well as peer (server to server / cluster) communication. - -To get up and running you first need to have a CA certificate and a signed key pair for one member. It is recommended to create and sign a new key pair for every member in a cluster. - -For convenience, the [cfssl] tool provides an easy interface to certificate generation, and we provide an example using the tool [here][tls-setup]. You can also examine this [alternative guide to generating self-signed key pairs][tls-guide]. - -## Basic setup - -etcd takes several certificate related configuration options, either through command-line flags or environment variables: - -**Client-to-server communication:** - -`--cert-file=`: Certificate used for SSL/TLS connections **to** etcd. When this option is set, you can set advertise-client-urls using HTTPS schema. - -`--key-file=`: Key for the certificate. Must be unencrypted. - -`--client-cert-auth`: When this is set etcd will check all incoming HTTPS requests for a client certificate signed by the trusted CA, requests that don't supply a valid client certificate will fail. If [authentication][auth] is enabled, the certificate provides credentials for the user name given by the Common Name field. - -`--trusted-ca-file=`: Trusted certificate authority. - -**Peer (server-to-server / cluster) communication:** - -The peer options work the same way as the client-to-server options: - -`--peer-cert-file=`: Certificate used for SSL/TLS connections between peers. This will be used both for listening on the peer address as well as sending requests to other peers. - -`--peer-key-file=`: Key for the certificate. Must be unencrypted. - -`--peer-client-cert-auth`: When set, etcd will check all incoming peer requests from the cluster for valid client certificates signed by the supplied CA. - -`--peer-trusted-ca-file=`: Trusted certificate authority. - -If either a client-to-server or peer certificate is supplied the key must also be set. All of these configuration options are also available through the environment variables, `ETCD_CA_FILE`, `ETCD_PEER_CA_FILE` and so on. - -## Example 1: Client-to-server transport security with HTTPS - -For this you need your CA certificate (`ca.crt`) and signed key pair (`server.crt`, `server.key`) ready. - -Let us configure etcd to provide simple HTTPS transport security step by step: - -```sh -$ etcd -name infra0 -data-dir infra0 \ - -cert-file=/path/to/server.crt -key-file=/path/to/server.key \ - -advertise-client-urls=https://127.0.0.1:2379 -listen-client-urls=https://127.0.0.1:2379 -``` - -This should start up fine and you can now test the configuration by speaking HTTPS to etcd: - -```sh -$ curl --cacert /path/to/ca.crt https://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -v -``` - -You should be able to see the handshake succeed. Because we use self-signed certificates with our own certificate authorities you need to provide the CA to curl using the `--cacert` option. Another possibility would be to add your CA certificate to the trusted certificates on your system (usually in `/etc/ssl/certs`). - -**OSX 10.9+ Users**: curl 7.30.0 on OSX 10.9+ doesn't understand certificates passed in on the command line. -Instead you must import the dummy ca.crt directly into the keychain or add the `-k` flag to curl to ignore errors. -If you want to test without the `-k` flag run `open ./fixtures/ca/ca.crt` and follow the prompts. -Please remove this certificate after you are done testing! -If you know of a workaround let us know. - -## Example 2: Client-to-server authentication with HTTPS client certificates - -For now we've given the etcd client the ability to verify the server identity and provide transport security. We can however also use client certificates to prevent unauthorized access to etcd. - -The clients will provide their certificates to the server and the server will check whether the cert is signed by the supplied CA and decide whether to serve the request. - -You need the same files mentioned in the first example for this, as well as a key pair for the client (`client.crt`, `client.key`) signed by the same certificate authority. - -```sh -$ etcd -name infra0 -data-dir infra0 \ - -client-cert-auth -trusted-ca-file=/path/to/ca.crt -cert-file=/path/to/server.crt -key-file=/path/to/server.key \ - -advertise-client-urls https://127.0.0.1:2379 -listen-client-urls https://127.0.0.1:2379 -``` - -Now try the same request as above to this server: - -```sh -$ curl --cacert /path/to/ca.crt https://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -v -``` - -The request should be rejected by the server: - -``` -... -routines:SSL3_READ_BYTES:sslv3 alert bad certificate -... -``` - -To make it succeed, we need to give the CA signed client certificate to the server: - -```sh -$ curl --cacert /path/to/ca.crt --cert /path/to/client.crt --key /path/to/client.key \ - -L https://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -v -``` - -You should be able to see: - -``` -... -SSLv3, TLS handshake, CERT verify (15): -... -TLS handshake, Finished (20) -``` - -And also the response from the server: - -```json -{ - "action": "set", - "node": { - "createdIndex": 12, - "key": "/foo", - "modifiedIndex": 12, - "value": "bar" - } -} -``` - -## Example 3: Transport security & client certificates in a cluster - -etcd supports the same model as above for **peer communication**, that means the communication between etcd members in a cluster. - -Assuming we have our `ca.crt` and two members with their own keypairs (`member1.crt` & `member1.key`, `member2.crt` & `member2.key`) signed by this CA, we launch etcd as follows: - - -```sh -DISCOVERY_URL=... # from https://discovery.etcd.io/new - -# member1 -$ etcd -name infra1 -data-dir infra1 \ - -peer-client-cert-auth -peer-trusted-ca-file=/path/to/ca.crt -peer-cert-file=/path/to/member1.crt -peer-key-file=/path/to/member1.key \ - -initial-advertise-peer-urls=https://10.0.1.10:2380 -listen-peer-urls=https://10.0.1.10:2380 \ - -discovery ${DISCOVERY_URL} - -# member2 -$ etcd -name infra2 -data-dir infra2 \ - -peer-client-cert-auth -peer-trusted-ca-file=/path/to/ca.crt -peer-cert-file=/path/to/member2.crt -peer-key-file=/path/to/member2.key \ - -initial-advertise-peer-urls=https://10.0.1.11:2380 -listen-peer-urls=https://10.0.1.11:2380 \ - -discovery ${DISCOVERY_URL} -``` - -The etcd members will form a cluster and all communication between members in the cluster will be encrypted and authenticated using the client certificates. You will see in the output of etcd that the addresses it connects to use HTTPS. - -## Notes For etcd Proxy - -etcd proxy terminates the TLS from its client if the connection is secure, and uses proxy's own key/cert specified in `--peer-key-file` and `--peer-cert-file` to communicate with etcd members. - -The proxy communicates with etcd members through both the `--advertise-client-urls` and `--advertise-peer-urls` of a given member. It forwards client requests to etcd members’ advertised client urls, and it syncs the initial cluster configuration through etcd members’ advertised peer urls. - -When client authentication is enabled for an etcd member, the administrator must ensure that the peer certificate specified in the proxy's `--peer-cert-file` option is valid for that authentication. The proxy's peer certificate must also be valid for peer authentication if peer authentication is enabled. - -## Frequently Asked Questions - -### My cluster is not working with peer tls configuration? - -The internal protocol of etcd v2.0.x uses a lot of short-lived HTTP connections. -So, when enabling TLS you may need to increase the heartbeat interval and election timeouts to reduce internal cluster connection churn. -A reasonable place to start are these values: ` --heartbeat-interval 500 --election-timeout 2500`. -These issues are resolved in the etcd v2.1.x series of releases which uses fewer connections. - -### I'm seeing a SSLv3 alert handshake failure when using SSL client authentication? - -The `crypto/tls` package of `golang` checks the key usage of the certificate public key before using it. -To use the certificate public key to do client auth, we need to add `clientAuth` to `Extended Key Usage` when creating the certificate public key. - -Here is how to do it: - -Add the following section to your openssl.cnf: - -``` -[ ssl_client ] -... - extendedKeyUsage = clientAuth -... -``` - -When creating the cert be sure to reference it in the `-extensions` flag: - -``` -$ openssl ca -config openssl.cnf -policy policy_anything -extensions ssl_client -out certs/machine.crt -infiles machine.csr -``` - -### With peer certificate authentication I receive "certificate is valid for 127.0.0.1, not $MY_IP" -Make sure that you sign your certificates with a Subject Name your member's public IP address. The `etcd-ca` tool for example provides an `--ip=` option for its `new-cert` command. - -If you need your certificate to be signed for your member's FQDN in its Subject Name then you could use Subject Alternative Names (short IP SANs) to add your IP address. The `etcd-ca` tool provides `--domain=` option for its `new-cert` command, and openssl can make [it][alt-name] too. - -[cfssl]: https://github.com/cloudflare/cfssl -[tls-setup]: ../../hack/tls-setup -[tls-guide]: https://github.com/coreos/docs/blob/master/os/generate-self-signed-certificates.md -[alt-name]: http://wiki.cacert.org/FAQ/subjectAltName -[auth]: authentication.md diff --git a/Documentation/v2/tuning.md b/Documentation/v2/tuning.md deleted file mode 100644 index 290e887cd..000000000 --- a/Documentation/v2/tuning.md +++ /dev/null @@ -1,80 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Tuning - -The default settings in etcd should work well for installations on a local network where the average network latency is low. -However, when using etcd across multiple data centers or over networks with high latency you may need to tweak the heartbeat interval and election timeout settings. - -The network isn't the only source of latency. Each request and response may be impacted by slow disks on both the leader and follower. Each of these timeouts represents the total time from request to successful response from the other machine. - -## Time Parameters - -The underlying distributed consensus protocol relies on two separate time parameters to ensure that nodes can handoff leadership if one stalls or goes offline. -The first parameter is called the *Heartbeat Interval*. -This is the frequency with which the leader will notify followers that it is still the leader. -For best practices, the parameter should be set around round-trip time between members. -By default, etcd uses a `100ms` heartbeat interval. - -The second parameter is the *Election Timeout*. -This timeout is how long a follower node will go without hearing a heartbeat before attempting to become leader itself. -By default, etcd uses a `1000ms` election timeout. - -Adjusting these values is a trade off. -The value of heartbeat interval is recommended to be around the maximum of average round-trip time (RTT) between members, normally around 0.5-1.5x the round-trip time. -If heartbeat interval is too low, etcd will send unnecessary messages that increase the usage of CPU and network resources. -On the other side, a too high heartbeat interval leads to high election timeout. Higher election timeout takes longer time to detect a leader failure. -The easiest way to measure round-trip time (RTT) is to use [PING utility][ping]. - -The election timeout should be set based on the heartbeat interval and average round-trip time between members. -Election timeouts must be at least 10 times the round-trip time so it can account for variance in your network. -For example, if the round-trip time between your members is 10ms then you should have at least a 100ms election timeout. - -You should also set your election timeout to at least 5 to 10 times your heartbeat interval to account for variance in leader replication. -For a heartbeat interval of 50ms you should set your election timeout to at least 250ms - 500ms. - -The upper limit of election timeout is 50000ms (50s), which should only be used when deploying a globally-distributed etcd cluster. -A reasonable round-trip time for the continental United States is 130ms, and the time between US and Japan is around 350-400ms. -If your network has uneven performance or regular packet delays/loss then it is possible that a couple of retries may be necessary to successfully send a packet. So 5s is a safe upper limit of global round-trip time. -As the election timeout should be an order of magnitude bigger than broadcast time, in the case of ~5s for a globally distributed cluster, then 50 seconds becomes a reasonable maximum. - -The heartbeat interval and election timeout value should be the same for all members in one cluster. Setting different values for etcd members may disrupt cluster stability. - -You can override the default values on the command line: - -```sh -# Command line arguments: -$ etcd -heartbeat-interval=100 -election-timeout=500 - -# Environment variables: -$ ETCD_HEARTBEAT_INTERVAL=100 ETCD_ELECTION_TIMEOUT=500 etcd -``` - -The values are specified in milliseconds. - -## Snapshots - -etcd appends all key changes to a log file. -This log grows forever and is a complete linear history of every change made to the keys. -A complete history works well for lightly used clusters but clusters that are heavily used would carry around a large log. - -To avoid having a huge log etcd makes periodic snapshots. -These snapshots provide a way for etcd to compact the log by saving the current state of the system and removing old logs. - -### Snapshot Tuning - -Creating snapshots can be expensive so they're only created after a given number of changes to etcd. -By default, snapshots will be made after every 10,000 changes. -If etcd's memory usage and disk usage are too high, you can lower the snapshot threshold by setting the following on the command line: - -```sh -# Command line arguments: -$ etcd -snapshot-count=5000 - -# Environment variables: -$ ETCD_SNAPSHOT_COUNT=5000 etcd -``` - -[ping]: https://en.wikipedia.org/wiki/Ping_(networking_utility) diff --git a/Documentation/v2/upgrade_2_1.md b/Documentation/v2/upgrade_2_1.md deleted file mode 100644 index 07ce35776..000000000 --- a/Documentation/v2/upgrade_2_1.md +++ /dev/null @@ -1,121 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Upgrade etcd to 2.1 - -In the general case, upgrading from etcd 2.0 to 2.1 can be a zero-downtime, rolling upgrade: - - one by one, stop the etcd v2.0 processes and replace them with etcd v2.1 processes - - after you are running all v2.1 processes, new features in v2.1 are available to the cluster - -Before [starting an upgrade](#upgrade-procedure), read through the rest of this guide to prepare. - -## Upgrade Checklists - -### Upgrade Requirements - -To upgrade an existing etcd deployment to 2.1, you must be running 2.0. If you’re running a version of etcd before 2.0, you must upgrade to [2.0][v2.0] before upgrading to 2.1. - -Also, to ensure a smooth rolling upgrade, your running cluster must be healthy. You can check the health of the cluster by using `etcdctl cluster-health` command. - -### Preparedness - -Before upgrading etcd, always test the services relying on etcd in a staging environment before deploying the upgrade to the production environment. - -You might also want to [backup your data directory][backup-datastore] for a potential [downgrade](#downgrade). - -etcd 2.1 introduces a new [authentication][auth] feature, which is disabled by default. If your deployment depends on these, you may want to test the auth features before enabling them in production. - -### Mixed Versions - -While upgrading, an etcd cluster supports mixed versions of etcd members. The cluster is only considered upgraded once all its members are upgraded to 2.1. - -Internally, etcd members negotiate with each other to determine the overall etcd cluster version, which controls the reported cluster version and the supported features. For example, if you are mid-upgrade, any 2.1 features (such as the the authentication feature mentioned above) won’t be available. - -### Limitations - -If you encounter any issues during the upgrade, you can attempt to restart the etcd process in trouble using a newer v2.1 binary to solve the problem. One known issue is that etcd v2.0.0 and v2.0.2 may panic during rolling upgrades due to an existing bug, which has been fixed since etcd v2.0.3. - -It might take up to 2 minutes for the newly upgraded member to catch up with the existing cluster when the total data size is larger than 50MB (You can check the size of the existing snapshot to know about the rough data size). In other words, it is safest to wait for 2 minutes before upgrading the next member. - -If you have even more data, this might take more time. If you have a data size larger than 100MB you should contact us before upgrading, so we can make sure the upgrades work smoothly. - -### Downgrade - -If all members have been upgraded to v2.1, the cluster will be upgraded to v2.1, and downgrade is **not possible**. If any member is still v2.0, the cluster will remain in v2.0, and you can go back to use v2.0 binary. - -Please [backup your data directory][backup-datastore] of all etcd members if you want to downgrade the cluster, even if it is upgraded. - -### Upgrade Procedure - -#### 1. Check upgrade requirements. - -``` -$ etcdctl cluster-health -cluster is healthy -member 6e3bd23ae5f1eae0 is healthy -member 924e2e83e93f2560 is healthy -member a8266ecf031671f3 is healthy - -$ curl http://127.0.0.1:4001/version -etcd 2.0.x -``` - -#### 2. Stop the existing etcd process - -You will see similar error logging from other etcd processes in your cluster. This is normal, since you just shut down a member. - -``` -2015/06/23 15:45:09 sender: error posting to 6e3bd23ae5f1eae0: dial tcp 127.0.0.1:7002: connection refused -2015/06/23 15:45:09 sender: the connection with 6e3bd23ae5f1eae0 became inactive -2015/06/23 15:45:11 rafthttp: encountered error writing to server log stream: write tcp 127.0.0.1:53783: broken pipe -2015/06/23 15:45:11 rafthttp: server streaming to 6e3bd23ae5f1eae0 at term 2 has been stopped -2015/06/23 15:45:11 stream: error sending message: stopped -2015/06/23 15:45:11 stream: stopping the stream server... -``` - -You could [backup your data directory][backup-datastore] for data safety. - -``` -$ etcdctl backup \ - --data-dir /var/lib/etcd \ - --backup-dir /tmp/etcd_backup -``` - -#### 3. Drop-in etcd v2.1 binary and start the new etcd process - -You will see the etcd publish its information to the cluster. - -``` -2015/06/23 15:45:39 etcdserver: published {Name:infra2 ClientURLs:[http://localhost:4002]} to cluster e9c7614f68f35fb2 -``` - -You could verify the cluster becomes healthy. - -``` -$ etcdctl cluster-health -cluster is healthy -member 6e3bd23ae5f1eae0 is healthy -member 924e2e83e93f2560 is healthy -member a8266ecf031671f3 is healthy -``` - -#### 4. Repeat step 2 to step 3 for all other members - -#### 5. Finish - -When all members are upgraded, you will see the cluster is upgraded to 2.1 successfully: - -``` -2015/06/23 15:46:35 etcdserver: updated the cluster version from 2.0.0 to 2.1.0 -``` - -``` -$ curl http://127.0.0.1:4001/version -{"etcdserver":"2.1.x","etcdcluster":"2.1.0"} -``` - -[auth]: auth_api.md -[backup-datastore]: admin_guide.md#backing-up-the-datastore -[v2.0]: https://github.com/coreos/etcd/releases/tag/v2.0.13 diff --git a/Documentation/v2/upgrade_2_2.md b/Documentation/v2/upgrade_2_2.md deleted file mode 100644 index 76fcf811e..000000000 --- a/Documentation/v2/upgrade_2_2.md +++ /dev/null @@ -1,137 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -# Upgrade etcd from 2.1 to 2.2 - -In the general case, upgrading from etcd 2.1 to 2.2 can be a zero-downtime, rolling upgrade: - - - one by one, stop the etcd v2.1 processes and replace them with etcd v2.2 processes - - after you are running all v2.2 processes, new features in v2.2 are available to the cluster - -Before [starting an upgrade](#upgrade-procedure), read through the rest of this guide to prepare. - -## Upgrade Checklists - -### Upgrade Requirement - -To upgrade an existing etcd deployment to 2.2, you must be running 2.1. If you’re running a version of etcd before 2.1, you must upgrade to [2.1][v2.1] before upgrading to 2.2. - -Also, to ensure a smooth rolling upgrade, your running cluster must be healthy. You can check the health of the cluster by using `etcdctl cluster-health` command. - -### Preparedness - -Before upgrading etcd, always test the services relying on etcd in a staging environment before deploying the upgrade to the production environment. - -You might also want to [backup the data directory][backup-datastore] for a potential [downgrade]. - -### Mixed Versions - -While upgrading, an etcd cluster supports mixed versions of etcd members. The cluster is only considered upgraded once all its members are upgraded to 2.2. - -Internally, etcd members negotiate with each other to determine the overall etcd cluster version, which controls the reported cluster version and the supported features. - -### Limitations - -If you have a data size larger than 100MB you should contact us before upgrading, so we can make sure the upgrades work smoothly. - -Every etcd 2.2 member will do health checking across the cluster periodically. etcd 2.1 member does not support health checking. During the upgrade, etcd 2.2 member will log warning about the unhealthy state of etcd 2.1 member. You can ignore the warning. - -### Downgrade - -If all members have been upgraded to v2.2, the cluster will be upgraded to v2.2, and downgrade is **not possible**. If any member is still v2.1, the cluster will remain in v2.1, and you can go back to use v2.1 binary. - -Please [backup the data directory][backup-datastore] of all etcd members if you want to downgrade the cluster, even if it is upgraded. - -### Upgrade Procedure - -In the example, we upgrade a three member v2.1 cluster running on local machine. - -#### 1. Check upgrade requirements. - -``` -$ etcdctl cluster-health -member 6e3bd23ae5f1eae0 is healthy: got healthy result from http://localhost:22379 -member 924e2e83e93f2560 is healthy: got healthy result from http://localhost:32379 -member a8266ecf031671f3 is healthy: got healthy result from http://localhost:12379 -cluster is healthy - -$ curl http://localhost:4001/version -{"etcdserver":"2.1.x","etcdcluster":"2.1.0"} -``` - -#### 2. Stop the existing etcd process - -You will see similar error logging from other etcd processes in your cluster. This is normal, since you just shut down a member and the connection is broken. - -``` -2015/09/2 09:48:35 etcdserver: failed to reach the peerURL(http://localhost:12380) of member a8266ecf031671f3 (Get http://localhost:12380/version: dial tcp [::1]:12380: getsockopt: connection refused) -2015/09/2 09:48:35 etcdserver: cannot get the version of member a8266ecf031671f3 (Get http://localhost:12380/version: dial tcp [::1]:12380: getsockopt: connection refused) -2015/09/2 09:48:35 rafthttp: failed to write a8266ecf031671f3 on stream Message (write tcp 127.0.0.1:32380->127.0.0.1:64394: write: broken pipe) -2015/09/2 09:48:35 rafthttp: failed to write a8266ecf031671f3 on pipeline (dial tcp [::1]:12380: getsockopt: connection refused) -2015/09/2 09:48:40 etcdserver: failed to reach the peerURL(http://localhost:7001) of member a8266ecf031671f3 (Get http://localhost:7001/version: dial tcp [::1]:12380: getsockopt: connection refused) -2015/09/2 09:48:40 etcdserver: cannot get the version of member a8266ecf031671f3 (Get http://localhost:12380/version: dial tcp [::1]:12380: getsockopt: connection refused) -2015/09/2 09:48:40 rafthttp: failed to heartbeat a8266ecf031671f3 on stream MsgApp v2 (write tcp 127.0.0.1:32380->127.0.0.1:64393: write: broken pipe) -``` - -You will see logging output like this from ungraded member due to a mixed version cluster. You can ignore this while upgrading. - -``` -2015/09/2 09:48:45 etcdserver: the etcd version 2.1.2+git is not up-to-date -2015/09/2 09:48:45 etcdserver: member a8266ecf031671f3 has a higher version &{2.2.0-rc.0+git 2.1.0} -``` - -You will also see logging output like this from the newly upgraded member, since etcd 2.1 member does not support health checking. You can ignore this while upgrading. - -``` -2015-09-02 09:55:42.691384 W | rafthttp: the connection to peer 6e3bd23ae5f1eae0 is unhealthy -2015-09-02 09:55:42.705626 W | rafthttp: the connection to peer 924e2e83e93f2560 is unhealthy - -``` - -[Backup your data directory][backup-datastore] for data safety. - -``` -$ etcdctl backup \ - --data-dir /var/lib/etcd \ - --backup-dir /tmp/etcd_backup -``` - -#### 3. Drop-in etcd v2.2 binary and start the new etcd process - -Now, you can start the etcd v2.2 binary with the previous configuration. -You will see the etcd start and publish its information to the cluster. - -``` -2015-09-02 09:56:46.117609 I | etcdserver: published {Name:infra2 ClientURLs:[http://localhost:22380]} to cluster e9c7614f68f35fb2 -``` - -You could verify the cluster becomes healthy. - -``` -$ etcdctl cluster-health -member 6e3bd23ae5f1eae0 is healthy: got healthy result from http://localhost:22379 -member 924e2e83e93f2560 is healthy: got healthy result from http://localhost:32379 -member a8266ecf031671f3 is healthy: got healthy result from http://localhost:12379 -cluster is healthy -``` - -#### 4. Repeat step 2 to step 3 for all other members - -#### 5. Finish - -When all members are upgraded, you will see the cluster is upgraded to 2.2 successfully: - -``` -2015-09-02 09:56:54.896848 N | etcdserver: updated the cluster version from 2.1 to 2.2 -``` - -``` -$ curl http://127.0.0.1:4001/version -{"etcdserver":"2.2.x","etcdcluster":"2.2.0"} -``` - -[backup-datastore]: admin_guide.md#backing-up-the-datastore -[downgrade]: #downgrade -[v2.1]: https://github.com/coreos/etcd/releases/tag/v2.1.2 diff --git a/Documentation/v2/upgrade_2_3.md b/Documentation/v2/upgrade_2_3.md deleted file mode 100644 index 95ddbbf41..000000000 --- a/Documentation/v2/upgrade_2_3.md +++ /dev/null @@ -1,126 +0,0 @@ -**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.** - -[v3-docs]: ../docs.md#documentation - - -## Upgrade etcd from 2.2 to 2.3 - -In the general case, upgrading from etcd 2.2 to 2.3 can be a zero-downtime, rolling upgrade: - - one by one, stop the etcd v2.2 processes and replace them with etcd v2.3 processes - - after running all v2.3 processes, new features in v2.3 are available to the cluster - -Before [starting an upgrade](#upgrade-procedure), read through the rest of this guide to prepare. - -### Upgrade Checklists - -#### Upgrade Requirements - -To upgrade an existing etcd deployment to 2.3, the running cluster must be 2.2 or greater. If it's before 2.2, please upgrade to [2.2](https://github.com/coreos/etcd/releases/tag/v2.2.0) before upgrading to 2.3. - -Also, to ensure a smooth rolling upgrade, the running cluster must be healthy. You can check the health of the cluster by using the `etcdctl cluster-health` command. - -#### Preparation - -Before upgrading etcd, always test the services relying on etcd in a staging environment before deploying the upgrade to the production environment. - -Before beginning, [backup the etcd data directory](admin_guide.md#backing-up-the-datastore). Should something go wrong with the upgrade, it is possible to use this backup to[downgrade](#downgrade) back to existing etcd version. - -#### Mixed Versions - -While upgrading, an etcd cluster supports mixed versions of etcd members, and operates with the protocol of the lowest common version. The cluster is only considered upgraded once all of its members are upgraded to version 2.3. Internally, etcd members negotiate with each other to determine the overall cluster version, which controls the reported version and the supported features. - -#### Limitations - -It might take up to 2 minutes for the newly upgraded member to catch up with the existing cluster when the total data size is larger than 50MB. Check the size of a recent snapshot to estimate the total data size. In other words, it is safest to wait for 2 minutes between upgrading each member. - -For a much larger total data size, 100MB or more , this one-time process might take even more time. Administrators of very large etcd clusters of this magnitude can feel free to contact the [etcd team][etcd-contact] before upgrading, and we’ll be happy to provide advice on the procedure. - -#### Downgrade - -If all members have been upgraded to v2.3, the cluster will be upgraded to v2.3, and downgrade from this completed state is **not possible**. If any single member is still v2.2, however, the cluster and its operations remains “v2.2”, and it is possible from this mixed cluster state to return to using a v2.2 etcd binary on all members. - -Please [backup the data directory](admin_guide.md#backing-up-the-datastore) of all etcd members to make downgrading the cluster possible even after it has been completely upgraded. - -### Upgrade Procedure - - -This example details the upgrade of a three-member v2.2 ectd cluster running on a local machine. - -#### 1. Check upgrade requirements. - -Is the the cluster healthy and running v.2.2.x? - -``` -$ etcdctl cluster-health -member 6e3bd23ae5f1eae0 is healthy: got healthy result from http://localhost:22379 -member 924e2e83e93f2560 is healthy: got healthy result from http://localhost:32379 -member a8266ecf031671f3 is healthy: got healthy result from http://localhost:12379 -cluster is healthy - -$ curl http://localhost:4001/version -{"etcdserver":"2.2.x","etcdcluster":"2.2.0"} -``` - -#### 2. Stop the existing etcd process - -When each etcd process is stopped, expected errors will be logged by other cluster members. This is normal since a cluster member connection has been (temporarily) broken: - -``` -2016-03-11 09:50:49.860319 E | rafthttp: failed to read 8211f1d0f64f3269 on stream Message (unexpected EOF) -2016-03-11 09:50:49.860335 I | rafthttp: the connection with 8211f1d0f64f3269 became inactive -2016-03-11 09:50:51.023804 W | etcdserver: failed to reach the peerURL(http://127.0.0.1:12380) of member 8211f1d0f64f3269 (Get http://127.0.0.1:12380/version: dial tcp 127.0.0.1:12380: getsockopt: connection refused) -2016-03-11 09:50:51.023821 W | etcdserver: cannot get the version of member 8211f1d0f64f3269 (Get http://127.0.0.1:12380/version: dial tcp 127.0.0.1:12380: getsockopt: connection refused) -``` - -It’s a good idea at this point to [backup the etcd data directory](https://github.com/coreos/etcd/blob/7f7e2cc79d9c5c342a6eb1e48c386b0223cf934e/Documentation/admin_guide.md#backing-up-the-datastore) to provide a downgrade path should any problems occur: - -``` -$ etcdctl backup \ - --data-dir /var/lib/etcd \ - --backup-dir /tmp/etcd_backup -``` - -#### 3. Drop-in etcd v2.3 binary and start the new etcd process - -The new v2.3 etcd will publish its information to the cluster: - -``` -09:58:25.938673 I | etcdserver: published {Name:infra1 ClientURLs:[http://localhost:12379]} to cluster 524400597fb1d5f6 -``` - -Verify that each member, and then the entire cluster, becomes healthy with the new v2.3 etcd binary: - -``` -$ etcdctl cluster-health -member 6e3bd23ae5f1eae0 is healthy: got healthy result from http://localhost:22379 -member 924e2e83e93f2560 is healthy: got healthy result from http://localhost:32379 -member a8266ecf031671f3 is healthy: got healthy result from http://localhost:12379 -cluster is healthy -``` - - -Upgraded members will log warnings like the following until the entire cluster is upgraded. This is expected and will cease after all etcd cluster members are upgraded to v2.3: - -``` -2016-03-11 09:58:26.851837 W | etcdserver: the local etcd version 2.2.0 is not up-to-date -2016-03-11 09:58:26.851854 W | etcdserver: member c02c70ede158499f has a higher version 2.3.0 -``` - -#### 4. Repeat step 2 to step 3 for all other members - -#### 5. Finish - -When all members are upgraded, the cluster will report upgrading to 2.3 successfully: - -``` -2016-03-11 10:03:01.583392 N | etcdserver: updated the cluster version from 2.2 to 2.3 -``` - -``` -$ curl http://127.0.0.1:4001/version -{"etcdserver":"2.3.x","etcdcluster":"2.3.0"} -``` - - -[etcd-contact]: https://coreos.com/etcd/? -