Skip to content

Commit eb33dbc

Browse files
committed
Update the ClusterCIDRConfig API and examples
Based on modifications suggested in the API PR associated with this KEP kubernetes/kubernetes#108290 Update the KEP Milestones.
1 parent 949bd7d commit eb33dbc

File tree

2 files changed

+60
-87
lines changed

2 files changed

+60
-87
lines changed

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

Lines changed: 56 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -242,26 +242,24 @@ type ClusterCIDRConfigSpec struct {
242242
// +optional
243243
NodeSelector *v1.NodeSelector
244244

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

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

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
259+
// IPv6CIDR defines an IPv6 IP block in CIDR notation(e.g. "fd12:3456:789a:1::/64").
260+
// This field is immutable.
261+
// +optional
262+
IPv6CIDR string
265263
}
266264

267265
type ClusterCIDRConfigStatus struct {
@@ -270,34 +268,30 @@ type ClusterCIDRConfigStatus struct {
270268

271269
#### Expected Behavior
272270

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

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

278-
```32 - IPv4.PerNodeMaskSize == 128 - IPv6.PerNodeMaskSize```
275+
```IPv4CIDR.PerNodeMaskSize = 32 - PerNodeHostBits```
279276

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
277+
```IPv6CIDR.PerNodeMaskSize = 128 - PerNodeHostBits```
278+
279+
- Each node will be assigned all Pod CIDRs from a matching config. That is to
280+
say, you cannot assign only IPv4 addresses from a `ClusterCIDRConfig` which
282281
specifies both IPv4 and IPv6. Consider the following example:
283282

284283
```go
285284
{
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-
},
285+
PerNodeHostBits: 10,
286+
IPv4CIDR: "10.0.0.0/20",
287+
IPv6CIDR: "fd12:3456:789a:1::/64",
294288
}
295289
```
296290
Only 4 nodes may be allocated from this `ClusterCIDRConfig` as only 4 IPv4
297291
Pod CIDRs can be partitioned from the IPv4 CIDR. The remaining IPv6 Pod
298292
CIDRs may be used if referenced in another `ClusterCIDRConfig`.
299293

300-
- When there are multiple `ClusterCIDRConfig` resources in the cluster, first
294+
- When there are multiple `ClusterCIDRConfig` resources in the cluster, first
301295
collect the list of applicable `ClusterCIDRConfig`. A `ClusterCIDRConfig` is
302296
applicable if its `NodeSelector` matches the `Node` being allocated, and if
303297
it has free CIDRs to allocate.
@@ -307,21 +301,21 @@ type ClusterCIDRConfigStatus struct {
307301
If there are multiple default ranges, ties are broken using the scheme
308302
outlined below.
309303

310-
In ths case of multiple matching ranges, attempt to break ties with the
304+
In the case of multiple matching ranges, attempt to break ties with the
311305
following rules:
312306
1. Pick the `ClusterCIDRConfig` whose `NodeSelector` matches the most
313307
labels/fields on the `Node`. For example,
314308
`{'node.kubernetes.io/instance-type': 'medium', 'rack': 'rack1'}` before
315309
`{'node.kubernetes.io/instance-type': 'medium'}`.
316310
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"}`
311+
example, `{CIDR: "10.0.0.0/16", PerNodeHostBits: "16"}` (1 possible Pod
312+
CIDR) is picked before `{CIDR: "192.168.0.0/20", PerNodeHostBits: "10"}`
319313
(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).
314+
1. Pick the `ClusterCIDRConfig` whose `PerNodeHostBits` is the fewest IPs.
315+
For example, `5` (32 IPs) picked before `7` (128 IPs).
322316
1. Break ties arbitrarily.
323317

324-
- When breaking ties between matching `ClusterCIDRConfig`, if the most
318+
- When breaking ties between matching `ClusterCIDRConfig`, if the most
325319
applicable (as defined by the tie-break rules) has no more free allocations,
326320
attempt to allocate from the next highest matching `ClusterCIDRConfig`. For
327321
example consider a node with the labels:
@@ -337,39 +331,32 @@ type ClusterCIDRConfigStatus struct {
337331
to the tie-break rules.
338332
```go
339333
{
340-
NodeSelector: { MatchExpressions: { "node": "n1", "rack": "rack1" } },
341-
IPv4: {
342-
CIDR: "10.5.0.0/16",
343-
PerNodeMaskSize: 26,
344-
}
334+
NodeSelector: { MatchExpressions: { "node": "n1", "rack": "rack1" } },
335+
PerNodeHostBits: 6,
336+
IPv4CIDR: "10.5.0.0/16",
337+
345338
},
346339
{
347340
NodeSelector: { MatchExpressions: { "node": "n1" } },
348-
IPv4: {
349-
CIDR: "192.168.128.0/17",
350-
PerNodeMaskSize: 28,
351-
}
341+
PerNodeHostBits: 4,
342+
IPv4CIDR: "192.168.128.0/17",
352343
},
353344
{
354345
NodeSelector: { MatchExpressions: { "node": "n1" } },
355-
IPv4: {
356-
CIDR: "192.168.64.0/20",
357-
PerNodeMaskSize: 28,
358-
}
346+
PerNodeHostBits: 4,
347+
IPv4CIDR: "192.168.64.0/20",
359348
},
360349
{
361350
NodeSelector: nil,
362-
IPv4: {
363-
CIDR: "10.0.0.0/8",
364-
PerNodeMaskSize: 26,
365-
}
351+
PerNodeHostBits: 6,
352+
IPv4CIDR: "10.0.0.0/8",
366353
}
367354
```
368355

369-
- The controller will add a finalizer to the `ClusterCIDRConfig` object
356+
- The controller will add a finalizer to the `ClusterCIDRConfig` object
370357
when it is created.
371358

372-
- On deletion of the `ClusterCIDRConfig`, the controller checks to see if any
359+
- On deletion of the `ClusterCIDRConfig`, the controller checks to see if any
373360
Nodes are using `PodCIDRs` from this range -- if so it keeps the finalizer
374361
in place and waits for the Nodes to be deleted. When all Nodes using this
375362
`ClusterCIDRConfig` are deleted, the finalizer is removed.
@@ -381,45 +368,31 @@ type ClusterCIDRConfigStatus struct {
381368
{
382369
// Default for nodes not matching any other rule
383370
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-
}
371+
PerNodeHostBits: 8,
372+
// For existing clusters this is the same as ClusterCIDR
373+
IPv4CIDR: "10.0.0.0/8",
390374
},
391375
{
392376
// Another range, also allocate-able to any node
393-
NodeSelector: nil,
394-
IPv4: {
395-
CIDR: "172.16.0.0/14",
396-
PerNodeMaskSize: 24,
397-
}
377+
NodeSelector: nil,
378+
PerNodeHostBits: 8,
379+
IPv4CIDR: "172.16.0.0/14",
398380
},
399381
{
400382
NodeSelector: { "node": "n1" },
401-
IPv4: {
402-
CIDR: "10.0.0.0/8",
403-
PerNodeMaskSize: 26,
404-
}
383+
PerNodeHostBits: 6,
384+
IPv4CIDR: "10.0.0.0/8",
405385
},
406386
{
407387
NodeSelector: { "node": "n2" },
408-
IPv4: {
409-
CIDR: "192.168.0.0/16",
410-
PerNodeMaskSize: 26,
411-
}
388+
PerNodeHostBits: 6,
389+
IPv4CIDR: "192.168.0.0/16",
412390
},
413391
{
414392
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-
}
393+
PerNodeHostBits: 6,
394+
IPv4CIDR: "5.2.0.0/16",
395+
IPv6CIDR: "fd12:3456:789a:1::/64",
423396
},
424397
...
425398
]

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)