fix: re-enable control plane flags

This PR aims to fix the ability to pass extra flags to control plane
components. This will close #1523

Signed-off-by: Spencer Smith <robertspencersmith@gmail.com>
This commit is contained in:
Spencer Smith 2020-01-23 13:32:51 -05:00 committed by Spencer Smith
parent 4f39907b6e
commit aabd46e651
7 changed files with 103 additions and 37 deletions

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.13
replace ( replace (
github.com/docker/distribution v2.7.1+incompatible => github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible github.com/docker/distribution v2.7.1+incompatible => github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible
github.com/firecracker-microvm/firecracker-go-sdk v0.19.0 => github.com/smira/firecracker-go-sdk v0.19.1-0.20200110185541-4fce8cba9f84 github.com/firecracker-microvm/firecracker-go-sdk v0.19.0 => github.com/smira/firecracker-go-sdk v0.19.1-0.20200110185541-4fce8cba9f84
github.com/kubernetes-sigs/bootkube => github.com/talos-systems/bootkube v0.14.1-0.20200121212854-f29021689bee github.com/kubernetes-sigs/bootkube => github.com/talos-systems/bootkube v0.14.1-0.20200123150754-82cbbbe2c4de
github.com/opencontainers/runtime-spec v1.0.1 => github.com/opencontainers/runtime-spec v0.1.2-0.20180301181910-fa4b36aa9c99 github.com/opencontainers/runtime-spec v1.0.1 => github.com/opencontainers/runtime-spec v0.1.2-0.20180301181910-fa4b36aa9c99
) )

4
go.sum
View File

@ -525,8 +525,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2 h1:b6uOv7YOFK0TYG7HtkIgExQo+2RdLuwRft63jn2HWj8= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2 h1:b6uOv7YOFK0TYG7HtkIgExQo+2RdLuwRft63jn2HWj8=
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/talos-systems/bootkube v0.14.1-0.20200121212854-f29021689bee h1:Grx/Ut3pPr+ZaBF/TdqmeEw5RLuX7e0m93yMpSOth1E= github.com/talos-systems/bootkube v0.14.1-0.20200123150754-82cbbbe2c4de h1:aXXO2cMA1iAxVtC2ailC/stPAlpNjpS3OyV0rxJsy7g=
github.com/talos-systems/bootkube v0.14.1-0.20200121212854-f29021689bee/go.mod h1:zLrZfPQ49k0O6x6QN0pDSJn9iD0EMyj6J+5x1vqJSFw= github.com/talos-systems/bootkube v0.14.1-0.20200123150754-82cbbbe2c4de/go.mod h1:zLrZfPQ49k0O6x6QN0pDSJn9iD0EMyj6J+5x1vqJSFw=
github.com/talos-systems/grpc-proxy v0.2.0 h1:DN75bLfaW4xfhq0r0mwFRnfGhSB+HPhK1LNzuMEs9Pw= github.com/talos-systems/grpc-proxy v0.2.0 h1:DN75bLfaW4xfhq0r0mwFRnfGhSB+HPhK1LNzuMEs9Pw=
github.com/talos-systems/grpc-proxy v0.2.0/go.mod h1:sm97Vc/z2cok3pu6ruNeszQej4KDxFrDgfWs4C1mtC4= github.com/talos-systems/grpc-proxy v0.2.0/go.mod h1:sm97Vc/z2cok3pu6ruNeszQej4KDxFrDgfWs4C1mtC4=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=

View File

@ -309,27 +309,30 @@ func generateAssets(config runtime.Configurator) (err error) {
images.PodCheckpointer = config.Cluster().PodCheckpointer().Image() images.PodCheckpointer = config.Cluster().PodCheckpointer().Image()
conf := asset.Config{ conf := asset.Config{
ClusterName: config.Cluster().Name(), ClusterName: config.Cluster().Name(),
CACert: k8sCA, APIServerExtraArgs: config.Cluster().APIServer().ExtraArgs(),
CAPrivKey: k8sKey, ControllerManagerExtraArgs: config.Cluster().ControllerManager().ExtraArgs(),
EtcdCACert: ca, SchedulerExtraArgs: config.Cluster().Scheduler().ExtraArgs(),
EtcdClientCert: peer, CACert: k8sCA,
EtcdClientKey: key, CAPrivKey: k8sKey,
EtcdServers: []*url.URL{etcdServer}, EtcdCACert: ca,
EtcdUseTLS: true, EtcdClientCert: peer,
ControlPlaneEndpoint: config.Cluster().Endpoint(), EtcdClientKey: key,
LocalAPIServerPort: config.Cluster().LocalAPIServerPort(), EtcdServers: []*url.URL{etcdServer},
APIServiceIP: apiServiceIP, EtcdUseTLS: true,
DNSServiceIP: dnsServiceIP, ControlPlaneEndpoint: config.Cluster().Endpoint(),
PodCIDR: podCIDR, LocalAPIServerPort: config.Cluster().LocalAPIServerPort(),
ServiceCIDR: serviceCIDR, APIServiceIP: apiServiceIP,
NetworkProvider: config.Cluster().Network().CNI().Name(), DNSServiceIP: dnsServiceIP,
AltNames: altNames, PodCIDR: podCIDR,
Images: images, ServiceCIDR: serviceCIDR,
BootstrapSecretsSubdir: "/assets/tls", NetworkProvider: config.Cluster().Network().CNI().Name(),
BootstrapTokenID: config.Cluster().Token().ID(), AltNames: altNames,
BootstrapTokenSecret: config.Cluster().Token().Secret(), Images: images,
AESCBCEncryptionSecret: config.Cluster().AESCBCEncryptionSecret(), BootstrapSecretsSubdir: "/assets/tls",
BootstrapTokenID: config.Cluster().Token().ID(),
BootstrapTokenSecret: config.Cluster().Token().Secret(),
AESCBCEncryptionSecret: config.Cluster().AESCBCEncryptionSecret(),
} }
as, err := asset.NewDefaultAssets(conf) as, err := asset.NewDefaultAssets(conf)

View File

@ -15,6 +15,9 @@ import (
// related options. // related options.
type Cluster interface { type Cluster interface {
Name() string Name() string
APIServer() APIServer
ControllerManager() ControllerManager
Scheduler() Scheduler
Endpoint() *url.URL Endpoint() *url.URL
Token() Token Token() Token
CertSANs() []string CertSANs() []string
@ -45,6 +48,24 @@ type CNI interface {
URLs() []string URLs() []string
} }
// APIServer defines the requirements for a config that pertains to apiserver related
// options.
type APIServer interface {
ExtraArgs() map[string]string
}
// ControllerManager defines the requirements for a config that pertains to controller manager related
// options.
type ControllerManager interface {
ExtraArgs() map[string]string
}
// Scheduler defines the requirements for a config that pertains to scheduler related
// options.
type Scheduler interface {
ExtraArgs() map[string]string
}
// Etcd defines the requirements for a config that pertains to etcd related // Etcd defines the requirements for a config that pertains to etcd related
// options. // options.
type Etcd interface { type Etcd interface {

View File

@ -39,11 +39,11 @@ func initUd(in *Input) (*v1alpha1.Config, error) {
ControlPlane: &v1alpha1.ControlPlaneConfig{ ControlPlane: &v1alpha1.ControlPlaneConfig{
Endpoint: &v1alpha1.Endpoint{URL: controlPlaneURL}, Endpoint: &v1alpha1.Endpoint{URL: controlPlaneURL},
}, },
APIServer: &v1alpha1.APIServerConfig{ APIServerConfig: &v1alpha1.APIServerConfig{
CertSANs: certSANs, CertSANs: certSANs,
}, },
ControllerManager: &v1alpha1.ControllerManagerConfig{}, ControllerManagerConfig: &v1alpha1.ControllerManagerConfig{},
Scheduler: &v1alpha1.SchedulerConfig{}, SchedulerConfig: &v1alpha1.SchedulerConfig{},
EtcdConfig: &v1alpha1.EtcdConfig{ EtcdConfig: &v1alpha1.EtcdConfig{
RootCA: in.Certs.Etcd, RootCA: in.Certs.Etcd,
}, },

View File

@ -203,16 +203,16 @@ func (c *ClusterConfig) LocalAPIServerPort() int {
// CertSANs implements the Configurator interface. // CertSANs implements the Configurator interface.
func (c *ClusterConfig) CertSANs() []string { func (c *ClusterConfig) CertSANs() []string {
return c.APIServer.CertSANs return c.APIServerConfig.CertSANs
} }
// SetCertSANs implements the Configurator interface. // SetCertSANs implements the Configurator interface.
func (c *ClusterConfig) SetCertSANs(sans []string) { func (c *ClusterConfig) SetCertSANs(sans []string) {
if c.APIServer == nil { if c.APIServerConfig == nil {
c.APIServer = &APIServerConfig{} c.APIServerConfig = &APIServerConfig{}
} }
c.APIServer.CertSANs = append(c.APIServer.CertSANs, sans...) c.APIServerConfig.CertSANs = append(c.APIServerConfig.CertSANs, sans...)
} }
// CA implements the Configurator interface. // CA implements the Configurator interface.
@ -230,6 +230,48 @@ func (c *ClusterConfig) Config(t machine.Type) (string, error) {
return "", nil return "", nil
} }
// APIServer implements the Configurator interface.
func (c *ClusterConfig) APIServer() cluster.APIServer {
if c.APIServerConfig == nil {
return &APIServerConfig{}
}
return c.APIServerConfig
}
// ExtraArgs implements the Configurator interface.
func (a *APIServerConfig) ExtraArgs() map[string]string {
return a.ExtraArgsConfig
}
// ControllerManager implements the Configurator interface.
func (c *ClusterConfig) ControllerManager() cluster.ControllerManager {
if c.ControllerManagerConfig == nil {
return &ControllerManagerConfig{}
}
return c.ControllerManagerConfig
}
// ExtraArgs implements the Configurator interface.
func (c *ControllerManagerConfig) ExtraArgs() map[string]string {
return c.ExtraArgsConfig
}
// Scheduler implements the Configurator interface.
func (c *ClusterConfig) Scheduler() cluster.Scheduler {
if c.SchedulerConfig == nil {
return &SchedulerConfig{}
}
return c.SchedulerConfig
}
// ExtraArgs implements the Configurator interface.
func (s *SchedulerConfig) ExtraArgs() map[string]string {
return s.ExtraArgsConfig
}
// Etcd implements the Configurator interface. // Etcd implements the Configurator interface.
func (c *ClusterConfig) Etcd() cluster.Etcd { func (c *ClusterConfig) Etcd() cluster.Etcd {
return c.EtcdConfig return c.EtcdConfig

View File

@ -235,7 +235,7 @@ type ClusterConfig struct {
// certSANs: // certSANs:
// - 1.2.3.4 // - 1.2.3.4
// - 5.6.7.8 // - 5.6.7.8
APIServer *APIServerConfig `yaml:"apiServer,omitempty"` APIServerConfig *APIServerConfig `yaml:"apiServer,omitempty"`
// description: | // description: |
// Controller manager server specific configuration options. // Controller manager server specific configuration options.
// examples: // examples:
@ -244,7 +244,7 @@ type ClusterConfig struct {
// image: ... // image: ...
// extraArgs: // extraArgs:
// key: value // key: value
ControllerManager *ControllerManagerConfig `yaml:"controllerManager,omitempty"` ControllerManagerConfig *ControllerManagerConfig `yaml:"controllerManager,omitempty"`
// description: | // description: |
// Scheduler server specific configuration options. // Scheduler server specific configuration options.
// examples: // examples:
@ -253,7 +253,7 @@ type ClusterConfig struct {
// image: ... // image: ...
// extraArgs: // extraArgs:
// key: value // key: value
Scheduler *SchedulerConfig `yaml:"scheduler,omitempty"` SchedulerConfig *SchedulerConfig `yaml:"scheduler,omitempty"`
// description: | // description: |
// Etcd specific configuration options. // Etcd specific configuration options.
// examples: // examples:
@ -479,7 +479,7 @@ type APIServerConfig struct {
Image string `yaml:"image,omitempty"` Image string `yaml:"image,omitempty"`
// description: | // description: |
// Extra arguments to supply to the API server. // Extra arguments to supply to the API server.
ExtraArgs map[string]string `yaml:"extraArgs,omitempty"` ExtraArgsConfig map[string]string `yaml:"extraArgs,omitempty"`
// description: | // description: |
// Extra certificate subject alternative names for the API server's certificate. // Extra certificate subject alternative names for the API server's certificate.
CertSANs []string `yaml:"certSANs,omitempty"` CertSANs []string `yaml:"certSANs,omitempty"`
@ -492,7 +492,7 @@ type ControllerManagerConfig struct {
Image string `yaml:"image,omitempty"` Image string `yaml:"image,omitempty"`
// description: | // description: |
// Extra arguments to supply to the controller manager. // Extra arguments to supply to the controller manager.
ExtraArgs map[string]string `yaml:"extraArgs,omitempty"` ExtraArgsConfig map[string]string `yaml:"extraArgs,omitempty"`
} }
// SchedulerConfig represents kube scheduler config vals. // SchedulerConfig represents kube scheduler config vals.
@ -502,7 +502,7 @@ type SchedulerConfig struct {
Image string `yaml:"image,omitempty"` Image string `yaml:"image,omitempty"`
// description: | // description: |
// Extra arguments to supply to the scheduler. // Extra arguments to supply to the scheduler.
ExtraArgs map[string]string `yaml:"extraArgs,omitempty"` ExtraArgsConfig map[string]string `yaml:"extraArgs,omitempty"`
} }
// EtcdConfig represents etcd config vals. // EtcdConfig represents etcd config vals.