@@ -242,26 +242,24 @@ type ClusterCIDRConfigSpec struct {
242
242
// +optional
243
243
NodeSelector *v1.NodeSelector
244
244
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.
246
251
// +optional
247
- IPv4 *ClusterCIDRSpec
252
+ PerNodeHostBits int32
248
253
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.
250
256
// +optional
251
- IPv6 *ClusterCIDRSpec
252
- }
257
+ IPv4CIDR string
253
258
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
265
263
}
266
264
267
265
type ClusterCIDRConfigStatus struct {
@@ -270,34 +268,30 @@ type ClusterCIDRConfigStatus struct {
270
268
271
269
#### Expected Behavior
272
270
273
- - ` NodeSelector ` , ` IPv4 ` , and ` IPv6 ` are immutable after creation.
271
+ - ` NodeSelector ` , ` PerNodeHostBits ` , ` IPv4CIDR ` , and ` IPv6CIDR ` are immutable after creation.
274
272
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:
277
274
278
- ``` 32 - IPv4 .PerNodeMaskSize == 128 - IPv6.PerNodeMaskSize ```
275
+ ``` IPv4CIDR .PerNodeMaskSize = 32 - PerNodeHostBits ```
279
276
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
282
281
specifies both IPv4 and IPv6. Consider the following example:
283
282
284
283
``` go
285
284
{
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" ,
294
288
}
295
289
```
296
290
Only 4 nodes may be allocated from this ` ClusterCIDRConfig` as only 4 IPv4
297
291
Pod CIDRs can be partitioned from the IPv4 CIDR . The remaining IPv6 Pod
298
292
CIDRs may be used if referenced in another ` ClusterCIDRConfig` .
299
293
300
- - When there are multiple ` ClusterCIDRConfig` resources in the cluster, first
294
+ - When there are multiple ` ClusterCIDRConfig` resources in the cluster, first
301
295
collect the list of applicable ` ClusterCIDRConfig` . A ` ClusterCIDRConfig` is
302
296
applicable if its ` NodeSelector` matches the ` Node` being allocated, and if
303
297
it has free CIDRs to allocate.
@@ -307,21 +301,21 @@ type ClusterCIDRConfigStatus struct {
307
301
If there are multiple default ranges, ties are broken using the scheme
308
302
outlined below.
309
303
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
311
305
following rules:
312
306
1 . Pick the ` ClusterCIDRConfig` whose ` NodeSelector` matches the most
313
307
labels/fields on the ` Node` . For example,
314
308
` {'node.kubernetes.io/instance-type': 'medium', 'rack': 'rack1'}` before
315
309
` {'node.kubernetes.io/instance-type': 'medium'}` .
316
310
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 "}`
319
313
(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 ).
322
316
1 . Break ties arbitrarily.
323
317
324
- - When breaking ties between matching ` ClusterCIDRConfig` , if the most
318
+ - When breaking ties between matching ` ClusterCIDRConfig` , if the most
325
319
applicable (as defined by the tie-break rules) has no more free allocations,
326
320
attempt to allocate from the next highest matching ` ClusterCIDRConfig` . For
327
321
example consider a node with the labels:
@@ -337,39 +331,32 @@ type ClusterCIDRConfigStatus struct {
337
331
to the tie-break rules.
338
332
` ` ` go
339
333
{
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
+
345
338
},
346
339
{
347
340
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",
352
343
},
353
344
{
354
345
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",
359
348
},
360
349
{
361
350
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",
366
353
}
367
354
` ` `
368
355
369
- - The controller will add a finalizer to the ` ClusterCIDRConfig` object
356
+ - The controller will add a finalizer to the ` ClusterCIDRConfig` object
370
357
when it is created.
371
358
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
373
360
Nodes are using ` PodCIDRs` from this range -- if so it keeps the finalizer
374
361
in place and waits for the Nodes to be deleted. When all Nodes using this
375
362
` ClusterCIDRConfig` are deleted, the finalizer is removed.
@@ -381,45 +368,31 @@ type ClusterCIDRConfigStatus struct {
381
368
{
382
369
// Default for nodes not matching any other rule
383
370
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",
390
374
},
391
375
{
392
376
// 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",
398
380
},
399
381
{
400
382
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",
405
385
},
406
386
{
407
387
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",
412
390
},
413
391
{
414
392
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",
423
396
},
424
397
...
425
398
]
0 commit comments