Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate node configuration through kubernetes api #258

Merged
merged 5 commits into from
Mar 28, 2024

Conversation

berkayoz
Copy link
Member

Added NodeConfigurationController that handles watching and reconciling arguments on services.
Restructured components(functionalities) to reduce code duplication and help with updating node config(k8sd-config configmap)

@kwmonroe kwmonroe marked this pull request as ready for review March 21, 2024 15:39
@kwmonroe kwmonroe requested a review from a team as a code owner March 21, 2024 15:39
Copy link
Contributor

@bschimke95 bschimke95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work @berkayoz - did a first pass on the propagation part

package types

type NodeConfig struct {
CloudProvider string `mapstructure:"cloud-provider,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to pull in mapstructure - just use json

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can technically use json but wouldn't that mean doing a Marshal and Unmarshal just to convert between map[string]string and NodeConfig. Seems a bit inefficient/hacky imo.

@berkayoz berkayoz requested a review from a team March 25, 2024 09:31
Copy link
Contributor

@neoaggelos neoaggelos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work so far, but needs some improvements

Comment on lines 11 to 14

configController := controllers.NewNodeConfigurationController()
go configController.Run(s.Context, snap)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd love us to have an option like --disable-node-configuration-controller in k8sd. Just a note for the future, don't do this just yet

Comment on lines 26 to 31
select {
case <-ctx.Done():
return nil
default:
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the time.Sleep() at the end of the loop with a <-time.After(3 * time.Second) here. This interval should be something larger like 10 seconds (or more?). That way you don't need multiple time.Sleep()s in the loop, and you don't have to wait for sleep to finish to see that the context has been canceled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not exactly sure if the interval should be something larger. Mainly 2 concerns:

  • The initial start of the controller might be a bit delayed, which increases the time for nodes to settle.
  • If for some reason the Watch fails, it will take 10 seconds to recover

I think a small interval is okay, the only worry I would have is for the failure on getting a kubernetes client when the cluster is not bootstrapped/joined. Especially in the scenario where someone installed the k8s snap and never interacted with it. We would print an error message into the logs every 3 seconds, that can eventually exhaust disk space.

@berkayoz berkayoz force-pushed the KU-489/propagate-node-config branch from 595bd5c to 0213732 Compare March 27, 2024 05:54
Copy link
Contributor

@neoaggelos neoaggelos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, how is this tested? Is there value in having an e2e test for this? Join a control plane and a worker, update a config like the dns.service-ip, and check that all nodes eventually use that?

Copy link
Contributor

Package Line Rate
github.com/canonical/k8s/api/v1 48%
github.com/canonical/k8s/cmd/k8s 28%
github.com/canonical/k8s/cmd/util 14%
github.com/canonical/k8s/pkg/client/dqlite 44%
github.com/canonical/k8s/pkg/component 10%
github.com/canonical/k8s/pkg/k8sd/api 2%
github.com/canonical/k8s/pkg/k8sd/database 48%
github.com/canonical/k8s/pkg/k8sd/pki 55%
github.com/canonical/k8s/pkg/k8sd/setup 70%
github.com/canonical/k8s/pkg/k8sd/types 68%
github.com/canonical/k8s/pkg/proxy 6%
github.com/canonical/k8s/pkg/snap 14%
github.com/canonical/k8s/pkg/snap/util 90%
github.com/canonical/k8s/pkg/utils 32%
github.com/canonical/k8s/pkg/utils/control 100%
github.com/canonical/k8s/pkg/utils/errors 100%
github.com/canonical/k8s/pkg/utils/k8s 52%
Summary 32% (1654 / 5189)

Copy link
Contributor

@bschimke95 bschimke95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@berkayoz berkayoz merged commit 2ef77f6 into main Mar 28, 2024
13 checks passed
@berkayoz berkayoz deleted the KU-489/propagate-node-config branch March 28, 2024 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants