Skip to content

Conversation

@saewoni
Copy link

@saewoni saewoni commented Oct 24, 2025

Fixes #

Description
We need to expose the localdns configuration in the CRD for Karpenter. This will allow NAP to leverage the same localdns currently used for node pools in AKS-RP.

How was this change tested?

Unit tests below

  • pkg/apis/v1alpha2/aksnodeclass_hash_test.go
  • pkg/apis/v1beta1/aksnodeclass_hash_test.go
  • pkg/apis/v1alpha2/crd_validation_cel_test.go
  • pkg/apis/v1beta1/crd_validation_cel_test.go

Need to learn how to do test like this PR: #688
Does this change impact docs?

  • Yes, PR includes docs updates
  • Yes, issue opened: #
  • No

Release Note

New AKSNodeClass.Spec field (LocalDNSProfile)

@saewoni saewoni marked this pull request as ready for review October 27, 2025 18:14
@saewoni saewoni changed the title [Karpenter CRD change] Add LocalDNSProfile to AKSNodeClassSpec [CRD change] Add LocalDNSProfile to AKSNodeClassSpec Oct 27, 2025
@saewoni saewoni requested a review from Copilot October 27, 2025 23:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds LocalDNSProfile support to the AKSNodeClass CRD, enabling Karpenter to configure local DNS settings for AKS nodes. The implementation follows the AKS-RP proto definitions for consistency with the broader Azure ecosystem.

Key changes:

  • New LocalDNSProfile field in AKSNodeClassSpec with comprehensive DNS configuration options
  • Validation tests for all enum types and boundaries
  • Hash tests to ensure configuration changes trigger node updates

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/apis/v1beta1/aksnodeclass.go Added LocalDNSProfile types and enum constants with kubebuilder validation tags
pkg/apis/v1alpha2/aksnodeclass.go Added LocalDNSProfile types and enum constants with kubebuilder validation tags
pkg/apis/v1beta1/zz_generated.deepcopy.go Auto-generated DeepCopy methods for LocalDNSProfile and LocalDNSOverrides
pkg/apis/v1alpha2/zz_generated.deepcopy.go Auto-generated DeepCopy methods for LocalDNSProfile and LocalDNSOverrides
pkg/apis/v1beta1/crd_validation_cel_test.go Added validation tests for all LocalDNS enum types
pkg/apis/v1alpha2/crd_validation_cel_test.go Added validation tests for all LocalDNS enum types
pkg/apis/v1beta1/aksnodeclass_hash_test.go Added hash tests for LocalDNSProfile fields
pkg/apis/v1alpha2/aksnodeclass_hash_test.go Added hash tests for LocalDNSProfile fields
pkg/apis/crds/karpenter.azure.com_aksnodeclasses.yaml Updated CRD with LocalDNSProfile schema definitions
charts/karpenter-crd/templates/karpenter.azure.com_aksnodeclasses.yaml Updated CRD template with LocalDNSProfile schema definitions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@saewoni saewoni requested a review from Copilot October 27, 2025 23:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@matthchr matthchr left a comment

Choose a reason for hiding this comment

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

I don't think zz_generated.pricing.go needs to be regenerated for this PR?

@saewoni saewoni changed the title [CRD change] Add LocalDNSProfile to AKSNodeClassSpec [CRD change] Add LocalDNSProfile to AKSNodeClassSpec + Integration Tests Oct 31, 2025
@saewoni saewoni changed the title [CRD change] Add LocalDNSProfile to AKSNodeClassSpec + Integration Tests [CRD change] Add LocalDNSProfile to AKSNodeClassSpec + NAP Integration Tests Oct 31, 2025
@saewoni saewoni force-pushed the sakwa/localdns_for_NAP branch 2 times, most recently from 29c6b95 to 4a16ccc Compare November 26, 2025 03:56
@saewoni saewoni requested a review from Copilot December 3, 2025 05:02
Copilot finished reviewing on behalf of saewoni December 3, 2025 05:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
}

func TestConvertLocalDNSOverrideToModel(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

minor, style: Consider just putting these tests into the above test and passing everything through convertLocalDNSToModel (test the public interface or at least the most public part)

@saewoni saewoni force-pushed the sakwa/localdns_for_NAP branch from 618d2ab to 6a42d21 Compare December 3, 2025 23:32
// LocalDNSOverrides specifies DNS override configuration
type LocalDNSOverrides struct {
// Log level for DNS queries in localDNS.
// +optional
Copy link
Author

Choose a reason for hiding this comment

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

yup - i will make localdnsoverrides required only if localdns config is provided. i need to add the validation rule for it still. last time i attempted, my validation rule was too expensive so karpenter repo rejected it

yewmsft
yewmsft previously approved these changes Dec 4, 2025
@saewoni saewoni force-pushed the sakwa/localdns_for_NAP branch from f4c29d2 to 21c7ab0 Compare December 5, 2025 18:35
Copy link
Collaborator

@tallaxes tallaxes left a comment

Choose a reason for hiding this comment

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

The logic looks good to me; left some comments around API, runtime validation (and status condition), and caching.

For the API best practices, had some feedback, started to question myself, and ended up just running kube-api-linter. Left what it found as comments - look for "(kubeapilinter)" - pretty much everything looks legitimate / should be addressed, I think. (For more insight on each see API Conventions doc.) We really should integrate kube-api-linter as part of our dev cycle/CI, TODO. There are more issues it flags elsewhere in our API, can be addressed later. But for the new API we introduce, let's get it right from the get go. (It might be possible to prioritize externally visible changes, and follow-up with internal-only later ...)

if !p.isInstanceTypeSupportedByEncryptionAtHost(sku, nodeClass) {
continue
}
if !p.isInstanceTypeSupportedByLocalDNS(sku, nodeClass) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you have to add local DNS setting (maybe IsLocalDNSEnabled) to the cache key above, since it now affects the set of instance types

ConditionTypeImagesReady = "ImagesReady"
ConditionTypeKubernetesVersionReady = "KubernetesVersionReady"
ConditionTypeSubnetsReady = "SubnetsReady"
ConditionTypeLocalDNSReady = "LocalDNSReady"
Copy link
Collaborator

@tallaxes tallaxes Dec 5, 2025

Choose a reason for hiding this comment

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

Unlike other existing conditions (which fetch certain things and wait for them to be available/ready), this one is just about static API validation, and we are likely to have more of this kind of validation going forward (for other fields as well). So it probably needs to be a single ValidationSucceeded condition, with multiple possible reasons for it to be false - like LocalDNSValiationFailed in this case. Could use AWS provider as an example (e.g. https://github.com/aws/karpenter-provider-aws/blob/main/pkg/controllers/nodeclass/validation.go)

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.

7 participants