Repository: kubernetes/kubernetes (language: go)

Issue:
Change kube-controller-manager flags documentation related to --cluster-cidr and --allocate-node-cidrs (remove required note) 
### What happened?

In [kube-controller-manager documentation](https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager) on  --cluster-cidr flag is written that it requires --allocate-node-cidrs to be true.
Bu actual, we can set non empty --cluster-cidr and disable node cidr allocation (set --allocate-node-cidrs to false).


### What did you expect to happen?

I expect to see in documentation of --allocate-node-cidrs flag note that for this node pod cidr allocation functionality is required to set the --cluster-cidr flag. Also in documentation on --cluster-cidr flag I expect removing mention about that it requires --allocate-node-cidrs flag to be true.

### How can we reproduce it (as minimally and precisely as possible)?

Run controller manager with 2 flags:
--allocate-node-cidrs=false
--cluster-cidr=172.20.0.0/16

### Anything else we need to know?

We are using this functionality to change the expand cluster CIDR subnet.
As I see, we can temporary disable nodeIPAM controller work by setting --allocate-node-cidrs=false.
I found a [merged PR](https://github.com/kubernetes/kubernetes/pull/54934) with the code that ignores cluster cidr parsing if allocate-node-cidrs flag is false.


### Kubernetes version

kubernetes version 1.23.17

### Cloud provider

bare metal

### OS version

_No response_

### Install tools

_No response_

### Container runtime (CRI) and version (if applicable)

_No response_

### Related plugins (CNI, CSI, ...) and versions (if applicable)

_No response_


Discussion / hints:
This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the `triage/accepted` label and provide further guidance.

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


<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
</details>
/sig docs
 if you disable  `--allocate-node-cidrs` the value of `-cluster-cidr` is not used anyhwere, is it?

> We are using this functionality to change the expand cluster CIDR subnet.

I do not understand exactly what do you mean here, can you elaborate in your use case?
/assign

We have a cluster which was initialized with `--cluster-cidr=172.20.0.0/16` and `--allocate-node-cidrs=true`.
Our cluster grew to 65 nodes.
In kube-controlle-manager logs we observed errors like:
```
E0703 16:38:19.620181       1 controller_utils.go:260] Error while processing Node Add/Delete: failed to allocate cidr from cluster cidr at idx:0: CIDR allocation failed; there are no remaining CIDRs left to allocate in the accepted range
```
This error appears because the nodeIPAM controller is enabled and it tries to allocate a podCIDR subnet with /24 mask for each node.
`172.20.0.0/16` have 64 `/24` subnets - so for 65'th node there is now free subnet.
We want to expand cluster CIDR subnet.
For this action, while maintenance, we want to disable kube-controller-manager's nodeIPAM controller.
Actually we can do this by changing only one flag in kube-controller-manager `--allocate-node-cidrs=false`.
The flag `--cluster-cidr` can remain unchanged.


> if you disable `--allocate-node-cidrs` the value of `--cluster-cidr` is not used anyhwere, is it?

Yes it is. The main idea of the issue is to change the affirmation in [documentation](https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/).
Would be more transparent if `--allocate-node-cidrs` flag will require ` --cluster-cidr` flag to be set.
Bot not vice versa.

From the docs It is not clear that you can disable allocation of node CIDR and leave the flag cluster-cidr.
I try to thing back side: 
If the flags `--cluster-cidr` and `--allocate-node-cidrs` are 100% connected and there are used only by nodeIPAM, why do we need this separate flags. 
As I understand:
 `--cluster-cidr` - configures the CIDR parameter for nodeIPAM controller.
`--allocate-node-cidrs` - enables the controller.

So if I am right in previous affirmations, the `--cluster-cidr` flag  actually does not require `--allocate-node-cidrs` to be true. NodeIPAM controller requires `--allocate-node-cidrs=true` and `--cluster-cidr` with a subnet set.

/cc @danwinship @thockin 

as we talked about this today
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity, `lifecycle/stale` is applied
- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied
- After 30d of inactivity since `lifecycle/rotten` was applied, the issue is closed

You can:
- Mark this issue as fresh with `/remove-lifecycle stale`
- Close this issue with `/close`
- Offer to help out with [Issue Triage][1]

Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community).

/lifecycle stale

[1]: https://www.kubernetes.dev/docs/guide/issue-triage/
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity, `lifecycle/stale` is applied
- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied
- After 30d of inactivity since `lifecycle/rotten` was applied, the issue is closed

You can:
- Mark this issue as fresh with `/remove-lifecycle rotten`
- Close this issue with `/close`
- Offer to help out with [Issue Triage][1]

Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community).

/lifecycle rotten

[1]: https://www.kubernetes.dev/docs/guide/issue-triage/
/remove-lifecycle rotten
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity, `lifecycle/stale` is applied
- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied
- After 30d of inactivity since `lifecycle/rotten` was applied, the issue is closed

You can:
- Mark this issue as fresh with `/remove-lifecycle stale`
- Close this issue with `/close`
- Offer to help out with [Issue Triage][1]

Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community).

/lifecycle stale

[1]: https://www.kubernetes.dev/docs/guide/issue-triage/
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity, `lifecycle/stale` is applied
- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied
- After 30d of inactivity since `lifecycle/rotten` was applied, the issue is closed

You can:
- Mark this issue as fresh with `/remove-lifecycle rotten`
- Close this issue with `/close`
- Offer to help out with [Issue Triage][1]

Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community).

/lifecycle rotten

[1]: https://www.kubernetes.dev/docs/guide/issue-triage/
/remove-lifecycle rotten
/assign

Fix patch:
diff --git a/cmd/kube-controller-manager/app/options/nodeipamcontroller.go b/cmd/kube-controller-manager/app/options/nodeipamcontroller.go
index 0a897e472bd5d..00e6fa47d6cc7 100644
--- a/cmd/kube-controller-manager/app/options/nodeipamcontroller.go
+++ b/cmd/kube-controller-manager/app/options/nodeipamcontroller.go
@@ -35,7 +35,7 @@ func (o *NodeIPAMControllerOptions) AddFlags(fs *pflag.FlagSet) {
 	if o == nil {
 		return
 	}
-	fs.StringVar(&o.ServiceCIDR, "service-cluster-ip-range", o.ServiceCIDR, "CIDR Range for Services in cluster. Requires --allocate-node-cidrs to be true")
+	fs.StringVar(&o.ServiceCIDR, "service-cluster-ip-range", o.ServiceCIDR, "CIDR Range for Services in cluster. Only used when --allocate-node-cidrs=true; if false, this option will be ignored.")
 	fs.Int32Var(&o.NodeCIDRMaskSize, "node-cidr-mask-size", o.NodeCIDRMaskSize, "Mask size for node cidr in cluster. Default is 24 for IPv4 and 64 for IPv6.")
 	fs.Int32Var(&o.NodeCIDRMaskSizeIPv4, "node-cidr-mask-size-ipv4", o.NodeCIDRMaskSizeIPv4, "Mask size for IPv4 node cidr in dual-stack cluster. Default is 24.")
 	fs.Int32Var(&o.NodeCIDRMaskSizeIPv6, "node-cidr-mask-size-ipv6", o.NodeCIDRMaskSizeIPv6, "Mask size for IPv6 node cidr in dual-stack cluster. Default is 64.")
diff --git a/staging/src/k8s.io/cloud-provider/options/kubecloudshared.go b/staging/src/k8s.io/cloud-provider/options/kubecloudshared.go
index 988eade1c408f..08a2f01b817d1 100644
--- a/staging/src/k8s.io/cloud-provider/options/kubecloudshared.go
+++ b/staging/src/k8s.io/cloud-provider/options/kubecloudshared.go
@@ -61,8 +61,8 @@ func (o *KubeCloudSharedOptions) AddFlags(fs *pflag.FlagSet) {
 	fs.DurationVar(&o.NodeMonitorPeriod.Duration, "node-monitor-period", o.NodeMonitorPeriod.Duration,
 		fmt.Sprintf("The period for syncing NodeStatus in %s.", names.CloudNodeLifecycleController))
 	fs.StringVar(&o.ClusterName, "cluster-name", o.ClusterName, "The instance prefix for the cluster.")
-	fs.StringVar(&o.ClusterCIDR, "cluster-cidr", o.ClusterCIDR, "CIDR Range for Pods in cluster. Requires --allocate-node-cidrs to be true")
-	fs.BoolVar(&o.AllocateNodeCIDRs, "allocate-node-cidrs", false, "Should CIDRs for Pods be allocated and set on the cloud provider.")
+	fs.StringVar(&o.ClusterCIDR, "cluster-cidr", o.ClusterCIDR, "CIDR Range for Pods in cluster. Only used when --allocate-node-cidrs=true; if false, this option will be ignored.")
+	fs.BoolVar(&o.AllocateNodeCIDRs, "allocate-node-cidrs", false, "Should CIDRs for Pods be allocated and set on the cloud provider. Requires --cluster-cidr.")
 	fs.StringVar(&o.CIDRAllocatorType, "cidr-allocator-type", "RangeAllocator", "Type of CIDR allocator to use")
 	fs.BoolVar(&o.ConfigureCloudRoutes, "configure-cloud-routes", true, "Should CIDRs allocated by allocate-node-cidrs be configured on the cloud provider.")
 


Test patch: