mirror of https://github.com/kubernetes/kops.git
bare-metal: configure etcd with static configuration
Likely restricted to a single node for now (because of the need for well-known IP addresses)
This commit is contained in:
parent
f0555ca3bf
commit
ab0f6847d4
|
@ -143,20 +143,19 @@ func BuildFlagsList(options interface{}) ([]string, error) {
|
||||||
case string:
|
case string:
|
||||||
vString := fmt.Sprintf("%v", v)
|
vString := fmt.Sprintf("%v", v)
|
||||||
if vString != "" && vString != flagEmpty {
|
if vString != "" && vString != flagEmpty {
|
||||||
flag = fmt.Sprintf("--%s=%s", flagName, vString)
|
flag = fmt.Sprintf("--%s=%s", flagName, maybeQuote(vString))
|
||||||
}
|
}
|
||||||
|
|
||||||
case *string:
|
case *string:
|
||||||
if v != nil {
|
if v != nil {
|
||||||
// If flagIncludeEmpty is specified, include anything, including empty strings. Otherwise, behave
|
// If flagIncludeEmpty is specified, include anything, including empty strings. Otherwise, behave
|
||||||
// just like the string case above.
|
// just like the string case above.
|
||||||
|
vString := fmt.Sprintf("%v", *v)
|
||||||
if flagIncludeEmpty {
|
if flagIncludeEmpty {
|
||||||
vString := fmt.Sprintf("%v", *v)
|
flag = fmt.Sprintf("--%s=%s", flagName, maybeQuote(vString))
|
||||||
flag = fmt.Sprintf("--%s=%s", flagName, vString)
|
|
||||||
} else {
|
} else {
|
||||||
vString := fmt.Sprintf("%v", *v)
|
|
||||||
if vString != "" && vString != flagEmpty {
|
if vString != "" && vString != flagEmpty {
|
||||||
flag = fmt.Sprintf("--%s=%s", flagName, vString)
|
flag = fmt.Sprintf("--%s=%s", flagName, maybeQuote(vString))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,3 +213,10 @@ func BuildFlagsList(options interface{}) ([]string, error) {
|
||||||
|
|
||||||
return flags, nil
|
return flags, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func maybeQuote(s string) string {
|
||||||
|
if strings.Contains(s, "\"") {
|
||||||
|
return fmt.Sprintf("%q", s)
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
|
@ -528,7 +528,24 @@ func (b *EtcdManagerBuilder) buildPod(etcdCluster kops.EtcdClusterSpec, instance
|
||||||
|
|
||||||
case kops.CloudProviderMetal:
|
case kops.CloudProviderMetal:
|
||||||
config.VolumeProvider = "external"
|
config.VolumeProvider = "external"
|
||||||
// TODO: Use static configuration here?
|
config.BackupStore = "file:///mnt/disks/backups"
|
||||||
|
config.VolumeTag = []string{
|
||||||
|
fmt.Sprintf("%s--%s--", b.Cluster.Name, etcdCluster.Name),
|
||||||
|
}
|
||||||
|
|
||||||
|
staticConfig := &StaticConfig{
|
||||||
|
EtcdVersion: etcdCluster.Version,
|
||||||
|
}
|
||||||
|
staticConfig.Nodes = append(staticConfig.Nodes, StaticConfigNode{
|
||||||
|
ID: fmt.Sprintf("%s--%s--%d", b.Cluster.Name, etcdCluster.Name, 0),
|
||||||
|
// TODO: Support multiple control-plane nodes (will be interesting!)
|
||||||
|
IP: []string{"127.0.0.1"},
|
||||||
|
})
|
||||||
|
b, err := json.Marshal(staticConfig)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("building static config: %w", err)
|
||||||
|
}
|
||||||
|
config.StaticConfig = string(b)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("CloudProvider %q not supported with etcd-manager", b.Cluster.GetCloudProvider())
|
return nil, fmt.Errorf("CloudProvider %q not supported with etcd-manager", b.Cluster.GetCloudProvider())
|
||||||
|
@ -653,6 +670,19 @@ type config struct {
|
||||||
VolumeNameTag string `flag:"volume-name-tag"`
|
VolumeNameTag string `flag:"volume-name-tag"`
|
||||||
DNSSuffix string `flag:"dns-suffix"`
|
DNSSuffix string `flag:"dns-suffix"`
|
||||||
NetworkCIDR *string `flag:"network-cidr"`
|
NetworkCIDR *string `flag:"network-cidr"`
|
||||||
|
|
||||||
|
// StaticConfig enables running with a fixed etcd cluster configuration.
|
||||||
|
StaticConfig string `flag:"static-config"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type StaticConfig struct {
|
||||||
|
EtcdVersion string `json:"etcdVersion,omitempty"`
|
||||||
|
Nodes []StaticConfigNode `json:"nodes,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type StaticConfigNode struct {
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
IP []string `json:"ip,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SelectorForCluster returns the selector that should be used to select our pods (from services)
|
// SelectorForCluster returns the selector that should be used to select our pods (from services)
|
||||||
|
|
Loading…
Reference in New Issue