Skip to content

Feat: add common_crds role and Prometheus Operator CRDs installation#12441

Merged
k8s-ci-robot merged 4 commits intokubernetes-sigs:masterfrom
tico88612:feat/crds-installation
Aug 19, 2025
Merged

Feat: add common_crds role and Prometheus Operator CRDs installation#12441
k8s-ci-robot merged 4 commits intokubernetes-sigs:masterfrom
tico88612:feat/crds-installation

Conversation

@tico88612
Copy link
Copy Markdown
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

The use case proposed by the Post kubeadm hook (#12408) is to install Prometheus CRDs, such as ServiceMonitor. Most packages commonly use Prometheus Operator CRDs for monitoring, so this PR proposal is installed together with the Gateway API and merged into common_crds.

Which issue(s) this PR fixes:

Related #12408

Special notes for your reviewer:

The Prometheus Operator CRDs are commonly used for monitoring and are used by some CNIs (such as Cilium). Kubespray can be installed first, and the subsequent installation of the Prometheus operator can be handled by the user (or later extensions).

/label tide/merge-method-merge

Does this PR introduce a user-facing change?:

Added Prometheus Operator CRDs installation

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. tide/merge-method-merge Denotes a PR that should use a standard merge by tide when it merges. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 1, 2025
@k8s-ci-robot k8s-ci-robot requested review from VannTen and mzaian August 1, 2025 18:22
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 1, 2025
@tico88612 tico88612 changed the title [WIP] Feat: add common_crds role and Prometheus Operator CRDs installation Feat: add common_crds role and Prometheus Operator CRDs installation Aug 2, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 2, 2025
@tico88612 tico88612 force-pushed the feat/crds-installation branch from ae56340 to 4d94a21 Compare August 2, 2025 02:33
@tico88612
Copy link
Copy Markdown
Member Author

tico88612 commented Aug 2, 2025

/hold
Preventing accidental merges, need review & discussion

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 2, 2025
@rarescosma
Copy link
Copy Markdown

This looks very promising, good job!

One question though: would it be possible to check if the CRD is installed already, and skip the install in this case? (say somewhere in a layer above Kubespray we change the CRD version, then we wouldn't want subsequent Kubespray runs overwriting it)

See this comment on the generic hooks PR too: #12408 (comment)

@tico88612
Copy link
Copy Markdown
Member Author

I remember that upgrade is not yet integrated with CRDs (that is, upgrading a cluster does not include installing or upgrading CRDs)

@rarescosma
Copy link
Copy Markdown

I remember that upgrade is not yet integrated with CRDs (that is, upgrading a cluster does not include installing or upgrading CRDs)

Hmmm, I don't think this is about upgrades, we sort of run the cluster.yml playbook repeatedly. On subsequent runs, if the CRDs are already present in the cluster, we'd like to skip re-installing them.

Maybe something like this:

    - name: Apply ServiceMonitors CRD manifest
      shell: >-
        {{ kubectl }} get crd servicemonitors.monitoring.coreos.com \
        || {{ kubectl }} apply -f {{ temp_dir.path }}/crd-servicemonitors.yaml
      args:
        executable: /bin/bash
      run_once: true

Maybe expose it through another flag: ..._skip_if_found_....

That would make this feature actually usable for us, remove the need of generic hooks and make everything simpler 🥳

WDYT?

@tico88612 tico88612 force-pushed the feat/crds-installation branch from 4d94a21 to 0165ca9 Compare August 5, 2025 12:50
@tico88612
Copy link
Copy Markdown
Member Author

@rarescosma I changed the state to present, I think this is what you want.

When set to present, an object will be created, if it does not already exist.

@tico88612
Copy link
Copy Markdown
Member Author

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 8, 2025
@rarescosma
Copy link
Copy Markdown

@rarescosma I changed the state to present, I think this is what you want.

When set to present, an object will be created, if it does not already exist.

Lovely, I'll try backporting this onto our 2.28 tracking branch and give it a go next week. Thank you!

@tico88612
Copy link
Copy Markdown
Member Author

tico88612 commented Aug 8, 2025

@MrFreezeex could you help me take a look at this? thanks!

Copy link
Copy Markdown
Member

@MrFreezeex MrFreezeex left a comment

Choose a reason for hiding this comment

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

Thanks that look promising!
The only thing that might be a bit weird to me is that we need to duplicate those default variable in multiple places (especially those version number unfortunately) but this is the same for the existing gateway-api crds so I wouldn't block that pr on that

I can add the lgtm label if you want me to or wait in case you want additional reviews as you wish

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MrFreezeex, tico88612

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

The pull request process is described here

Details 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

@tico88612
Copy link
Copy Markdown
Member Author

Thanks that look promising! The only thing that might be a bit weird to me is that we need to duplicate those default variable in multiple places (especially those version number unfortunately) but this is the same for the existing gateway-api crds so I wouldn't block that pr on that

Yep, ideally, I would like to write the CRD version in separate files, but obviously the download module will need to be used. We may need to discuss how to proceed.

I can add the lgtm label if you want me to or wait in case you want additional reviews as you wish

If you think it's okay to merge, I respect the opinion of each reviewer.

Copy link
Copy Markdown
Contributor

@VannTen VannTen left a comment

Choose a reason for hiding this comment

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

The common CRDs idea looks smart to me, some comments.

Adding commonly used CRDs can be expanded

Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
@tico88612 tico88612 force-pushed the feat/crds-installation branch from 0165ca9 to 4440dcc Compare August 18, 2025 13:15
Comment on lines +1 to +12
---
- name: Prometheus Operator CRDs | Download YAML
include_tasks: "../../../../download/tasks/download_file.yml"
vars:
download: "{{ download_defaults | combine(downloads.prometheus_operator_crds) }}"

- name: Read CRDs yaml from remote
slurp:
src: "{{ local_release_dir }}/prometheus-operator-crds.yaml"
register: crds_file
when:
- "inventory_hostname == groups['kube_control_plane'][0]"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I somehow forgot that the download rewrite is still WIP 😅

@tico88612 tico88612 force-pushed the feat/crds-installation branch 2 times, most recently from 5109496 to 97b0ebd Compare August 18, 2025 14:05
The Prometheus Operator CRDs are commonly used for monitoring and are
used by some CNIs (such as Cilium). Kubespray can be installed first,
and the subsequent installation of the operator can be handled by the
user (or later extensions).

Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
@tico88612 tico88612 force-pushed the feat/crds-installation branch from 97b0ebd to 9dca520 Compare August 18, 2025 14:27
@tico88612
Copy link
Copy Markdown
Member Author

/retest

1 similar comment
@tico88612
Copy link
Copy Markdown
Member Author

/retest

@VannTen
Copy link
Copy Markdown
Contributor

VannTen commented Aug 19, 2025

Can you just add the prometheus_crds_enable: true in one (or several) test cases so we exercise the code in CI ? Apart from that, looks OK to me.

Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
@tico88612
Copy link
Copy Markdown
Member Author

Can you just add the prometheus_crds_enable: true in one (or several) test cases so we exercise the code in CI ? Apart from that, looks OK to me.

Added it.

@VannTen
Copy link
Copy Markdown
Contributor

VannTen commented Aug 19, 2025

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 19, 2025
@k8s-ci-robot k8s-ci-robot merged commit eb4f6d7 into kubernetes-sigs:master Aug 19, 2025
47 checks passed
@tico88612 tico88612 deleted the feat/crds-installation branch August 20, 2025 06:26
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-merge Denotes a PR that should use a standard merge by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants