Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for /32 (/128) networks and perNodeBlockSize 1 #57

Merged
merged 3 commits into from
Oct 15, 2024

Conversation

ykulazhenkov
Copy link
Collaborator

@ykulazhenkov ykulazhenkov commented Oct 14, 2024

Add support for single IP ranges/subnets in all places:

IPPool perNodeBlockSize 1
apiVersion: nv-ipam.nvidia.com/v1alpha1
kind: IPPool
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"nv-ipam.nvidia.com/v1alpha1","kind":"IPPool","metadata":{"annotations":{},"name":"pool1","namespace":"kube-system"},"spec":{"gateway":"192.168.0.3","perNodeBlockSize":1,"subnet":"192.168.0.0/24"}}
  creationTimestamp: "2024-10-14T16:44:59Z"
  generation: 15
  name: pool1
  namespace: kube-system
  resourceVersion: "16150"
  uid: b43c059a-9364-4fbc-b945-1a1f017ddb1b
spec:
  gateway: 192.168.0.3
  perNodeBlockSize: 1
  subnet: 192.168.0.0/24
status:
  allocations:
  - endIP: 192.168.0.2
    nodeName: kind-control-plane
    startIP: 192.168.0.2
  - endIP: 192.168.0.1
    nodeName: kind-worker
    startIP: 192.168.0.1
  - endIP: 192.168.0.4
    nodeName: kind-worker2
    startIP: 192.168.0.4
  - endIP: 192.168.0.5
    nodeName: kind-worker3
    startIP: 192.168.0.5
IPPool /32
apiVersion: nv-ipam.nvidia.com/v1alpha1
kind: IPPool
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"nv-ipam.nvidia.com/v1alpha1","kind":"IPPool","metadata":{"annotations":{},"name":"pool1","namespace":"kube-system"},"spec":{"perNodeBlockSize":1,"subnet":"192.168.1.1/32"}}
  creationTimestamp: "2024-10-14T16:44:59Z"
  generation: 16
  name: pool1
  namespace: kube-system
  resourceVersion: "16441"
  uid: b43c059a-9364-4fbc-b945-1a1f017ddb1b
spec:
  perNodeBlockSize: 1
  subnet: 192.168.1.1/32
status:
  allocations:
  - endIP: 192.168.1.1
    nodeName: kind-control-plane
    startIP: 192.168.1.1
IPPool /31
apiVersion: nv-ipam.nvidia.com/v1alpha1
kind: IPPool
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"nv-ipam.nvidia.com/v1alpha1","kind":"IPPool","metadata":{"annotations":{},"name":"pool1","namespace":"kube-system"},"spec":{"perNodeBlockSize":1,"subnet":"192.168.1.1/31"}}
  creationTimestamp: "2024-10-14T16:44:59Z"
  generation: 17
  name: pool1
  namespace: kube-system
  resourceVersion: "16586"
  uid: b43c059a-9364-4fbc-b945-1a1f017ddb1b
spec:
  perNodeBlockSize: 1
  subnet: 192.168.1.1/31
status:
  allocations:
  - endIP: 192.168.1.1
    nodeName: kind-control-plane
    startIP: 192.168.1.1
  - endIP: 192.168.1.0
    nodeName: kind-worker
    startIP: 192.168.1.0
CIDRPool /32
apiVersion: nv-ipam.nvidia.com/v1alpha1
kind: CIDRPool
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"nv-ipam.nvidia.com/v1alpha1","kind":"CIDRPool","metadata":{"annotations":{},"name":"pool1","namespace":"kube-system"},"spec":{"cidr":"192.168.100.0/24","perNodeNetworkPrefix":32,"staticAllocations":[{"prefix":"192.168.100.0/32"}]}}
  creationTimestamp: "2024-10-14T16:08:21Z"
  generation: 9
  name: pool1
  namespace: kube-system
  resourceVersion: "17155"
  uid: 1a90011c-e373-4ed7-bfd9-8bf1d9935a76
spec:
  cidr: 192.168.100.0/24
  perNodeNetworkPrefix: 32
  staticAllocations:
  - prefix: 192.168.100.0/32
status:
  allocations:
  - nodeName: kind-control-plane
    prefix: 192.168.100.1/32
  - nodeName: kind-worker
    prefix: 192.168.100.2/32
  - nodeName: kind-worker2
    prefix: 192.168.100.3/32
  - nodeName: kind-worker3
    prefix: 192.168.100.4/32
CIDRPool /128
apiVersion: nv-ipam.nvidia.com/v1alpha1
kind: CIDRPool
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"nv-ipam.nvidia.com/v1alpha1","kind":"CIDRPool","metadata":{"annotations":{},"name":"pool1","namespace":"kube-system"},"spec":{"cidr":"fd52:2eb5:44::100/128","perNodeNetworkPrefix":128}}
  creationTimestamp: "2024-10-14T16:08:21Z"
  generation: 11
  name: pool1
  namespace: kube-system
  resourceVersion: "17745"
  uid: 1a90011c-e373-4ed7-bfd9-8bf1d9935a76
spec:
  cidr: fd52:2eb5:44::100/128
  perNodeNetworkPrefix: 128
status:
  allocations:
  - nodeName: kind-control-plane
    prefix: fd52:2eb5:44::100/128

perNodeBlockSize: 1 - useful when you need to deploy one and only one instance of a service per node and you need to make sure that this instance is always have the same predictable IP.

CIDRPool /32 - useful to assign IPs for loopback interfaces on routers

@coveralls
Copy link

coveralls commented Oct 14, 2024

Coverage Status

coverage: 72.493% (+2.0%) from 70.448%
when pulling 07ef882 on ykulazhenkov:pr-single-ip-pools
into f85a716 on Mellanox:main.

Copy link
Member

@vasrem vasrem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

A couple of questions and nits

pkg/ip/cidr.go Show resolved Hide resolved
pkg/ipam-controller/allocator/allocator.go Outdated Show resolved Hide resolved
pkg/ipam-controller/allocator/allocator.go Outdated Show resolved Hide resolved
pkg/ipam-controller/allocator/allocator_test.go Outdated Show resolved Hide resolved
- Add support for /31(/127) and /32(/128) subnets
- Add single IP allocations
@ykulazhenkov
Copy link
Collaborator Author

@vasrem Thanks for the review! I addressed your comments.

README.md Show resolved Hide resolved
@ykulazhenkov ykulazhenkov merged commit 0db060c into Mellanox:main Oct 15, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants