Skip to content

Commit a9e56c5

Browse files
authored
Merge pull request #7595 from twz123/external-etcd-without-component
Don't use etcd component at all when external etcd is used
2 parents 222a994 + 9d4ce4c commit a9e56c5

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
@@ -242,18 +242,23 @@ func (c *command) start(ctx context.Context, flags *config.ControllerOptions, de
242242
K0sVars: c.K0sVars,
243243
}
244244
case v1beta1.EtcdStorageType:
245-
storageBackend = &controller.Etcd{
246-
CertManager: certificateManager,
247-
Config: nodeConfig.Spec.Storage.Etcd,
248-
JoinClient: joinClient,
249-
K0sVars: c.K0sVars,
250-
LogLevel: c.LogLevels.Etcd,
245+
config := nodeConfig.Spec.Storage.Etcd
246+
if !config.IsExternalClusterUsed() {
247+
storageBackend = &controller.Etcd{
248+
CertManager: certificateManager,
249+
Config: config,
250+
JoinClient: joinClient,
251+
K0sVars: c.K0sVars,
252+
LogLevel: c.LogLevels.Etcd,
253+
}
251254
}
252255
default:
253256
return fmt.Errorf("invalid storage type: %s", nodeConfig.Spec.Storage.Type)
254257
}
255-
logrus.Infof("using storage backend %s", nodeConfig.Spec.Storage.Type)
256-
nodeComponents.Add(ctx, storageBackend)
258+
if storageBackend != nil {
259+
logrus.Infof("using storage backend %s", nodeConfig.Spec.Storage.Type)
260+
nodeComponents.Add(ctx, storageBackend)
261+
}
257262

258263
controllerMode := flags.Mode()
259264
// Will the cluster support multiple controllers, or just a single one?
@@ -306,7 +311,6 @@ func (c *command) start(ctx context.Context, flags *config.ControllerOptions, de
306311
ClusterConfig: nodeConfig,
307312
K0sVars: c.K0sVars,
308313
LogLevel: c.LogLevels.KubeAPIServer,
309-
Storage: storageBackend,
310314
EnableKonnectivity: enableKonnectivity,
311315
StopTimeout: flags.APIServerStopTimeout,
312316

pkg/component/controller/apiserver.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ type APIServer struct {
3636
ClusterConfig *v1beta1.ClusterConfig
3737
K0sVars *config.CfgVars
3838
LogLevel string
39-
Storage manager.Component
4039
EnableKonnectivity bool
4140
DisableEndpointReconciler bool
4241
StopTimeout time.Duration

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)