diff --git a/Documentation/docs.md b/Documentation/docs.md index e011718ec..b39a6eac5 100644 --- a/Documentation/docs.md +++ b/Documentation/docs.md @@ -42,6 +42,7 @@ Administrators who need to create reliable and scalable key-value stores for the - [Supported systems][supported_platforms] - [Docker container][container_docker] + - [Container Linux, systemd][container_linux_platform] - [rkt container][container_rkt] - [Amazon Web Services][aws_platform] - [FreeBSD][freebsd_platform] @@ -101,6 +102,7 @@ Answers to [common questions] about etcd. [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 diff --git a/Documentation/platforms/container-linux-systemd.md b/Documentation/platforms/container-linux-systemd.md new file mode 100644 index 000000000..b8234e86c --- /dev/null +++ b/Documentation/platforms/container-linux-systemd.md @@ -0,0 +1,203 @@ +# Run etcd on Container Linux with systemd + +The following guide shows how to run etcd with [systemd][systemd-docs] under [Container Linux][container-linux-docs]. + +## Provisioning an etcd cluster + +Cluster bootstrapping in Container Linux is simplest with [Ignition][container-linux-ignition]; `coreos-metadata.service` dynamically fetches the machine's IP for discovery. Note that etcd's discovery service protocol is only meant for bootstrapping, and cannot be used with runtime reconfiguration or cluster monitoring. + +The [Container Linux Config Transpiler][container-linux-ct] compiles etcd configuration files into Ignition configuration files: + +```yaml container-linux-config:norender +etcd: + version: 3.2.0 + name: s1 + data_dir: /var/lib/etcd + advertise_client_urls: http://{PUBLIC_IPV4}:2379 + initial_advertise_peer_urls: http://{PRIVATE_IPV4}:2380 + listen_client_urls: http://0.0.0.0:2379 + listen_peer_urls: http://{PRIVATE_IPV4}:2380 + discovery: https://discovery.etcd.io/ +``` + +`ct` would produce the following Ignition Config: + +``` +$ ct --platform=gce --in-file /tmp/ct-etcd.cnf +{"ignition":{"version":"2.0.0","config"... +``` + +```json ignition-config +{ + "ignition":{"version":"2.0.0","config":{}}, + "storage":{}, + "systemd":{ + "units":[{ + "name":"etcd-member.service", + "enable":true, + "dropins":[{ + "name":"20-clct-etcd-member.conf", + "contents":"[Unit]\nRequires=coreos-metadata.service\nAfter=coreos-metadata.service\n\n[Service]\nEnvironmentFile=/run/metadata/coreos\nEnvironment=\"ETCD_IMAGE_TAG=v3.1.8\"\nExecStart=\nExecStart=/usr/lib/coreos/etcd-wrapper $ETCD_OPTS \\\n --name=\"s1\" \\\n --data-dir=\"/var/lib/etcd\" \\\n --listen-peer-urls=\"http://${COREOS_GCE_IP_LOCAL_0}:2380\" \\\n --listen-client-urls=\"http://0.0.0.0:2379\" \\\n --initial-advertise-peer-urls=\"http://${COREOS_GCE_IP_LOCAL_0}:2380\" \\\n --advertise-client-urls=\"http://${COREOS_GCE_IP_EXTERNAL_0}:2379\" \\\n --discovery=\"https://discovery.etcd.io/\u003ctoken\u003e\""}]}]}, + "networkd":{}, + "passwd":{}} +``` + +To avoid accidental misconfiguration, the transpiler helpfully verifies etcd configurations when generating Ignition files: + +```yaml container-linux-config:norender +etcd: + version: 3.2.0 + name: s1 + data_dir_x: /var/lib/etcd + advertise_client_urls: http://{PUBLIC_IPV4}:2379 + initial_advertise_peer_urls: http://{PRIVATE_IPV4}:2380 + listen_client_urls: http://0.0.0.0:2379 + listen_peer_urls: http://{PRIVATE_IPV4}:2380 + discovery: https://discovery.etcd.io/ +``` + +``` +$ ct --platform=gce --in-file /tmp/ct-etcd.cnf +warning at line 3, column 2 +Config has unrecognized key: data_dir_x +``` + +See [Container Linux Provisioning][container-linux-provision] for more details. + +## etcd 3.x service + +[Container Linux][container-linux-docs] does not include etcd 3.x binaries by default. Different versions of etcd 3.x can be fetched via `etcd-member.service`. + +Confirm unit file exists: + +``` +systemctl cat etcd-member.service +``` + +Check if the etcd service is running: + +``` +systemctl status etcd-member.service +``` + +Example systemd drop-in unit to override the default service settings: + +```bash +cat > /tmp/20-cl-etcd-member.conf <