33
33
- [ ClusterCIDRConfig Deleted] ( #clustercidrconfig-deleted )
34
34
- [ kube-controller-manager] ( #kube-controller-manager )
35
35
- [ 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 )
39
40
- [ Graduation Criteria] ( #graduation-criteria )
40
41
- [ Alpha to Beta Graduation] ( #alpha-to-beta-graduation )
41
42
- [ Beta to GA Graduation] ( #beta-to--ga-graduation )
@@ -242,26 +243,24 @@ type ClusterCIDRConfigSpec struct {
242
243
// +optional
243
244
NodeSelector *v1.NodeSelector
244
245
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.
246
252
// +optional
247
- IPv4 *ClusterCIDRSpec
253
+ PerNodeHostBits int32
248
254
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.
250
257
// +optional
251
- IPv6 *ClusterCIDRSpec
252
- }
258
+ IPv4CIDR string
253
259
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
265
264
}
266
265
267
266
type ClusterCIDRConfigStatus struct {
@@ -270,34 +269,30 @@ type ClusterCIDRConfigStatus struct {
270
269
271
270
#### Expected Behavior
272
271
273
- - ` NodeSelector ` , ` IPv4 ` , and ` IPv6 ` are immutable after creation.
272
+ - ` NodeSelector ` , ` PerNodeHostBits ` , ` IPv4CIDR ` , and ` IPv6CIDR ` are immutable after creation.
274
273
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:
277
275
278
- ``` 32 - IPv4 .PerNodeMaskSize == 128 - IPv6.PerNodeMaskSize ```
276
+ ``` IPv4CIDR .PerNodeMaskSize = 32 - PerNodeHostBits ```
279
277
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
282
282
specifies both IPv4 and IPv6. Consider the following example:
283
283
284
284
``` go
285
285
{
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" ,
294
289
}
295
290
```
296
291
Only 4 nodes may be allocated from this ` ClusterCIDRConfig` as only 4 IPv4
297
292
Pod CIDRs can be partitioned from the IPv4 CIDR . The remaining IPv6 Pod
298
293
CIDRs may be used if referenced in another ` ClusterCIDRConfig` .
299
294
300
- - When there are multiple ` ClusterCIDRConfig` resources in the cluster, first
295
+ - When there are multiple ` ClusterCIDRConfig` resources in the cluster, first
301
296
collect the list of applicable ` ClusterCIDRConfig` . A ` ClusterCIDRConfig` is
302
297
applicable if its ` NodeSelector` matches the ` Node` being allocated, and if
303
298
it has free CIDRs to allocate.
@@ -307,21 +302,21 @@ type ClusterCIDRConfigStatus struct {
307
302
If there are multiple default ranges, ties are broken using the scheme
308
303
outlined below.
309
304
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
311
306
following rules:
312
307
1 . Pick the ` ClusterCIDRConfig` whose ` NodeSelector` matches the most
313
308
labels/fields on the ` Node` . For example,
314
309
` {'node.kubernetes.io/instance-type': 'medium', 'rack': 'rack1'}` before
315
310
` {'node.kubernetes.io/instance-type': 'medium'}` .
316
311
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 "}`
319
314
(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 ).
322
317
1 . Break ties arbitrarily.
323
318
324
- - When breaking ties between matching ` ClusterCIDRConfig` , if the most
319
+ - When breaking ties between matching ` ClusterCIDRConfig` , if the most
325
320
applicable (as defined by the tie-break rules) has no more free allocations,
326
321
attempt to allocate from the next highest matching ` ClusterCIDRConfig` . For
327
322
example consider a node with the labels:
@@ -337,39 +332,32 @@ type ClusterCIDRConfigStatus struct {
337
332
to the tie-break rules.
338
333
` ` ` go
339
334
{
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
+
345
339
},
346
340
{
347
341
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",
352
344
},
353
345
{
354
346
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",
359
349
},
360
350
{
361
351
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",
366
354
}
367
355
` ` `
368
356
369
- - The controller will add a finalizer to the ` ClusterCIDRConfig` object
357
+ - The controller will add a finalizer to the ` ClusterCIDRConfig` object
370
358
when it is created.
371
359
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
373
361
Nodes are using ` PodCIDRs` from this range -- if so it keeps the finalizer
374
362
in place and waits for the Nodes to be deleted. When all Nodes using this
375
363
` ClusterCIDRConfig` are deleted, the finalizer is removed.
@@ -381,45 +369,31 @@ type ClusterCIDRConfigStatus struct {
381
369
{
382
370
// Default for nodes not matching any other rule
383
371
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",
390
375
},
391
376
{
392
377
// 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",
398
381
},
399
382
{
400
383
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",
405
386
},
406
387
{
407
388
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",
412
391
},
413
392
{
414
393
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",
423
397
},
424
398
...
425
399
]
@@ -605,26 +579,35 @@ The list of current valid types is
605
579
606
580
### Test Plan
607
581
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
609
591
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
612
595
613
- #### Integration Tests
596
+ ##### Integration tests
614
597
615
598
- Verify finalizers and statuses are persisted appropriately
616
599
- Test watchers
617
600
- Ensure that the controller handles the feature being disabled and re-enabled:
618
601
- Test with some Nodes already having `PodCIDR` allocations
619
602
620
- #### End-to-End Tests
603
+ ##### e2e tests
621
604
622
605
- Run through some sample workflows. Just a few for example:
623
606
- Adding a node
624
607
- Adding a ClusterCIDRConfig
625
608
- Deleting a ClusterCIDRConfig that is in use
626
609
- 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
628
611
allocated and new nodes also get ranges.
629
612
- Use `NodeSelector` to allocate different sized CIDRs to different nodes.
630
613
- Create and use discontiguous ranges.
0 commit comments