Skip to content

Commit 9d4ce4c

Browse files
committed
Don't use etcd component at all when external etcd is used
The Start method was already a no-op in this case, but the Init method is also unnecessary. Also, remove the unused Storage field from the APIServer component. It modeled the logical dependency but is otherwise useless. Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
1 parent a0acede commit 9d4ce4c

3 files changed

Lines changed: 13 additions & 14 deletions

File tree

cmd/controller/controller.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,18 +236,23 @@ func (c *command) start(ctx context.Context, flags *config.ControllerOptions, de
236236
K0sVars: c.K0sVars,
237237
}
238238
case v1beta1.EtcdStorageType:
239-
storageBackend = &controller.Etcd{
240-
CertManager: certificateManager,
241-
Config: nodeConfig.Spec.Storage.Etcd,
242-
JoinClient: joinClient,
243-
K0sVars: c.K0sVars,
244-
LogLevel: c.LogLevels.Etcd,
239+
config := nodeConfig.Spec.Storage.Etcd
240+
if !config.IsExternalClusterUsed() {
241+
storageBackend = &controller.Etcd{
242+
CertManager: certificateManager,
243+
Config: config,
244+
JoinClient: joinClient,
245+
K0sVars: c.K0sVars,
246+
LogLevel: c.LogLevels.Etcd,
247+
}
245248
}
246249
default:
247250
return fmt.Errorf("invalid storage type: %s", nodeConfig.Spec.Storage.Type)
248251
}
249-
logrus.Infof("using storage backend %s", nodeConfig.Spec.Storage.Type)
250-
nodeComponents.Add(ctx, storageBackend)
252+
if storageBackend != nil {
253+
logrus.Infof("using storage backend %s", nodeConfig.Spec.Storage.Type)
254+
nodeComponents.Add(ctx, storageBackend)
255+
}
251256

252257
controllerMode := flags.Mode()
253258
// Will the cluster support multiple controllers, or just a single one?
@@ -300,7 +305,6 @@ func (c *command) start(ctx context.Context, flags *config.ControllerOptions, de
300305
ClusterConfig: nodeConfig,
301306
K0sVars: c.K0sVars,
302307
LogLevel: c.LogLevels.KubeAPIServer,
303-
Storage: storageBackend,
304308
EnableKonnectivity: enableKonnectivity,
305309

306310
// If k0s reconciles the kubernetes endpoint, the API server shouldn't do it.

pkg/component/controller/apiserver.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ type APIServer struct {
3535
ClusterConfig *v1beta1.ClusterConfig
3636
K0sVars *config.CfgVars
3737
LogLevel string
38-
Storage manager.Component
3938
EnableKonnectivity bool
4039
DisableEndpointReconciler bool
4140

pkg/component/controller/etcd.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,6 @@ func (e *Etcd) syncEtcdConfig(ctx context.Context, etcdRequest v1beta1.EtcdReque
140140

141141
// Run runs etcd if external cluster is not configured
142142
func (e *Etcd) Start(ctx context.Context) error {
143-
if e.Config.IsExternalClusterUsed() {
144-
return nil
145-
}
146-
147143
etcdCaCert := filepath.Join(e.K0sVars.EtcdCertDir, "ca.crt")
148144
etcdCaCertKey := filepath.Join(e.K0sVars.EtcdCertDir, "ca.key")
149145
etcdServerCert := filepath.Join(e.K0sVars.EtcdCertDir, "server.crt")

0 commit comments

Comments
 (0)