dns icon indicating copy to clipboard operation
dns copied to clipboard

Enable optional TLS on nodecache metrics endpoint

Open nuhakala opened this issue 6 months ago • 10 comments

Fixes #692. Chose to do the configuration with flags instead of extra config file because thought that it will be simpler and more in line with the project overall.

Adapted the implementation for CoreDNS metrics TLS support to nodecache. The original PR here https://github.com/coredns/coredns/pull/7255

  • TLS support optional (backward compatible)
  • TLS can be configured through command line flags, including the key files and client certificate.
  • Added tests

New command line flags

  • tls-cert-file default value /etc/ssl/tls.crt
  • tls-private-key-file default value /etc/ssl/tls.key
  • client-auth-type default value NoClientCert
  • client-ca-file default value empty
  • tls-min-version default value TLS version 13
  • tls-enabled default value false

In order to use the feature, one needs to give as flag -tls-enabled=1. The defaults are used and the existence of TLS key-files is checked and error is thrown if no files are found. The defaults can be changed by using the corresponding flags.

nuhakala avatar May 26 '25 09:05 nuhakala

Welcome @nuhakala!

It looks like this is your first PR to kubernetes/dns 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/dns has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. :smiley:

k8s-ci-robot avatar May 26 '25 09:05 k8s-ci-robot

Hi @nuhakala. Thanks for your PR.

I'm waiting for a kubernetes 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 avatar May 26 '25 09:05 k8s-ci-robot

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nuhakala Once this PR has been reviewed and has the lgtm label, please assign damiansawicki 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

k8s-ci-robot avatar May 26 '25 09:05 k8s-ci-robot

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-contributor-experience at kubernetes/community.

/check-cla /easycla

k8s-triage-robot avatar May 26 '25 13:05 k8s-triage-robot

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: nuhakala / name: Nuutti Hakala (c825d0bd319979d5e0953e182f9a0cdbf38cd6d5)

@bowei @MrHohn Do you have time to review?

nuhakala avatar May 28 '25 09:05 nuhakala

@bowei @MrHohn Can I get a review on this so that the PR can move forward?

nuhakala avatar Jun 06 '25 13:06 nuhakala

it would be great to have some reviews on this one and move it forward. /cc @DamianSawicki

kashifest avatar Jun 09 '25 06:06 kashifest

/ok-to-test

lentzi90 avatar Jun 09 '25 06:06 lentzi90

it would be great to have some reviews on this one and move it forward. /cc @DamianSawicki

Personally, I won't be able to have a look at it at the moment.

I see 3 open PRs touching the cmd/node-cache directory (this one, https://github.com/kubernetes/dns/pull/690, and https://github.com/kubernetes/dns/pull/689). It could be really beneficial if authors of these PRs, with apparent expertise in node-cache, could cross-review each other's PRs. CC: @Michcioperz @johnbelamaric @zooneon

DamianSawicki avatar Jun 09 '25 18:06 DamianSawicki

This PR is self-contained and primarily focuses on updates to metrics.go and metrics_test.go. The changes to main.go and cache_app.go are minimal and only introduce optional flags to support TLS encryption for the /metrics endpoint.

The implementation is designed to be non-intrusive and does not alter existing functionality. As such, reviewing this PR does not require familiarity with other open pull requests.

peppi-lotta avatar Jul 14 '25 13:07 peppi-lotta

@bowei @MrHohn Could I get review on this?

nuhakala avatar Sep 26 '25 08:09 nuhakala

Refactored and simplified this PR according to the CoreDNS PR.

nuhakala avatar Nov 20 '25 10:11 nuhakala

@DamianSawicki can we get some reviews on this? This is a useful optional feature and shouldn't hamper the usual workflow if not used.

kashifest avatar Dec 01 '25 07:12 kashifest

The meaningful changes the three files under cmd/node-cache/app directory. Rest of the changes are in the auto generated vendor directory and some test configs added for the metrics_test. @bowei , @MrHohn, @DamianSawicki PTAL and if you have any question I'm happy to help. This feature doesn't affect the current workflows in any way but allows more security for the users that need it.

peppi-lotta avatar Dec 04 '25 09:12 peppi-lotta