Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 7f27c94

Browse files
jipperinbhamcrawford
authored andcommitted
config: add etcd authentication
1 parent d0a21be commit 7f27c94

6 files changed

Lines changed: 59 additions & 2 deletions

File tree

Documentation/deployment-and-configuration.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,40 @@ Each `fleetd` daemon must be configured to talk to the same [etcd cluster][etcd]
1212

1313
[etcd]: https://coreos.com/docs/cluster-management/setup/getting-started-with-etcd
1414

15+
### Basic Authentication
16+
17+
If your etcd cluster has [Basic authentication][etcd-authentication] enabled, you will need to configure fleet to use an username/password combination for a valid user in the system. Also, because [Basic authentication][etcd-authentication] is Base64 encoded and easily deciphered, it is recommended to also use [TLS authentication][etcd-security] for transport level encryption by providing an `etcd_cafile`. *Authentication is only available since etcd 2.1.X and greater.*
18+
The examples below show how to achieve this:
19+
20+
#### Using systemd Drop-Ins
21+
22+
```ini
23+
[Service]
24+
Environment="FLEET_ETCD_SERVERS=https://192.0.2.12:2379"
25+
Environment="FLEET_ETCD_USERNAME=root"
26+
Environment="FLEET_ETCD_PASSWORD=coreos"
27+
```
28+
29+
#### Using CoreOS Cloud Config
30+
31+
```yaml
32+
#cloud-config
33+
34+
coreos:
35+
fleet:
36+
etcd_servers: "https://192.0.2.12:2379"
37+
etcd_username: root
38+
etcd_password: coreos
39+
```
40+
41+
#### Using fleet configuration file
42+
43+
```ini
44+
etcd_servers=["https://192.0.2.12:2379"]
45+
etcd_username=root
46+
etcd_password=coreos
47+
```
48+
1549
## systemd
1650

1751
The `fleetd` daemon communicates with systemd (v207+) running locally on a given machine. It requires D-Bus (v1.6.12+) to do this.
@@ -129,3 +163,7 @@ Default: "30s"
129163
Interval in seconds at which the engine should reconcile the cluster schedule in etcd.
130164

131165
Default: 2
166+
167+
[etcd]: https://github.com/coreos/etcd/blob/v3.0.4/Documentation/docs.md
168+
[etcd-security]: https://github.com/coreos/etcd/blob/v3.0.4/Documentation/op-guide/security.md
169+
[etcd-authentication]: https://github.com/coreos/etcd/blob/v3.0.4/Documentation/v2/authentication.md

Documentation/using-the-client.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ Alternatively, `--endpoint` can be provided through the `FLEETCTL_ENDPOINT` envi
1717

1818
FLEETCTL_ENDPOINT=http://<IP:[PORT]> fleetctl list-units
1919

20+
### Using etcd Authentication
21+
22+
If your `etcd` cluster is configured with authentication enabled, use the `--etcd-username` and `--etc-password` flags to provide credentials to the command-line tool.
23+
24+
*It is not recommended to use Authentication without also using TLS Transport by also providing the `--ca-file` flag*
25+
2026
### From an External Host
2127

2228
If you prefer to execute fleetctl from an external host (i.e. your laptop), the `--tunnel` flag can be used to tunnel communication with your fleet cluster over SSH:
@@ -27,7 +33,7 @@ One can also provide `--tunnel` through the environment variable `FLEETCTL_TUNNE
2733

2834
FLEETCTL_TUNNEL=<IP[:PORT]> fleetctl list-units
2935

30-
When using `--tunnel` and `--endpoint` together, it is important to note that all etcd requests will be made through the SSH tunnel.
36+
When using `--tunnel` and `--endpoint` together, it is important to note that all etcd requests will be made through the SSH tunnel.
3137
The address in the `--endpoint` flag must be routable from the server hosting the tunnel.
3238

3339
If the external host requires a username other than `core`, the `--ssh-username` flag can be used to set an alternative username.
@@ -136,7 +142,7 @@ hello.service ping.service pong.service
136142
$ fleetctl submit examples/*
137143
```
138144

139-
Submission of units to a fleet cluster does not cause them to be scheduled.
145+
Submission of units to a fleet cluster does not cause them to be scheduled.
140146
The unit will be visible in a `fleetctl list-unit-files` command, but have no reported state in `fleetctl list-units`.
141147

142148
A unit can be removed from a cluster with the `destroy` command:

config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020

2121
type Config struct {
2222
EtcdServers []string
23+
EtcdUsername string
24+
EtcdPassword string
2325
EtcdKeyPrefix string
2426
EtcdKeyFile string
2527
EtcdCertFile string

fleet.conf.sample

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
# etcd_keyfile=/path/to/keyfile
1717
# etcd_certfile=/path/to/certfile
1818

19+
# Provide Authentication configuration when basic authentication is enabled in etcd endpoints
20+
# etcd_username=root
21+
# etcd_password=coreos
22+
1923
# IP address that should be published with any socket information. By default,
2024
# no IP address is published.
2125
# public_ip=""

fleetd/fleetd.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ func main() {
6666
cfgset := flag.NewFlagSet("fleet", flag.ExitOnError)
6767
cfgset.Int("verbosity", 0, "Logging level")
6868
cfgset.Var(&pkg.StringSlice{"http://127.0.0.1:2379", "http://127.0.0.1:4001"}, "etcd_servers", "List of etcd endpoints")
69+
cfgset.String("etcd_username", "", "username for secure etcd communication")
70+
cfgset.String("etcd_password", "", "password for secure etcd communication")
6971
cfgset.String("etcd_keyfile", "", "SSL key file used to secure etcd communication")
7072
cfgset.String("etcd_certfile", "", "SSL certification file used to secure etcd communication")
7173
cfgset.String("etcd_cafile", "", "SSL Certificate Authority file used to secure etcd communication")
@@ -178,6 +180,8 @@ func getConfig(flagset *flag.FlagSet, userCfgFile string) (*config.Config, error
178180
cfg := config.Config{
179181
Verbosity: (*flagset.Lookup("verbosity")).Value.(flag.Getter).Get().(int),
180182
EtcdServers: (*flagset.Lookup("etcd_servers")).Value.(flag.Getter).Get().(pkg.StringSlice),
183+
EtcdUsername: (*flagset.Lookup("etcd_username")).Value.(flag.Getter).Get().(string),
184+
EtcdPassword: (*flagset.Lookup("etcd_password")).Value.(flag.Getter).Get().(string),
181185
EtcdKeyPrefix: (*flagset.Lookup("etcd_key_prefix")).Value.(flag.Getter).Get().(string),
182186
EtcdKeyFile: (*flagset.Lookup("etcd_keyfile")).Value.(flag.Getter).Get().(string),
183187
EtcdCertFile: (*flagset.Lookup("etcd_certfile")).Value.(flag.Getter).Get().(string),

server/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ func New(cfg config.Config) (*Server, error) {
8484
eCfg := etcd.Config{
8585
Transport: &http.Transport{TLSClientConfig: tlsConfig},
8686
Endpoints: cfg.EtcdServers,
87+
Username: cfg.EtcdUsername,
88+
Password: cfg.EtcdPassword,
8789
}
90+
8891
eClient, err := etcd.New(eCfg)
8992
if err != nil {
9093
return nil, err

0 commit comments

Comments
 (0)