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

Add docs for ApplySet-based pruning in kubectl apply #39818

Merged
merged 8 commits into from
Apr 4, 2023

Conversation

KnVerey
Copy link
Contributor

@KnVerey KnVerey commented Mar 6, 2023

@k8s-ci-robot k8s-ci-robot added this to the 1.27 milestone Mar 6, 2023
@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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 6, 2023
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 6, 2023
@k8s-ci-robot k8s-ci-robot added the area/blog Issues or PRs related to the Kubernetes Blog subproject label Mar 6, 2023
@k8s-ci-robot k8s-ci-robot added language/en Issues or PRs related to English language sig/docs Categorizes an issue or PR as relevant to SIG Docs. labels Mar 6, 2023
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 16, 2023
@KnVerey KnVerey marked this pull request as ready for review March 17, 2023 00:12
@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 Mar 17, 2023
@KnVerey
Copy link
Contributor Author

KnVerey commented Mar 17, 2023

/cc @justinsb


**Authors:** Katrina Verey (Shopify) and Justin Santa Barbara (Google)

PLACEHOLDER: blog post for KEP http://git.k8s.io/enhancements/keps/sig-cli/3659-kubectl-apply-prune
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@justinsb assuming we do want to propose a blog post, should we do it later? If I've understood correctly, the main feature docs are due next Tuesday (Mar 21), but blog posts are due April 4.

Copy link
Contributor

Choose a reason for hiding this comment

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

Due date for blog placeholders was the 8th of March - see https://github.com/kubernetes/sig-release/tree/master/releases/release-1.27

@KnVerey KnVerey changed the title Placeholder docs for KEP 3659 Docs for KEP 3659: ApplySet-based pruning in kubectl apply Mar 17, 2023
@sftim
Copy link
Contributor

sftim commented Mar 17, 2023

/retitle Add blog article to announce ApplySet-based pruning in kubectl apply

@k8s-ci-robot k8s-ci-robot changed the title Docs for KEP 3659: ApplySet-based pruning in kubectl apply Add blog article to announce ApplySet-based pruning in kubectl apply Mar 17, 2023
@sftim sftim changed the title Add blog article to announce ApplySet-based pruning in kubectl apply Add docs and blog article to announce ApplySet-based pruning in kubectl apply Mar 17, 2023
@sftim
Copy link
Contributor

sftim commented Mar 17, 2023

/hold

The blog article should be a separate PR so that we can review it in isolation (and can ship v1.27 regardless of progress on post-release blogs).

OK to unhold once the blog part is gone from this PR.

@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 Mar 17, 2023
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

My biggest concern is wrt to documenting alpha labels, I'd probably pull them together with the rest of the description, so it's clear they are part of alpha or skip it for now.

Alternative, we need an alpha tag next to the labels, so it's clear they should not be relied on, yet, since based on the warning they might change.

{{< feature-state for_k8s_version="v1.27" state="alpha" >}}

{{< warning >}}
`kubectl apply --prune --applyset` is in alpha, and backwards incompatible
Copy link
Contributor

Choose a reason for hiding this comment

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

This warning is why I'd probably not document the labels in the other file, not yet. If we decide to go with a resource, rather than label it'll be confusing and we'll have users relying on alpha feature, which is not plainly obvious in that other file.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine documenting it here, under the alpha tag, if there's a desire.

Copy link
Contributor

Choose a reason for hiding this comment

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

We register labels or annotation as soon as released code might either set them or heed them.

If someone sees a label set on an object and we've not documented that label, it doesn't leave as good an impression.
There's another aspect too: keys are “insta-durable” in as much as the first use we make of them, we're on the hook forever to explain what that label does or did mean. Plenty of the well-known labels are documented as deprecated, but a bit like with stable APIs, once they're registered we never delete the registration.

If it's helpful to, we can:

-### applyset.k8s.io/tooling
+### applyset.k8s.io/tooling (alpha) {#applyset-k8s-io-tooling}

and similar, to mark that the key is alpha. No problem there. Notice how I overrode the fragment identifier so that bookmarks etc still work after graduation to beta or stable.


{{< warning >}}
You must be careful when using this command, so that you
do not delete objects unintentionally.
Only use this if you know what you are doing. You must be careful when using this command, so that you do not delete objects unintentionally. For more information on the problems with this command, see the [Current Implementation](git.k8s.io/enhancements/keps/sig-cli/3659-kubectl-apply-prune#current-implementation) section of the ApplySet KEP.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Only use this if you know what you are doing. You must be careful when using this command, so that you do not delete objects unintentionally. For more information on the problems with this command, see the [Current Implementation](git.k8s.io/enhancements/keps/sig-cli/3659-kubectl-apply-prune#current-implementation) section of the ApplySet KEP.
Take care when using `--prune` with `kubectl apply` in allow list mode. The kubectl command must dynamically discover
and infer which objects should be removed as part of the prune operation, and the heuristics for this
can sometimes mean that kubectl deletes objects that did not require pruning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reverse is also true--it can orphan objects that should have been pruned. And user choices regarding the allowlist and labels flags can also cause and/or exacerbate either issue.


```shell
kubectl apply -f <directory/> --prune -l <labels>
kubectl apply -f <directory/> --prune -l <labels> --prune-allowlist=<gvk-list>
```

{{< warning >}}
Apply with prune should only be run against the root directory
containing the object configuration files. Running against sub-directories
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional extra fix:

containing the object manifests. Running against sub-directories


{{< feature-state for_k8s_version="v1.27" state="alpha" >}}

{{< warning >}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a note or a caution here. Warning is for “this could break your cluster if you don't get it right”; if that's really the casefor apply set pruning, I think we should probably revert it until we're more confident.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just intended as a standard alpha warning, so I'll switch it to caution I guess? This feature is more dangerous than others not because it is incomplete or particularly immature or anything like that; simply because its purpose is to perform destructive actions (deletions), which makes misunderstandings/misuse more consequential. Our unit test coverage is very good (MUCH better than what's there for allowlist-based pruning), and we have a basic multi-step e2e in place as well.

{{< feature-state for_k8s_version="v1.27" state="alpha" >}}

{{< warning >}}
`kubectl apply --prune --applyset` is in alpha, and backwards incompatible
Copy link
Contributor

Choose a reason for hiding this comment

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

We register labels or annotation as soon as released code might either set them or heed them.

If someone sees a label set on an object and we've not documented that label, it doesn't leave as good an impression.
There's another aspect too: keys are “insta-durable” in as much as the first use we make of them, we're on the hook forever to explain what that label does or did mean. Plenty of the well-known labels are documented as deprecated, but a bit like with stable APIs, once they're registered we never delete the registration.

If it's helpful to, we can:

-### applyset.k8s.io/tooling
+### applyset.k8s.io/tooling (alpha) {#applyset-k8s-io-tooling}

and similar, to mark that the key is alpha. No problem there. Notice how I overrode the fragment identifier so that bookmarks etc still work after graduation to beta or stable.

@KnVerey KnVerey requested review from sftim and removed request for justinsb, onlydole, nate-double-u and shannonxtreme March 21, 2023 01:43
@KnVerey
Copy link
Contributor Author

KnVerey commented Mar 21, 2023

Updated with the standard prefix since kubernetes/kubernetes#116780 is fully approved for merge into 1.27.

@KnVerey KnVerey requested review from soltysh and removed request for sftim March 21, 2023 21:50
Used on: Objects being used as ApplySet parents.

Use of this annotation is alpha.
For Kubernetes version {{< skew currentVersion >}}, you can use this annotation on Secrets, ConfigMaps, or custom resources if the {{< glossary_tooltip term_id="CustomResourceDefinition" text="CustomResourceDefinition" >}} defining them has the `applyset.kubernetes.io/is-parent-type` label.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please help wrap the long lines for the benefits of downstream localization teams.

For example:

Suggested change
For Kubernetes version {{< skew currentVersion >}}, you can use this annotation on Secrets, ConfigMaps, or custom resources if the {{< glossary_tooltip term_id="CustomResourceDefinition" text="CustomResourceDefinition" >}} defining them has the `applyset.kubernetes.io/is-parent-type` label.
For Kubernetes version {{< skew currentVersion >}}, you can use this annotation on
Secrets, ConfigMaps, or custom resources if the
{{< glossary_tooltip term_id="CustomResourceDefinition" text="CustomResourceDefinition" >}}
defining them has the `applyset.kubernetes.io/is-parent-type` label.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there an explanation of what the desired wrapping is, or perhaps automation (like a make task) that can take care of the toil if this is required? I'm also curious why that helps localization.

Copy link
Contributor

Choose a reason for hiding this comment

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

We have a script that identifies lines that have changed. Long lines don't work well with that.

It'd be nice to see this wrapped (eg at around 100 characters). Can happen after this merges.


Part of the specification used to implement [ApplySet-based pruning in kubectl](/docs/tasks/manage-kubernetes-objects/declarative-config/#alternative-kubectl-apply-f-directory-prune). This annotation is applied to the parent object used to track an ApplySet to extend the scope of the ApplySet beyond the parent object's own namespace (if any). The value is a comma-separated list of the names of namespaces other than the parent's namespace in which objects are found.

### applyset.kubernetes.io/contains-group-resources (alpha) {#applyset-kubernetes-io-contains-group-resources}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a shorter anchor is good enough?

Suggested change
### applyset.kubernetes.io/contains-group-resources (alpha) {#applyset-kubernetes-io-contains-group-resources}
### applyset.kubernetes.io/contains-group-resources (alpha) {#applyset-contains-group-resources}

Copy link
Contributor

Choose a reason for hiding this comment

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

These aren't priced by the byte, you know. The fragment identifies in this page are typically quite long. I think it's OK. The important bit is that they're stable.

@Nancy-Chauhan
Copy link

Hello, Comms Shadow for the 1.27 release here. This feature blog is tracked for release, the deadline for submitting the draft is 4th of April- the sooner the better since there's still editing to be done afterwards 😃 Any doubt, the Comms team is here to help. CC @harshitasao

@KnVerey
Copy link
Contributor Author

KnVerey commented Mar 23, 2023

@Nancy-Chauhan I originally included the blog post placeholder on this PR by mistake, but it is now in #40070. This PR is just the docs.

/remove-area blog

@k8s-ci-robot k8s-ci-robot removed the area/blog Issues or PRs related to the Kubernetes Blog subproject label Mar 23, 2023
@LukeMwila
Copy link

/lgtm

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

LGTM label has been added.

Git tree hash: b0f6052c4ff05be02f412272023c98322c3d0edc

@sftim
Copy link
Contributor

sftim commented Apr 4, 2023

I previewed this locally. It builds OK.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sftim

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 Apr 4, 2023
@k8s-ci-robot k8s-ci-robot merged commit 8c906ea into kubernetes:dev-1.27 Apr 4, 2023
@KnVerey KnVerey deleted the applyset-docs branch April 4, 2023 15:45
DonatoHorn pushed a commit to DonatoHorn/website that referenced this pull request Jun 25, 2023
* Documentation for ApplySet-based pruning (KEP3659)

* Apply suggestions from code review

Co-authored-by: Tim Bannister <[email protected]>

* Add ApplySet labels and annotations to well-known list

* Minor fixups

* Address feedback on label/annotation listing

* Apply suggestions from code review

Co-authored-by: Tim Bannister <[email protected]>

* fix label vs annotation copy-paste errors

* Update prefix to kubernetes.io

---------

Co-authored-by: Tim Bannister <[email protected]>
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. language/en Issues or PRs related to English language lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants