Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prune-whitelist doesn't work for customresourcedefinitions #1310

Closed
thetillhoff opened this issue Oct 23, 2022 · 5 comments
Closed

prune-whitelist doesn't work for customresourcedefinitions #1310

thetillhoff opened this issue Oct 23, 2022 · 5 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. kind/support Categorizes issue or PR as a support question. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@thetillhoff
Copy link

What happened:

My kubernetes deployment pipeline has two (relevant) steps;

  1. Apply CustomResourceDefinitions with kubectl apply -k ./crds
  2. Apply Resources and CustomResources with kubectl apply --prune --all --prune-whitelist=apiextensions.k8s.io/v1 /customresourcedefinition -k ./

But for some reason, the second command will always prune the CustomResourceDefinitions anyway,

What you expected to happen:

The first step should apply all CustomResourceDefinitions that are located in ./crds/.
The second step should apply all resources and custom resources, prune the ones that don't exist in the folder any more, but not prune the CustomResourceDefinitions.

How to reproduce it (as minimally and precisely as possible):

My use case is cert-manager (v1.10.0), where I moved the CustomResourceDefinitions into the ./crds folder (taken from https://github.com/cert-manager/cert-manager/releases/download/v1.10.0/cert-manager.crds.yaml).
The custom resource I'm trying to deploy in the second step is a ClusterIssuer.

But I think generally any CustomResourceDefinition would be fine to verify this.

Anything else we need to know?:

  • I'm using k3s.
  • If there is a better way to deploy the CRDs alongside the CRs in one step, feel free to describe that as well.

Environment:

  • Kubernetes client and server versions (use kubectl version):
Client Version: v1.24.6+k3s1
Kustomize Version: v4.5.4
Server Version: v1.24.6+k3s1
  • Cloud provider or hardware configuration: k3s on amd64 bare metal
  • OS (e.g: cat /etc/os-release): Debian 11
@thetillhoff thetillhoff added the kind/bug Categorizes issue or PR as related to a bug. label Oct 23, 2022
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Oct 23, 2022
@k8s-ci-robot
Copy link
Contributor

@thetillhoff: This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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/test-infra repository.

@brianpursley
Copy link
Member

The second step should apply all resources and custom resources, prune the ones that don't exist in the folder any more, but not prune the CustomResourceDefinitions.

Prune whitelist works the opposite way. When specified, you are telling kubectl which resources can be pruned, so by specifying that, you are telling kubectl to ONLY prune CRDs.

You can specify the flag multiple times for multiple resource types (ie. --prune-whitelist core/v1/configmap --prune-whitelist core/v1/pod)

Or you can use label selectors to indicate which resources are eligible for pruning.

@eddiezane
Copy link
Member

Please let us know if Brian's answer doesn't make sense.

/close
/kind support

@k8s-ci-robot k8s-ci-robot added the kind/support Categorizes issue or PR as a support question. label Nov 9, 2022
@k8s-ci-robot
Copy link
Contributor

@eddiezane: Closing this issue.

In response to this:

Please let us know if Brian's answer doesn't make sense.

/close
/kind support

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/test-infra repository.

@thetillhoff
Copy link
Author

Thank you Eddie for the reminder and thank you Brian for the explanation!

It makes sense to me and answers my question.

At the same it doesn't solve my problem 🥲
Could you please propose a way to apply CRDs and CRs in a pipeline (and removing them if they are removed from the repo)?
Maybe prune isn't the right direction, or is something like --blacklist planned in the future?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. kind/support Categorizes issue or PR as a support question. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

4 participants