Skip to content

Conversation

ivankatliarchuk
Copy link
Contributor

@ivankatliarchuk ivankatliarchuk commented Jun 9, 2025

What does it do ?

Motivation

Worth to add support for FQDN templating for pods. Similar to nodes

Quite useful for debugging and create on the fly DNS records based on different pod spec or annotations without the need to restart/reboot them or apply any other sources.

What else I found, pod source does not support

More

  • Yes, this PR title follows Conventional Commits
  • Yes, I added unit tests
  • Yes, I updated end user documentation accordingly

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 9, 2025
@k8s-ci-robot k8s-ci-robot requested a review from mloiseleur June 9, 2025 08:39
@k8s-ci-robot k8s-ci-robot requested a review from szuecs June 9, 2025 08:39
@k8s-ci-robot k8s-ci-robot added source size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 9, 2025
@ivankatliarchuk
Copy link
Contributor Author

Hi @vflaux wdyt to review this feature?

Probably worth to have a look, there is one test, and it seems bit flakey #5470 (comment)

Never seen it before the refactoring.

@ivankatliarchuk
Copy link
Contributor Author

Hi @vflaux wdyt to review this feature?

Probably worth to have a look, there is one test, and it seems bit flakey #5470 (comment)

Never seen it before the refactoring.

possibly flaky test is fixed #5514, we will see it

Comment on lines 679 to 685
// if tc.expectedDebugMsgs != nil {
// for _, expectedMsg := range tc.expectedDebugMsgs {
// testutils.TestHelperLogContains(expectedMsg, hook, t)
// }
// } else {
// require.Empty(t, hook.AllEntries(), "Expected no debug messages")
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this still be commented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice one. Need to uncomment this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. There were a bug, fixed in this pr #5514. Merged with master

Comment on lines 689 to 694

// for _, ep := range endpoints {
// // TODO: source should always set the resource label key. currently not supported by the pod source.
// assert.Empty(t, ep.Labels, "Labels should not be empty for endpoint %s", ep.DNSName)
// assert.NotContains(t, ep.Labels, endpoint.ResourceLabelKey)
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this still be commented?

Maybe use require instead of assert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to require

}

func (*podSource) AddEventHandler(ctx context.Context, handler func()) {
func (*podSource) AddEventHandler(_ context.Context, _ func()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, do you know why this function does nothing? (Other sources often add the handler to informers)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. We need to fix that as well. Related PR #5274

We need to review and fix all the handlers. It's a useful feature. I'm not too sure how it differ from adding handlers in constructur, that the only gotcha

source/pod.go Outdated
}

endpointMap := make(map[endpoint.EndpointKey][]string)
fqdnEndpointMap := make(map[endpoint.EndpointKey][]string)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this map there to ensure the fqdn endpoints get priority over pod endpoints by adding them to endpointMap at the end? Or we could copy directly into endpointMap without it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can try to copy. The code could be slightly more complex. As currently we could merge them at the end. Do you want me try to re-use single map?

The main challange I experience, is that ps.addPodEndpointsToEndpointMap(endpointMap, pod) actually modify same map. But still possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. removed fqdn map, and we are using single map

source/pod.go Outdated
if ps.fqdnTemplate != nil {
fqdnHosts, err := ps.hostsFromTemplate(pod)
if err != nil {
log.Debug(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be a warning at least? Or this is expected to "silently" ignore errors?

Copy link
Contributor Author

@ivankatliarchuk ivankatliarchuk Jun 10, 2025

Choose a reason for hiding this comment

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

Someone may decide to use FQDN with {{ .PodSpec.PodDNSConfig }}, one pod could have it, the other pod not necessary. We may have too many warnings. No prference, shell I change it to warn?

Copy link
Contributor

Choose a reason for hiding this comment

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

I've looked at other Sources and they return the error directly.
I'm not sure what is the best thing to do 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.

Make sense. I'll do the same then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to return error directly as in others.

@k8s-ci-robot
Copy link
Contributor

@vflaux: changing LGTM is restricted to collaborators

In response to this:

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.

ivankatliarchuk and others added 7 commits June 10, 2025 16:13
* master:
  test(source): fix flaky test (kubernetes-sigs#5514)
  chore(source/node): added resouce labels for nodes (kubernetes-sigs#5509)
  chore(deps): bump the dev-dependencies group across 1 directory with 14 updates (kubernetes-sigs#5511)
  fix(ovh): correct handling of records deletion (kubernetes-sigs#5450)
@ivankatliarchuk ivankatliarchuk requested a review from vflaux June 11, 2025 07:46
@k8s-ci-robot
Copy link
Contributor

@vflaux: changing LGTM is restricted to collaborators

In response to this:

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.

@ivankatliarchuk
Copy link
Contributor Author

/assign @mloiseleur

Copy link
Collaborator

@mloiseleur mloiseleur left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 13, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mloiseleur, vflaux

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

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 13, 2025
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 13, 2025
@ivankatliarchuk
Copy link
Contributor Author

/lgtm

@k8s-ci-robot
Copy link
Contributor

@ivankatliarchuk: you cannot LGTM your own PR.

In response to this:

/lgtm

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.

…t-for-fqdn' into feat-pod-add-support-for-fqdn

* refs/remotes/origin/feat-pod-add-support-for-fqdn:
  feat(source/pod): add support for fqdn templating
@mloiseleur
Copy link
Collaborator

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 13, 2025
@k8s-ci-robot k8s-ci-robot merged commit 7792986 into kubernetes-sigs:master Jun 13, 2025
13 checks passed
@ivankatliarchuk ivankatliarchuk deleted the feat-pod-add-support-for-fqdn branch June 14, 2025 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. docs lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants