Skip to content

Commit 245fc0f

Browse files
Merge pull request #168 from crawford/etcd
*: remove etcd nodes
2 parents f323e0f + ee97cc2 commit 245fc0f

File tree

14 files changed

+62
-241
lines changed

14 files changed

+62
-241
lines changed

examples/tectonic.aws.yaml

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,6 @@ aws:
1111
# (optional) AMI override for all nodes. Example: `ami-foobar123`.
1212
# ec2AMIOverride:
1313

14-
etcd:
15-
# Instance size for the etcd node(s). Example: `t2.medium`. Read the [etcd recommended hardware](https://coreos.com/etcd/docs/latest/op-guide/hardware.html) guide for best performance
16-
ec2Type: t2.medium
17-
18-
# (optional) List of additional security group IDs for etcd nodes.
19-
#
20-
# Example: `["sg-51530134", "sg-b253d7cc"]`
21-
# extraSGIDs:
22-
23-
# (optional) Name of IAM role to use for the instance profiles of etcd nodes.
24-
# The name is also the last part of a role's ARN.
25-
#
26-
# Example:
27-
# * Role ARN = arn:aws:iam::123456789012:role/tectonic-installer
28-
# * Role Name = tectonic-installer
29-
# iamRoleName:
30-
31-
rootVolume:
32-
# The amount of provisioned IOPS for the root block device of etcd nodes.
33-
# Ignored if the volume type is not io1.
34-
iops: 100
35-
36-
# The size of the volume in gigabytes for the root block device of etcd nodes.
37-
size: 30
38-
39-
# The type of volume for the root block device of etcd nodes.
40-
type: gp2
41-
4214
external:
4315
# (optional) List of subnet IDs within an existing VPC to deploy master nodes into.
4416
# Required to use an existing VPC and the list must match the AZ count.
@@ -206,11 +178,6 @@ containerLinux:
206178
# (optional) A list of PEM encoded CA files that will be installed in /etc/ssl/certs on etcd, master, and worker nodes.
207179
# customCAPEMList:
208180

209-
etcd:
210-
# The name of the node pool(s) to use for etcd nodes
211-
nodePools:
212-
- etcd
213-
214181
iscsi:
215182
# (optional) Start iscsid.service to enable iscsi volume attachment.
216183
# enabled: false
@@ -256,11 +223,6 @@ networking:
256223
# type: flannel
257224

258225
nodePools:
259-
# The number of etcd nodes to be created.
260-
# If set to zero, the count of etcd nodes will be determined automatically.
261-
- count: 3
262-
name: etcd
263-
264226
# The number of master nodes to be created.
265227
# This applies only to cloud platforms.
266228
- count: 1

examples/tectonic.libvirt.yaml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,9 @@ containerLinux:
4444
# Examples: `latest`, `1465.6.0`
4545
version: latest
4646

47-
# (optional) A list of PEM encoded CA files that will be installed in /etc/ssl/certs on etcd, master, and worker nodes.
47+
# (optional) A list of PEM encoded CA files that will be installed in /etc/ssl/certs on master and worker nodes.
4848
# customCAPEMList:
4949

50-
etcd:
51-
# The name of the node pool(s) to use for etcd nodes
52-
nodePools:
53-
- etcd
54-
5550
iscsi:
5651
# (optional) Start iscsid.service to enable iscsi volume attachment.
5752
# enabled: false
@@ -96,11 +91,6 @@ networking:
9691
# type: flannel
9792

9893
nodePools:
99-
# The number of etcd nodes to be created.
100-
# If set to zero, the count of etcd nodes will be determined automatically.
101-
- count: 1
102-
name: etcd
103-
10494
# The number of master nodes to be created.
10595
# This applies only to cloud platforms.
10696
- count: 1

installer/pkg/config-generator/ignition.go

Lines changed: 53 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -13,103 +13,90 @@ import (
1313
"github.com/vincent-petithory/dataurl"
1414
)
1515

16-
var (
17-
ignVersion = "2.2.0"
18-
ignFilesPath = map[string]string{
19-
"master": config.IgnitionMaster,
20-
"worker": config.IgnitionWorker,
21-
"etcd": config.IgnitionEtcd,
22-
}
16+
const (
2317
caPath = "generated/tls/root-ca.crt"
2418
)
2519

26-
func (c *ConfigGenerator) poolToRoleMap() map[string]string {
27-
poolToRole := make(map[string]string)
28-
// assume no roles can share pools
29-
for _, n := range c.Master.NodePools {
30-
poolToRole[n] = "master"
31-
}
32-
for _, n := range c.Worker.NodePools {
33-
poolToRole[n] = "worker"
20+
// GenerateIgnConfig generates Ignition configs for the workers and masters.
21+
func (c *ConfigGenerator) GenerateIgnConfig(clusterDir string) error {
22+
var masters config.NodePool
23+
var workers config.NodePool
24+
for _, pool := range c.NodePools {
25+
switch pool.Name {
26+
case "master":
27+
masters = pool
28+
case "worker":
29+
workers = pool
30+
case "etcd": // FIXME: ignore these until openshift/release stops defining them
31+
default:
32+
return fmt.Errorf("unrecognized role: %s", pool.Name)
33+
}
3434
}
35-
for _, n := range c.Etcd.NodePools {
36-
poolToRole[n] = "etcd"
35+
36+
ca, err := ioutil.ReadFile(filepath.Join(clusterDir, caPath))
37+
if err != nil {
38+
return err
3739
}
38-
return poolToRole
39-
}
4040

41-
// GenerateIgnConfig generates, if successful, files with the ign config for each role.
42-
func (c *ConfigGenerator) GenerateIgnConfig(clusterDir string) error {
43-
poolToRole := c.poolToRoleMap()
44-
for _, p := range c.NodePools {
45-
role := poolToRole[p.Name]
46-
if _, ok := ignFilesPath[role]; !ok {
47-
return fmt.Errorf("unrecognized pool: %s", p.Name)
48-
}
41+
workerCfg, err := parseIgnFile(workers.IgnitionFile)
42+
if err != nil {
43+
return fmt.Errorf("failed to parse Ignition config for workers: %v", err)
44+
}
4945

50-
ignCfg, err := parseIgnFile(p.IgnitionFile)
51-
if err != nil {
52-
return fmt.Errorf("failed to GenerateIgnConfig for pool %s and file %s: %v", p.Name, p.IgnitionFile, err)
53-
}
46+
// XXX(crawford): The SSH key should only be added to the bootstrap
47+
// node. After that, MCO should be responsible for
48+
// distributing SSH keys.
49+
c.embedUserBlock(&workerCfg)
50+
c.appendCertificateAuthority(&workerCfg, ca)
51+
c.embedAppendBlock(&workerCfg, "worker", "")
5452

55-
var ignCfgs []ignconfigtypes.Config
56-
for i := 0; i < p.Count; i++ {
57-
ignCfgs = append(ignCfgs, *ignCfg)
58-
}
53+
if err = ignCfgToFile(workerCfg, filepath.Join(clusterDir, config.IgnitionPathWorker)); err != nil {
54+
return err
55+
}
5956

60-
ca, err := ioutil.ReadFile(filepath.Join(clusterDir, caPath))
61-
if err != nil {
62-
return err
63-
}
57+
masterCfg, err := parseIgnFile(masters.IgnitionFile)
58+
if err != nil {
59+
return fmt.Errorf("failed to parse Ignition config for masters: %v", err)
60+
}
6461

65-
for i := range ignCfgs {
66-
c.appendCertificateAuthority(&ignCfgs[i], ca)
67-
}
62+
for i := 0; i < masters.Count; i++ {
63+
ignCfg := masterCfg
6864

6965
// XXX(crawford): The SSH key should only be added to the bootstrap
7066
// node. After that, MCO should be responsible for
7167
// distributing SSH keys.
72-
for i := range ignCfgs {
73-
c.embedUserBlock(&ignCfgs[i])
74-
}
68+
c.embedUserBlock(&ignCfg)
69+
c.appendCertificateAuthority(&ignCfg, ca)
70+
c.embedAppendBlock(&ignCfg, "master", fmt.Sprintf("etcd_index=%d", i))
7571

76-
fileTargetPath := filepath.Join(clusterDir, ignFilesPath[role])
77-
if role == "master" {
78-
for i := range ignCfgs {
79-
c.embedAppendBlock(&ignCfgs[i], role, fmt.Sprintf("etcd_index=%d", i))
80-
if err = ignCfgToFile(ignCfgs[i], fmt.Sprintf(fileTargetPath, i)); err != nil {
81-
return err
82-
}
83-
}
84-
} else {
85-
c.embedAppendBlock(&ignCfgs[0], role, "")
86-
if err = ignCfgToFile(ignCfgs[0], fileTargetPath); err != nil {
87-
return err
88-
}
72+
if err = ignCfgToFile(ignCfg, filepath.Join(clusterDir, fmt.Sprintf(config.IgnitionPathMaster, i))); err != nil {
73+
return err
8974
}
9075
}
76+
9177
return nil
9278
}
9379

94-
func parseIgnFile(filePath string) (*ignconfigtypes.Config, error) {
80+
func parseIgnFile(filePath string) (ignconfigtypes.Config, error) {
9581
if filePath == "" {
96-
ignition := &ignconfigtypes.Ignition{
97-
Version: ignVersion,
98-
}
99-
return &ignconfigtypes.Config{Ignition: *ignition}, nil
82+
return ignconfigtypes.Config{
83+
Ignition: ignconfigtypes.Ignition{
84+
Version: ignconfigtypes.MaxVersion.String(),
85+
},
86+
}, nil
10087
}
10188

10289
data, err := ioutil.ReadFile(filePath)
10390
if err != nil {
104-
return nil, err
91+
return ignconfigtypes.Config{}, err
10592
}
10693

10794
cfg, rpt, _ := ignconfig.Parse(data)
10895
if len(rpt.Entries) > 0 {
109-
return nil, fmt.Errorf("failed to parse ignition file %s: %s", filePath, rpt.String())
96+
return ignconfigtypes.Config{}, fmt.Errorf("failed to parse ignition file %s: %s", filePath, rpt.String())
11097
}
11198

112-
return &cfg, nil
99+
return cfg, nil
113100
}
114101

115102
func (c *ConfigGenerator) embedAppendBlock(ignCfg *ignconfigtypes.Config, role string, query string) {

installer/pkg/config/aws/aws.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const (
2222
type AWS struct {
2323
EC2AMIOverride string `json:"tectonic_aws_ec2_ami_override,omitempty" yaml:"ec2AMIOverride,omitempty"`
2424
Endpoints Endpoints `json:"tectonic_aws_endpoints,omitempty" yaml:"endpoints,omitempty"`
25-
Etcd `json:",inline" yaml:"etcd,omitempty"`
2625
External `json:",inline" yaml:"external,omitempty"`
2726
ExtraTags map[string]string `json:"tectonic_aws_extra_tags,omitempty" yaml:"extraTags,omitempty"`
2827
InstallerRole string `json:"tectonic_aws_installer_role,omitempty" yaml:"installerRole,omitempty"`
@@ -41,21 +40,6 @@ type External struct {
4140
WorkerSubnetIDs []string `json:"tectonic_aws_external_worker_subnet_ids,omitempty" yaml:"workerSubnetIDs,omitempty"`
4241
}
4342

44-
// Etcd converts etcd related config.
45-
type Etcd struct {
46-
EC2Type string `json:"tectonic_aws_etcd_ec2_type,omitempty" yaml:"ec2Type,omitempty"`
47-
ExtraSGIDs []string `json:"tectonic_aws_etcd_extra_sg_ids,omitempty" yaml:"extraSGIDs,omitempty"`
48-
IAMRoleName string `json:"tectonic_aws_etcd_iam_role_name,omitempty" yaml:"iamRoleName,omitempty"`
49-
EtcdRootVolume `json:",inline" yaml:"rootVolume,omitempty"`
50-
}
51-
52-
// EtcdRootVolume converts etcd rool volume related config.
53-
type EtcdRootVolume struct {
54-
IOPS int `json:"tectonic_aws_etcd_root_volume_iops,omitempty" yaml:"iops,omitempty"`
55-
Size int `json:"tectonic_aws_etcd_root_volume_size,omitempty" yaml:"size,omitempty"`
56-
Type string `json:"tectonic_aws_etcd_root_volume_type,omitempty" yaml:"type,omitempty"`
57-
}
58-
5943
// Master converts master related config.
6044
type Master struct {
6145
CustomSubnets map[string]string `json:"tectonic_aws_master_custom_subnets,omitempty" yaml:"customSubnets,omitempty"`

installer/pkg/config/cluster.go

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ import (
1212
)
1313

1414
const (
15-
// IgnitionMaster is the relative path to the ign master cfg from the tf working directory
15+
// IgnitionPathMaster is the relative path to the ign master cfg from the tf working directory
1616
// This is a format string so that the index can be populated later
17-
IgnitionMaster = "master-%d.ign"
18-
// IgnitionWorker is the relative path to the ign worker cfg from the tf working directory
19-
IgnitionWorker = "worker.ign"
20-
// IgnitionEtcd is the relative path to the ign etcd cfg from the tf working directory
21-
IgnitionEtcd = "etcd.ign"
17+
IgnitionPathMaster = "master-%d.ign"
18+
// IgnitionPathWorker is the relative path to the ign worker cfg from the tf working directory
19+
IgnitionPathWorker = "worker.ign"
2220
// PlatformAWS is the platform for a cluster launched on AWS.
2321
PlatformAWS Platform = "aws"
2422
// PlatformLibvirt is the platform for a cluster launched on libvirt.
@@ -81,8 +79,6 @@ type Cluster struct {
8179
BaseDomain string `json:"tectonic_base_domain,omitempty" yaml:"baseDomain,omitempty"`
8280
CA `json:",inline" yaml:"CA,omitempty"`
8381
ContainerLinux `json:",inline" yaml:"containerLinux,omitempty"`
84-
Etcd `json:",inline" yaml:"etcd,omitempty"`
85-
IgnitionEtcd string `json:"tectonic_ignition_etcd,omitempty" yaml:"-"`
8682
IgnitionMasters []string `json:"tectonic_ignition_masters,omitempty" yaml:"-"`
8783
IgnitionWorker string `json:"tectonic_ignition_worker,omitempty" yaml:"-"`
8884
Internal `json:",inline" yaml:"-"`
@@ -114,20 +110,18 @@ func (c Cluster) NodeCount(names []string) int {
114110

115111
// TFVars will return the config for the cluster in tfvars format.
116112
func (c *Cluster) TFVars() (string, error) {
117-
c.Etcd.Count = c.NodeCount(c.Etcd.NodePools)
118113
c.Master.Count = c.NodeCount(c.Master.NodePools)
119114
c.Worker.Count = c.NodeCount(c.Worker.NodePools)
120115

121116
for i := 0; i < c.Master.Count; i++ {
122-
c.IgnitionMasters = append(c.IgnitionMasters, fmt.Sprintf(IgnitionMaster, i))
117+
c.IgnitionMasters = append(c.IgnitionMasters, fmt.Sprintf(IgnitionPathMaster, i))
123118
}
124119

125-
c.IgnitionWorker = IgnitionWorker
126-
c.IgnitionEtcd = IgnitionEtcd
120+
c.IgnitionWorker = IgnitionPathWorker
127121

128122
// fill in master ips
129123
if c.Platform == PlatformLibvirt {
130-
if err := c.Libvirt.TFVars(c.Master.Count, c.Worker.Count, c.Etcd.Count); err != nil {
124+
if err := c.Libvirt.TFVars(c.Master.Count, c.Worker.Count); err != nil {
131125
return "", err
132126
}
133127
}
@@ -142,12 +136,6 @@ func (c *Cluster) TFVars() (string, error) {
142136

143137
// YAML will return the config for the cluster in yaml format.
144138
func (c *Cluster) YAML() (string, error) {
145-
c.NodePools = append(c.NodePools, NodePool{
146-
Count: c.Etcd.Count,
147-
Name: "etcd",
148-
})
149-
c.Etcd.NodePools = []string{"etcd"}
150-
151139
c.NodePools = append(c.NodePools, NodePool{
152140
Count: c.Master.Count,
153141
Name: "master",

installer/pkg/config/libvirt/libvirt.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ type Libvirt struct {
2121
Network `json:",inline" yaml:"network"`
2222
MasterIPs []string `json:"tectonic_libvirt_master_ips,omitempty" yaml:"masterIPs"`
2323
WorkerIPs []string `json:"tectonic_libvirt_worker_ips,omitempty" yaml:"workerIPs"`
24-
EtcdIPs []string `json:"tectonic_libvirt_etcd_ips,omitempty" yaml:"etcdIPs"`
2524
BootstrapIP string `json:"tectonic_libvirt_bootstrap_ip,omitempty" yaml:"bootstrapIP"`
2625
}
2726

@@ -34,7 +33,7 @@ type Network struct {
3433
}
3534

3635
// TFVars fills in computed Terraform variables.
37-
func (l *Libvirt) TFVars(masterCount int, workerCount int, etcdCount int) error {
36+
func (l *Libvirt) TFVars(masterCount int, workerCount int) error {
3837
_, network, err := net.ParseCIDR(l.Network.IPRange)
3938
if err != nil {
4039
return fmt.Errorf("failed to parse libvirt network ipRange: %v", err)
@@ -72,18 +71,6 @@ func (l *Libvirt) TFVars(masterCount int, workerCount int, etcdCount int) error
7271
}
7372
}
7473

75-
if len(l.EtcdIPs) > 0 {
76-
if len(l.EtcdIPs) != etcdCount {
77-
return fmt.Errorf("length of EtcdIPs doesn't match etcd count")
78-
}
79-
} else {
80-
if ips, err := generateIPs("etcd", network, etcdCount, 20); err == nil {
81-
l.EtcdIPs = ips
82-
} else {
83-
return err
84-
}
85-
}
86-
8774
return nil
8875
}
8976

installer/pkg/config/types.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ type ContainerLinux struct {
3636
Version string `json:"tectonic_container_linux_version,omitempty" yaml:"version,omitempty"`
3737
}
3838

39-
// Etcd converts etcd related config.
40-
type Etcd struct {
41-
Count int `json:"tectonic_etcd_count,omitempty" yaml:"-"`
42-
NodePools []string `json:"-" yaml:"nodePools"`
43-
}
44-
4539
// NodePool converts node pool related config.
4640
type NodePool struct {
4741
Count int `json:"-" yaml:"count"`

0 commit comments

Comments
 (0)