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

Improve LimitRange documentation #46950

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

subhals
Copy link

@subhals subhals commented Jun 24, 2024

Improve limitRange documentation by creating example resources in specific namespaces.
fixes #46899

@k8s-ci-robot k8s-ci-robot added the language/en Issues or PRs related to English language label Jun 24, 2024
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 24, 2024
Copy link

netlify bot commented Jun 24, 2024

Pull request preview available for checking

Built without sensitive environment variables

Name Link
🔨 Latest commit 70011c8
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-io-main-staging/deploys/669478ef52d95c0009d416e2
😎 Deploy Preview https://deploy-preview-46950--kubernetes-io-main-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 26, 2024
@@ -2,6 +2,7 @@ apiVersion: v1
kind: LimitRange
metadata:
name: cpu-resource-constraint
namespace: default
Copy link
Contributor

Choose a reason for hiding this comment

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

Can use other than default, like dev / prod

@@ -2,6 +2,7 @@ apiVersion: v1
kind: Pod
metadata:
name: example-no-conflict-with-limitrange-cpu
namespace: default
Copy link
Contributor

Choose a reason for hiding this comment

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

Can use other than default, like dev / prod

@@ -2,6 +2,7 @@ apiVersion: v1
kind: Pod
metadata:
name: example-conflict-with-limitrange-cpu
namespace: default
Copy link
Contributor

Choose a reason for hiding this comment

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

Can use other than default, like dev / prod

Copy link
Author

Choose a reason for hiding this comment

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

The problem with using other namespace than default is when user copies the manifest and executes it, they will potentially run into namespace not found error.
Although it might be a simple error which users can fix themselves, this will disrupt the user's workflow as the namespace creation is not mentioned anywhere before.

Copy link
Author

Choose a reason for hiding this comment

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

@utkarsh-singh1 wdyt? Do you still recommend specifying dev/prod namespace?
May be we can add a note to create the namespace before applying the yaml?

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO

To keep the concept simple, I think it's okay to keep namespace as the default namespace and include a comment in the YAML manifest indicating that the namespace is implied.

@subhals, @utkarsh-singh1

@tengqm
Copy link
Contributor

tengqm commented Jul 11, 2024

Explicitly specifying "namespace" property is not a good practice for manifest authors. It makes the manifest non-portable. Hardcoding the "namespace" to a fixed value, even if for demonstration's purpose, could be confusing.

I'd suggest we add a warning to that concept page rather than change the manifest.

@T-Lakshmi
Copy link
Contributor

I'd suggest we add a warning to that concept page rather than change the manifest.

@tengqm,
I agree with your suggestion, that is also good idea!

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign natalisucks for approval. For more information see the Kubernetes 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

@subhals
Copy link
Author

subhals commented Jul 15, 2024

Explicitly specifying "namespace" property is not a good practice for manifest authors. It makes the manifest non-portable. Hardcoding the "namespace" to a fixed value, even if for demonstration's purpose, could be confusing.

I'd suggest we add a warning to that concept page rather than change the manifest.

Thank you @tengqm @T-Lakshmi for the suggestions. Updated the changes. PTAL!

@@ -55,16 +55,18 @@ The name of a LimitRange object must be a valid

A `LimitRange` does **not** check the consistency of the default values it applies. This means that a default value for the _limit_ that is set by `LimitRange` may be less than the _request_ value specified for the container in the spec that a client submits to the API server. If that happens, the final Pod will not be schedulable.


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

I don't think this extra line required.

@@ -55,16 +55,18 @@ The name of a LimitRange object must be a valid

A `LimitRange` does **not** check the consistency of the default values it applies. This means that a default value for the _limit_ that is set by `LimitRange` may be less than the _request_ value specified for the container in the spec that a client submits to the API server. If that happens, the final Pod will not be schedulable.
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
A `LimitRange` does **not** check the consistency of the default values it applies. This means that a default value for the _limit_ that is set by `LimitRange` may be less than the _request_ value specified for the container in the spec that a client submits to the API server. If that happens, the final Pod will not be schedulable.
A `LimitRange` does **not** check the consistency of the default values it applies. This means that
a default value for the _limit_ that is set by `LimitRange` may be less than the _request_ value
specified for the container in the spec that a client submits to the API server. If that happens,
the final Pod will not be schedulable.

Copy link
Contributor

Choose a reason for hiding this comment

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

This change doesn't align with the PR description, @T-Lakshmi.

It's OK to not make suggestions where those suggestions would leave the code changes out of step with the PR description.

Copy link
Contributor

Choose a reason for hiding this comment

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

Noted @sftim.

Copy link
Contributor

Choose a reason for hiding this comment

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

@subhals,
This suggestion is entirely optional as it is out of scope as per the PR description.
However, you are free to make changes so that it more closely matches with the PR recent title update.

For example, you define a `LimitRange` with this manifest:

{{% code_sample file="concepts/policy/limit-range/problematic-limit-range.yaml" %}}
{{< warning >}}
The following examples operate within the default namespace, as the namespace parameter is undefined. This implies that any references or operations within these examples will interact with elements within the default namespace unless otherwise specified.{{< /warning >}}
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
The following examples operate within the default namespace, as the namespace parameter is undefined. This implies that any references or operations within these examples will interact with elements within the default namespace unless otherwise specified.{{< /warning >}}
The following examples operate within the default namespace of your cluster, as the namespace
parameter is undefined and the `LimitRange` scope is limited to the namespace level.
This implies that any references or operations within these examples will interact with elements
within the default namespace of your cluster. You can override the operating namespace
by configuring namespace in the `metadata.namespace` field.
{{< /warning >}}

Do you agree with these?

Copy link
Contributor

@sftim sftim Jul 30, 2024

Choose a reason for hiding this comment

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

OK, but we'd ideally we'd write LimitRange without backticks.

If you'd like to, @subhals, you can edit this file so that all the API kinds (eg LimitRange) are written without backticks. It's not mandatory!

@sftim
Copy link
Contributor

sftim commented Jul 30, 2024

/retitle Improve LimitRange documentation

@k8s-ci-robot k8s-ci-robot changed the title Update limit-range.md Improve LimitRange documentation Jul 30, 2024
For example, you define a `LimitRange` with this manifest:

{{% code_sample file="concepts/policy/limit-range/problematic-limit-range.yaml" %}}
{{< warning >}}
Copy link
Contributor

Choose a reason for hiding this comment

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

warning is much too strong. We use warning for: you must follow this advice; if you didn't, your cluster might be at risk.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, Agree with you @sftim.

In that case, replacing warning with a Note instruction would be more appropriate.
WDYT? @sftim @subhals @tengqm.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd use note

@T-Lakshmi
Copy link
Contributor

@subhals,
Can you please respond to the reviewers feedback here when you get time.

@sftim
Copy link
Contributor

sftim commented Sep 30, 2024

@subhals, would you be willing to revise this PR further? With a few adjustments it would be good to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. language/en Issues or PRs related to English language size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improvement for k8s.io/docs/concepts/policy/limit-range/
6 participants