Skip to content

Commit

Permalink
Merge pull request #5313 from twz123/reuse-er-condition
Browse files Browse the repository at this point in the history
Reuse boolean for toggling the k0s endpoint reconciler
  • Loading branch information
twz123 authored Dec 5, 2024
2 parents 8fb5362 + 6807dfd commit b58ebc6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions cmd/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ func (c *command) start(ctx context.Context) error {
}

enableKonnectivity := !c.SingleNode && !slices.Contains(c.DisableComponents, constant.KonnectivityServerComponentName)
disableEndpointReconciler := !slices.Contains(c.DisableComponents, constant.APIEndpointReconcilerComponentName) &&
nodeConfig.Spec.API.ExternalAddress != ""
enableK0sEndpointReconciler := nodeConfig.Spec.API.ExternalAddress != "" &&
!slices.Contains(c.DisableComponents, constant.APIEndpointReconcilerComponentName)

if enableKonnectivity {
nodeComponents.Add(ctx, &controller.Konnectivity{
Expand All @@ -267,12 +267,14 @@ func (c *command) start(ctx context.Context) error {
}

nodeComponents.Add(ctx, &controller.APIServer{
ClusterConfig: nodeConfig,
K0sVars: c.K0sVars,
LogLevel: c.LogLevels.KubeAPIServer,
Storage: storageBackend,
EnableKonnectivity: enableKonnectivity,
DisableEndpointReconciler: disableEndpointReconciler,
ClusterConfig: nodeConfig,
K0sVars: c.K0sVars,
LogLevel: c.LogLevels.KubeAPIServer,
Storage: storageBackend,
EnableKonnectivity: enableKonnectivity,

// If k0s reconciles the kubernetes endpoint, the API server shouldn't do it.
DisableEndpointReconciler: enableK0sEndpointReconciler,
})

if !c.SingleNode {
Expand Down Expand Up @@ -442,7 +444,7 @@ func (c *command) start(ctx context.Context) error {
clusterComponents.Add(ctx, controller.NewCRD(manifestsSaver, "autopilot"))
}

if !slices.Contains(c.DisableComponents, constant.APIEndpointReconcilerComponentName) && nodeConfig.Spec.API.ExternalAddress != "" {
if enableK0sEndpointReconciler {
clusterComponents.Add(ctx, controller.NewEndpointReconciler(
nodeConfig,
leaderElector,
Expand Down

0 comments on commit b58ebc6

Please sign in to comment.