From 94a242cc58c2d70889f7f477e2d755373e6e386f Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Mon, 30 Mar 2015 12:25:00 -0700 Subject: [PATCH] config: add support for etcd2 --- config/config.go | 1 + config/etcd2.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ initialize/config.go | 1 + system/etcd2.go | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 config/etcd2.go create mode 100644 system/etcd2.go diff --git a/config/config.go b/config/config.go index bb1d771..441e1ed 100644 --- a/config/config.go +++ b/config/config.go @@ -37,6 +37,7 @@ type CloudConfig struct { type CoreOS struct { Etcd Etcd `yaml:"etcd"` + Etcd2 Etcd2 `yaml:"etcd2"` Flannel Flannel `yaml:"flannel"` Fleet Fleet `yaml:"fleet"` Locksmith Locksmith `yaml:"locksmith"` diff --git a/config/etcd2.go b/config/etcd2.go new file mode 100644 index 0000000..1b809b4 --- /dev/null +++ b/config/etcd2.go @@ -0,0 +1,44 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package config + +type Etcd2 struct { + AdvertiseClientURLs string `yaml:"advertise_client_urls" env:"ETCD_ADVERTISE_CLIENT_URLS"` + CAFile string `yaml:"ca_file" env:"ETCD_CA_FILE"` + CertFile string `yaml:"cert_file" env:"ETCD_CERT_FILE"` + CorsOrigins string `yaml:"cors" env:"ETCD_CORS"` + DataDir string `yaml:"data_dir" env:"ETCD_DATA_DIR"` + Discovery string `yaml:"discovery" env:"ETCD_DISCOVERY"` + DiscoveryFallback string `yaml:"discovery_fallback" env:"ETCD_DISCOVERY_FALLBACK"` + DiscoverySRV string `yaml:"discovery_srv" env:"ETCD_DISCOVERY_SRV"` + DiscoveryProxy string `yaml:"discovery_proxy" env:"ETCD_DISCOVERY_PROXY"` + ElectionTimeout int `yaml:"election_timeout" env:"ETCD_ELECTION_TIMEOUT"` + HeartbeatInterval int `yaml:"heartbeat_interval" env:"ETCD_HEARTBEAT_INTERVAL"` + InitialAdvertisePeerURLs string `yaml:"initial_advertise_peer_urls" env:"ETCD_INITIAL_ADVERTISE_PEER_URLS"` + InitialCluster string `yaml:"initial_cluster" env:"ETCD_INITIAL_CLUSTER"` + InitialClusterState string `yaml:"initial_cluster_state" env:"ETCD_INITIAL_CLUSTER_STATE"` + InitialClusterToken string `yaml:"initial_cluster_token" env:"ETCD_INITIAL_CLUSTER_TOKEN"` + KeyFile string `yaml:"key_file" env:"ETCD_KEY_FILE"` + ListenClientURLs string `yaml:"listen_client_urls" env:"ETCD_LISTEN_CLIENT_URLS"` + ListenPeerURLs string `yaml:"listen_peer_urls" env:"ETCD_LISTEN_PEER_URLS"` + MaxSnapshots int `yaml:"max_snapshots" env:"ETCD_MAX_SNAPSHOTS"` + MaxWALs int `yaml:"max_wals" env:"ETCD_MAX_WALS"` + Name string `yaml:"name" env:"ETCD_NAME"` + PeerCAFile string `yaml:"peer_ca_file" env:"ETCD_PEER_CA_FILE"` + PeerCertFile string `yaml:"peer_cert_file" env:"ETCD_PEER_CERT_FILE"` + PeerKeyFile string `yaml:"peer_key_file" env:"ETCD_PEER_KEY_FILE"` + Proxy string `yaml:"proxy" env:"ETCD_PROXY"` + SnapshotCount int `yaml:"snapshot_count" env:"ETCD_SNAPSHOTCOUNT"` +} diff --git a/initialize/config.go b/initialize/config.go index 3bf7f54..94a47fa 100644 --- a/initialize/config.go +++ b/initialize/config.go @@ -135,6 +135,7 @@ func Apply(cfg config.CloudConfig, ifaces []network.InterfaceGenerator, env *Env for _, ccu := range []CloudConfigUnit{ system.Etcd{Etcd: cfg.CoreOS.Etcd}, + system.Etcd2{Etcd2: cfg.CoreOS.Etcd2}, system.Fleet{Fleet: cfg.CoreOS.Fleet}, system.Locksmith{Locksmith: cfg.CoreOS.Locksmith}, system.Update{Update: cfg.CoreOS.Update, ReadConfig: system.DefaultReadConfig}, diff --git a/system/etcd2.go b/system/etcd2.go new file mode 100644 index 0000000..9b243e0 --- /dev/null +++ b/system/etcd2.go @@ -0,0 +1,37 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package system + +import ( + "github.com/coreos/coreos-cloudinit/config" +) + +// Etcd2 is a top-level structure which embeds its underlying configuration, +// config.Etcd2, and provides the system-specific Unit(). +type Etcd2 struct { + config.Etcd2 +} + +// Units creates a Unit file drop-in for etcd, using any configured options. +func (ee Etcd2) Units() []Unit { + return []Unit{{config.Unit{ + Name: "etcd2.service", + Runtime: true, + DropIns: []config.UnitDropIn{{ + Name: "20-cloudinit.conf", + Content: serviceContents(ee.Etcd2), + }}, + }}} +}