Skip to content

Add ability for custom DNSConfig and DNSPolicy#3899

Merged
simonpasquier merged 9 commits intoprometheus-operator:mainfrom
stafot:add_dns_capabilities_to_pods
Oct 8, 2024
Merged

Add ability for custom DNSConfig and DNSPolicy#3899
simonpasquier merged 9 commits intoprometheus-operator:mainfrom
stafot:add_dns_capabilities_to_pods

Conversation

@stafot
Copy link
Contributor

@stafot stafot commented Mar 5, 2021

Closes #3836.

Adds ability to customize DNS configuration on `Alertmanager`, `Prometheus` and `Thanos` pods.
Adds also ability for custom DNS policy.

@stafot stafot force-pushed the add_dns_capabilities_to_pods branch 5 times, most recently from b380215 to b18a8e1 Compare March 6, 2021 16:55
@stafot stafot marked this pull request as ready for review March 6, 2021 16:55
@stafot stafot requested a review from a team as a code owner March 6, 2021 16:55
Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

do we want to expose dnsPolicy too? cc @prometheus-operator/prometheus-operator-reviewers

@stafot
Copy link
Contributor Author

stafot commented Mar 8, 2021

do we want to expose dnsPolicy too? cc @prometheus-operator/prometheus-operator-reviewers

If yes I could add this too, @simonpasquier.

@simonpasquier
Copy link
Contributor

I would assume folks would want dnsPolicy eventually but I'm not an expert here :)

@stafot stafot force-pushed the add_dns_capabilities_to_pods branch 2 times, most recently from d09b9d7 to b8f0288 Compare March 12, 2021 17:23
Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

Thanks! Only a few nits :)

@stafot stafot force-pushed the add_dns_capabilities_to_pods branch 3 times, most recently from f62a5aa to 197dc30 Compare March 28, 2021 15:06
@stafot stafot requested a review from paulfantom March 28, 2021 17:15
@coderanger
Copy link
Contributor

Isn't this completely equivalent to the existing deep merge option? This doesn't seem common enough to need dedicated fields.

@simonpasquier
Copy link
Contributor

@coderanger DNS config applies at the pod level, not container level so deep-merge can't work IIUC.

@stafot stafot requested a review from simonpasquier March 31, 2021 14:09
@nitinpatil1992
Copy link

Any plan for merging this?

@stafot
Copy link
Contributor Author

stafot commented May 8, 2021

@nitinpatil1992 Is there a formal process to ask for more reviews to proceed?

@simonpasquier
Copy link
Contributor

We're having discussions about adding deep-merge capabilities for the pod spec which would allow to cover any customization (see #4023). It might be more efficient and flexible in the long run than slowly extending the Prometheus CRD every time a new use case comes around.

@simonpasquier
Copy link
Contributor

Hey! Sorry for the very late feedback but we've discussed #4691 at the last contributors office hours and we agreed that adding support for dnsConfig and dnsPolicy makes sense. Would you be able to rebase your PR?

@stafot stafot force-pushed the add_dns_capabilities_to_pods branch from 197dc30 to 35f5e52 Compare May 11, 2022 13:59
@stafot
Copy link
Contributor Author

stafot commented May 11, 2022

I am unable to make generate at the moment due to golang/go#51706. I will retry asap.
cc @simonpasquier

@stafot stafot force-pushed the add_dns_capabilities_to_pods branch from 08039b6 to b30e606 Compare May 12, 2022 20:39
@stafot stafot force-pushed the add_dns_capabilities_to_pods branch from 673603a to 3bf1aed Compare September 27, 2024 12:33
Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that we need unit tests at this level. On the other side it would be good to check that the API validation works as expected in the e2e tests (example:

func testPrometheusCRDValidation(t *testing.T) {
).

Copy link
Contributor Author

@stafot stafot Sep 27, 2024

Choose a reason for hiding this comment

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

@simonpasquier Followed the pattern, I saw with service_monitor_types. Thus I added test for dns_types.

Thanks for the review but I believe needs more work on my side to be reviewable as some tests failing.

@stafot stafot marked this pull request as draft September 27, 2024 14:19
@github-actions github-actions bot removed the stale label Sep 28, 2024
stafot and others added 4 commits October 5, 2024 18:45
Signed-off-by: Stavros Foteinopoulos <stafot@gmail.com>
Review suggestions

Co-authored-by: Simon Pasquier <spasquie@redhat.com>
More review suggestions

Co-authored-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Stavros Foteinopoulos <stafot@gmail.com>
@stafot stafot force-pushed the add_dns_capabilities_to_pods branch from dc9fe8f to 34b6591 Compare October 5, 2024 15:46
@stafot stafot marked this pull request as ready for review October 5, 2024 18:32
Signed-off-by: Stavros Foteinopoulos <stafot@gmail.com>
@stafot stafot force-pushed the add_dns_capabilities_to_pods branch from 0b8eef0 to 1c03c32 Compare October 5, 2024 18:34
@stafot
Copy link
Contributor Author

stafot commented Oct 5, 2024

@paulfantom and @simonpasquier I believe now this PR is ready for review.
Changes based on previous comments done, all unit test and lint failures handled.

@stafot stafot requested a review from simonpasquier October 5, 2024 18:36
@stafot
Copy link
Contributor Author

stafot commented Oct 6, 2024

@simonpasquier I am working on adding these cases on e2e too, as per your comment. Let me know though if it is a must have or nice to have for this PR.

Signed-off-by: Stavros Foteinopoulos <stafot@gmail.com>
@stafot stafot force-pushed the add_dns_capabilities_to_pods branch from 8a563da to 558977b Compare October 7, 2024 08:12
TopologySpreadConstraints: prompkg.MakeK8sTopologySpreadConstraint(finalSelectorLabels, cpf.TopologySpreadConstraints),
HostAliases: operator.MakeHostAliases(cpf.HostAliases),
HostNetwork: cpf.HostNetwork,
DNSPolicy: k8sutil.ConvertDNSPolicy(cpf.DNSPolicy),
Copy link
Contributor

Choose a reason for hiding this comment

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

We should rather only set the fields when they're not nil to avoid undesired side-effects (the same for all controllers).

    if cpf.DNSPolicy != nil {
        spec.DNSPolicy = appsv1.DNSPolicy(*cpf.DNSPolicy)
    }

    if cpf.DNSConfig != nil {
        spec.DNSConfig = k8sutil.ConvertToK8sDNSConfig(*cpf.DNSConfig)
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@simonpasquier I don't fully follow where I need to change this. Could you elaborate please?

Co-authored-by: Simon Pasquier <spasquie@redhat.com>
@stafot stafot marked this pull request as draft October 7, 2024 18:55
stafot added 2 commits October 8, 2024 12:18
Signed-off-by: Stavros Foteinopoulos <stafot@gmail.com>
Signed-off-by: Stavros Foteinopoulos <stafot@gmail.com>
@stafot stafot marked this pull request as ready for review October 8, 2024 12:48
@stafot stafot requested a review from simonpasquier October 8, 2024 12:48
@stafot
Copy link
Contributor Author

stafot commented Oct 8, 2024

@simonpasquier I think last refactor takes into consideration all your comments

Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

thanks!

@simonpasquier simonpasquier merged commit d723855 into prometheus-operator:main Oct 8, 2024
@stafot stafot deleted the add_dns_capabilities_to_pods branch October 12, 2024 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add dnsConfig parameter on PrometheusSpec and to AlertmanagerSpec

8 participants