Skip to content

Commit 77b761c

Browse files
authored
Merge pull request kubernetes#3402 from sarveshr7/cluster-cidr-kep
KEP:2593:Update ClusterCIDRConfig API, Test plan and Milestones
2 parents ee6adf7 + 95d2d31 commit 77b761c

File tree

2 files changed

+79
-96
lines changed

2 files changed

+79
-96
lines changed

keps/sig-network/2593-multiple-cluster-cidrs/README.md

Lines changed: 75 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
- [ClusterCIDRConfig Deleted](#clustercidrconfig-deleted)
3434
- [kube-controller-manager](#kube-controller-manager)
3535
- [Test Plan](#test-plan)
36-
- [Unit Tests and Benchmarks](#unit-tests-and-benchmarks)
37-
- [Integration Tests](#integration-tests)
38-
- [End-to-End Tests](#end-to-end-tests)
36+
- [Prerequisite testing updates](#prerequisite-testing-updates)
37+
- [Unit tests](#unit-tests)
38+
- [Integration tests](#integration-tests)
39+
- [e2e tests](#e2e-tests)
3940
- [Graduation Criteria](#graduation-criteria)
4041
- [Alpha to Beta Graduation](#alpha-to-beta-graduation)
4142
- [Beta to GA Graduation](#beta-to--ga-graduation)
@@ -242,26 +243,24 @@ type ClusterCIDRConfigSpec struct {
242243
// +optional
243244
NodeSelector *v1.NodeSelector
244245

245-
// This defines the IPv4 CIDR assignable to nodes selected by this config.
246+
// PerNodeHostBits defines the number of host bits to be configured per node.
247+
// A subnet mask determines how much of the address is used for network bits
248+
// and host bits. For example an IPv4 address of 192.168.0.0/24, splits the
249+
// address into 24 bits for the network portion and 8 bits for the host portion.
250+
// For a /24 mask for IPv4 or a /120 for IPv6, configure PerNodeHostBits=8
251+
// This field is immutable.
246252
// +optional
247-
IPv4 *ClusterCIDRSpec
253+
PerNodeHostBits int32
248254

249-
// This defines the IPv6 CIDR assignable to nodes selected by this config.
255+
// IPv4CIDR defines an IPv4 IP block in CIDR notation(e.g. "10.0.0.0/8").
256+
// This field is immutable.
250257
// +optional
251-
IPv6 *ClusterCIDRSpec
252-
}
258+
IPv4CIDR string
253259

254-
type ClusterCIDRSpec struct {
255-
// An IP block in CIDR notation ("10.0.0.0/8", "fd12:3456:789a:1::/64")
256-
// +required
257-
CIDR string
258-
259-
// Netmask size (e.g. 25 -> "/25") to allocate to a node.
260-
// Users would have to ensure that the kubelet doesn't try to schedule more
261-
// pods than are supported by the node's netmask (i.e. the kubelet's
262-
// --max-pods flag)
263-
// +required
264-
PerNodeMaskSize int
260+
// IPv6CIDR defines an IPv6 IP block in CIDR notation(e.g. "fd12:3456:789a:1::/64").
261+
// This field is immutable.
262+
// +optional
263+
IPv6CIDR string
265264
}
266265

267266
type ClusterCIDRConfigStatus struct {
@@ -270,34 +269,30 @@ type ClusterCIDRConfigStatus struct {
270269

271270
#### Expected Behavior
272271

273-
- `NodeSelector`, `IPv4`, and `IPv6` are immutable after creation.
272+
- `NodeSelector`, `PerNodeHostBits`, `IPv4CIDR`, and `IPv6CIDR` are immutable after creation.
274273

275-
- `IPv4.PerNodeMaskSize` and `IPv6.PerNodeMaskSize` must specify the same
276-
number of IP addresses:
274+
- `PerNodeHostBits` is used to calculate the mask size PerNode for the specified CIDRs:
277275

278-
```32 - IPv4.PerNodeMaskSize == 128 - IPv6.PerNodeMaskSize```
276+
```IPv4CIDR.PerNodeMaskSize = 32 - PerNodeHostBits```
279277

280-
- Each node will be assigned all Pod CIDRs from a matching config. That is to
281-
say, you cannot assing only IPv4 addresses from a `ClusterCIDRConfig` which
278+
```IPv6CIDR.PerNodeMaskSize = 128 - PerNodeHostBits```
279+
280+
- Each node will be assigned all Pod CIDRs from a matching config. That is to
281+
say, you cannot assign only IPv4 addresses from a `ClusterCIDRConfig` which
282282
specifies both IPv4 and IPv6. Consider the following example:
283283

284284
```go
285285
{
286-
IPv4: {
287-
CIDR: "10.0.0.0/20",
288-
PerNodeMaskSize: "22",
289-
},
290-
IPv6: {
291-
CIDR: "fd12:3456:789a:1::/64"
292-
PerNodeMaskSize: "118",
293-
},
286+
PerNodeHostBits: 10,
287+
IPv4CIDR: "10.0.0.0/20",
288+
IPv6CIDR: "fd12:3456:789a:1::/64",
294289
}
295290
```
296291
Only 4 nodes may be allocated from this `ClusterCIDRConfig` as only 4 IPv4
297292
Pod CIDRs can be partitioned from the IPv4 CIDR. The remaining IPv6 Pod
298293
CIDRs may be used if referenced in another `ClusterCIDRConfig`.
299294

300-
- When there are multiple `ClusterCIDRConfig` resources in the cluster, first
295+
- When there are multiple `ClusterCIDRConfig` resources in the cluster, first
301296
collect the list of applicable `ClusterCIDRConfig`. A `ClusterCIDRConfig` is
302297
applicable if its `NodeSelector` matches the `Node` being allocated, and if
303298
it has free CIDRs to allocate.
@@ -307,21 +302,21 @@ type ClusterCIDRConfigStatus struct {
307302
If there are multiple default ranges, ties are broken using the scheme
308303
outlined below.
309304

310-
In ths case of multiple matching ranges, attempt to break ties with the
305+
In the case of multiple matching ranges, attempt to break ties with the
311306
following rules:
312307
1. Pick the `ClusterCIDRConfig` whose `NodeSelector` matches the most
313308
labels/fields on the `Node`. For example,
314309
`{'node.kubernetes.io/instance-type': 'medium', 'rack': 'rack1'}` before
315310
`{'node.kubernetes.io/instance-type': 'medium'}`.
316311
1. Pick the `ClusterCIDRConfig` with the fewest Pod CIDRs allocatable. For
317-
example, `{CIDR: "10.0.0.0/16", PerNodeMaskSize: "16"}` (1 possible Pod
318-
CIDR) is picked before `{CIDR: "192.168.0.0/20", PerNodeMaskSize: "22"}`
312+
example, `{CIDR: "10.0.0.0/16", PerNodeHostBits: "16"}` (1 possible Pod
313+
CIDR) is picked before `{CIDR: "192.168.0.0/20", PerNodeHostBits: "10"}`
319314
(4 possible Pod CIDRs)
320-
1. Pick the `ClusterCIDRConfig` whose `PerNodeMaskSize` is the fewest IPs.
321-
For example, `27` (32 IPs) picked before `25` (128 IPs).
315+
1. Pick the `ClusterCIDRConfig` whose `PerNodeHostBits` is the fewest IPs.
316+
For example, `5` (32 IPs) picked before `7` (128 IPs).
322317
1. Break ties arbitrarily.
323318

324-
- When breaking ties between matching `ClusterCIDRConfig`, if the most
319+
- When breaking ties between matching `ClusterCIDRConfig`, if the most
325320
applicable (as defined by the tie-break rules) has no more free allocations,
326321
attempt to allocate from the next highest matching `ClusterCIDRConfig`. For
327322
example consider a node with the labels:
@@ -337,39 +332,32 @@ type ClusterCIDRConfigStatus struct {
337332
to the tie-break rules.
338333
```go
339334
{
340-
NodeSelector: { MatchExpressions: { "node": "n1", "rack": "rack1" } },
341-
IPv4: {
342-
CIDR: "10.5.0.0/16",
343-
PerNodeMaskSize: 26,
344-
}
335+
NodeSelector: { MatchExpressions: { "node": "n1", "rack": "rack1" } },
336+
PerNodeHostBits: 6,
337+
IPv4CIDR: "10.5.0.0/16",
338+
345339
},
346340
{
347341
NodeSelector: { MatchExpressions: { "node": "n1" } },
348-
IPv4: {
349-
CIDR: "192.168.128.0/17",
350-
PerNodeMaskSize: 28,
351-
}
342+
PerNodeHostBits: 4,
343+
IPv4CIDR: "192.168.128.0/17",
352344
},
353345
{
354346
NodeSelector: { MatchExpressions: { "node": "n1" } },
355-
IPv4: {
356-
CIDR: "192.168.64.0/20",
357-
PerNodeMaskSize: 28,
358-
}
347+
PerNodeHostBits: 4,
348+
IPv4CIDR: "192.168.64.0/20",
359349
},
360350
{
361351
NodeSelector: nil,
362-
IPv4: {
363-
CIDR: "10.0.0.0/8",
364-
PerNodeMaskSize: 26,
365-
}
352+
PerNodeHostBits: 6,
353+
IPv4CIDR: "10.0.0.0/8",
366354
}
367355
```
368356

369-
- The controller will add a finalizer to the `ClusterCIDRConfig` object
357+
- The controller will add a finalizer to the `ClusterCIDRConfig` object
370358
when it is created.
371359

372-
- On deletion of the `ClusterCIDRConfig`, the controller checks to see if any
360+
- On deletion of the `ClusterCIDRConfig`, the controller checks to see if any
373361
Nodes are using `PodCIDRs` from this range -- if so it keeps the finalizer
374362
in place and waits for the Nodes to be deleted. When all Nodes using this
375363
`ClusterCIDRConfig` are deleted, the finalizer is removed.
@@ -381,45 +369,31 @@ type ClusterCIDRConfigStatus struct {
381369
{
382370
// Default for nodes not matching any other rule
383371
NodeSelector: nil,
384-
IPv4: {
385-
// For existing clusters this is the same as ClusterCIDR
386-
CIDR: "10.0.0.0/8",
387-
// For existing API this is the same as NodeCIDRMaskSize
388-
PerNodeMaskSize: 24,
389-
}
372+
PerNodeHostBits: 8,
373+
// For existing clusters this is the same as ClusterCIDR
374+
IPv4CIDR: "10.0.0.0/8",
390375
},
391376
{
392377
// Another range, also allocate-able to any node
393-
NodeSelector: nil,
394-
IPv4: {
395-
CIDR: "172.16.0.0/14",
396-
PerNodeMaskSize: 24,
397-
}
378+
NodeSelector: nil,
379+
PerNodeHostBits: 8,
380+
IPv4CIDR: "172.16.0.0/14",
398381
},
399382
{
400383
NodeSelector: { "node": "n1" },
401-
IPv4: {
402-
CIDR: "10.0.0.0/8",
403-
PerNodeMaskSize: 26,
404-
}
384+
PerNodeHostBits: 6,
385+
IPv4CIDR: "10.0.0.0/8",
405386
},
406387
{
407388
NodeSelector: { "node": "n2" },
408-
IPv4: {
409-
CIDR: "192.168.0.0/16",
410-
PerNodeMaskSize: 26,
411-
}
389+
PerNodeHostBits: 6,
390+
IPv4CIDR: "192.168.0.0/16",
412391
},
413392
{
414393
NodeSelector: { "node": "n3" },
415-
IPv4: {
416-
CIDR: "5.2.0.0/16",
417-
PerNodeMaskSize: 26,
418-
}
419-
IPv6: {
420-
CIDR: "fd12:3456:789a:1::/64",
421-
PerNodeMaskSize: 122,
422-
}
394+
PerNodeHostBits: 6,
395+
IPv4CIDR: "5.2.0.0/16",
396+
IPv6CIDR: "fd12:3456:789a:1::/64",
423397
},
424398
...
425399
]
@@ -605,26 +579,35 @@ The list of current valid types is
605579
606580
### Test Plan
607581
608-
#### Unit Tests and Benchmarks
582+
[X] I/we understand the owners of the involved components may require updates to
583+
existing tests to make this code solid enough prior to committing the changes necessary
584+
to implement this enhancement.
585+
586+
##### Prerequisite testing updates
587+
588+
N/A
589+
590+
##### Unit tests
609591
610-
- Ensure that the controller scales to ~5,000 nodes -- memory usage and
611-
reasonable allocation times
592+
- Ensure that the controller scales to ~5,000 nodes -- memory usage and
593+
reasonable allocation times.
594+
- k8s.io/kubernetes/pkg/controller/nodeipam: 06/21/2022 - 51.2
612595
613-
#### Integration Tests
596+
##### Integration tests
614597
615598
- Verify finalizers and statuses are persisted appropriately
616599
- Test watchers
617600
- Ensure that the controller handles the feature being disabled and re-enabled:
618601
- Test with some Nodes already having `PodCIDR` allocations
619602
620-
#### End-to-End Tests
603+
##### e2e tests
621604
622605
- Run through some sample workflows. Just a few for example:
623606
- Adding a node
624607
- Adding a ClusterCIDRConfig
625608
- Deleting a ClusterCIDRConfig that is in use
626609
- Run through the [user stories](#user-stories):
627-
- Expand the ClusterCIDR (existing nodes without alloations are
610+
- Expand the ClusterCIDR (existing nodes without allocations are
628611
allocated and new nodes also get ranges.
629612
- Use `NodeSelector` to allocate different sized CIDRs to different nodes.
630613
- Create and use discontiguous ranges.

keps/sig-network/2593-multiple-cluster-cidrs/kep.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ stage: alpha
2020
# The most recent milestone for which work toward delivery of this KEP has been
2121
# done. This can be the current (upcoming) milestone, if it is being actively
2222
# worked on.
23-
latest-milestone: "v1.24"
23+
latest-milestone: "v1.25"
2424

2525
# The milestone at which this feature was, or is targeted to be, at each stage.
2626
milestone:
27-
alpha: "v1.24"
28-
beta: "v1.25"
29-
stable: "v1.27"
27+
alpha: "v1.25"
28+
beta: "v1.26"
29+
stable: "v1.28"
3030

3131
feature-gates:
3232
- name: ClusterCIDRConfig

0 commit comments

Comments
 (0)