Skip to content

Conversation

@prometherion
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

Although kubeadm has not been designed to run as a library, the code base can still be imported and used via public functions.

The kubeadm function GetAvailableUpgrades can be used to extract the available upgrades for the given Control Plane, and it allows some mocking using the VersionGetter interface, which allows extensibility (e.g.: in case of air-gapped environments, or the need to interact with specific network desigs).

The VersionGetter already reports the following signatures:

  • ClusterVersion
  • KubeadmVersion
  • VersionFromCILabel
  • KubeletVersions
  • ComponentVersions

Some of the functions must interact with the API Server to extract information, and having them wrapped in an interface is vital; however, the GetAvailableUpgrades is not providing any interface to extract the CoreDNS version.

dnsVersion, err := dns.DeployedDNSAddon(client)
if err != nil {
return nil, err
}

The proposed changes extend the signature for the VersionGetter since it's responsible for retrieving component versions, and CoreDNS/DNS is part of those.

A positive outcome for implementing this would be able to reuse the function GetAvailableUpgrades by implementing a new VersionGetter when the state for the given cluster has been "frozen" (e.g.: Control Plane scaled to zero): otherwise, a fakeClient should be used since it's injected currently from the function signature, and it's just used for such a purpose. Thus, we could decrease the number of arguments and achieve more elegance and maintainability in the code.

Which issue(s) this PR is related to:

None

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 24, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot
Copy link
Contributor

Hi @prometherion. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubeadm sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 24, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: prometherion
Once this PR has been reviewed and has the lgtm label, please assign hirazawaui for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

i think this is generally fine @prometherion
added a few comments.

/ok-to-test

clientset "k8s.io/client-go/kubernetes"
"k8s.io/klog/v2"

versionutil "k8s.io/apimachinery/pkg/util/version"
Copy link
Member

Choose a reason for hiding this comment

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

is this needed?

Copy link
Contributor Author

@prometherion prometherion Oct 24, 2025

Choose a reason for hiding this comment

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

It was ready there:

versionutil "k8s.io/apimachinery/pkg/util/version"


func (f *fakeVersionGetter) DNSAddonVersion() (string, error) {
return dns.DeployedDNSAddon(f.client)
}
Copy link
Member

Choose a reason for hiding this comment

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

should be at the bottom of the list of methods.

Copy link
Member

@neolit123 neolit123 Oct 24, 2025

Choose a reason for hiding this comment

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

instead of creating a client, this fake getter should just return a 'faked string' version for coredns like the rest of the methods here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't, since we have a test case which requires a failure (get stable version from CI label failed)

Copy link
Member

Choose a reason for hiding this comment

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

the negative case can be simulated with a 'returnError bool` field from the feke version getter struct.
i think it's more consistent if you drop the fake client and return strings / fake errors.

kubeletVersion: v1Y0.String(),
kubeadmVersion: v1Y0.String(),
etcdVersion: fakeCurrentEtcdVersion,
client: fakeClient,
Copy link
Member

Choose a reason for hiding this comment

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

then here it could be just a string version instead of the client, IIUC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given that we were using a client with the previous implementation, I kept the original test behaviour without changing its logic. We can refactor the entire suite if you prefer by returning the version and the error. However, this client simulates scenarios with multiple CoreDNS installations; in such cases, the upgrade computation should fail.

Copy link
Member

Choose a reason for hiding this comment

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

any missing cases for the DNS getter should be added in TestDeployedDNSAddon, IMO

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 24, 2025
@prometherion prometherion force-pushed the feat/kubeadm-dns-signature branch 2 times, most recently from 7fb2977 to aae5e3e Compare October 24, 2025 13:37
@prometherion prometherion force-pushed the feat/kubeadm-dns-signature branch from aae5e3e to 37e7b39 Compare October 24, 2025 13:38
@prometherion prometherion force-pushed the feat/kubeadm-dns-signature branch from 37e7b39 to 4551366 Compare October 24, 2025 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/kubeadm cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants