whereabouts icon indicating copy to clipboard operation
whereabouts copied to clipboard

Add support for dualstack / multiple IP ranges

Open Ayush21298 opened this issue 3 years ago • 20 comments

New Feature

Motivation

This PR adds support for IPv4/IPv6 dual-stack and multiple IP assignment

Feature proposal: #237

Changes

  • Introduced a new type RangeConfiguration in pkg/types/types.go for encapsulating configurations of range for IP assignment
  • Add new field IPRanges []RangeConfiguration in IPAMConfig for handling multiple IP ranges
  • Update config.go to work with IPRanges instead of IPAM.Range, ...
  • Use RangeConfiguration in allocate.AssignIP instead of IPAMConfig
  • Integrate IPRanges with etcd's IP Management
  • Integrate IPRanges with kubernetes' IP Management
  • Update whereabouts' logic to assign multiple new IPs to a pod based on a list of new IPs returned by IP Management module
  • Update function definition of garbageCollector to match with the changes in definition of wbclient.IPManagement

Tasks

Project management

  • [x] Created a related issue
  • [x] Added proper labels to the issue @dougbtv
  • [x] Assigned yourself as the assignee @dougbtv
  • [x] Created a PR for design proposal
  • [x] Finalized and merged design proposal @dougbtv @maiqueb

Code management

  • [x] Update IPAM structure
  • [x] Backward compatibility
  • [x] Add feature to support dual-stack
  • [x] Add feature to support multiple IP ranges
  • [x] Manual testing for above feature
  • [x] Update old test cases
  • [x] Add new test cases for the added features
  • [x] Update documentation
  • [x] Checked for mistakenly committed files

Closes #212

Ayush21298 avatar Jul 17 '22 16:07 Ayush21298

Test for multiple IP assignment

NAD

apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
  name: whereabouts-conf
spec:
  config: '{
      "cniVersion": "0.3.0",
      "name": "whereaboutsexample",
      "type": "macvlan",
      "master": "eth0",
      "mode": "bridge",
      "ipam": {
        "type": "whereabouts",
        "ipRanges": [{
          "range": "10.10.10.10/24",
          "range_start": "10.10.10.20",
          "range_end": "10.10.10.200"
        }, {
          "range": "11.11.11.11/24",
          "range_start": "11.11.11.20",
          "range_end": "11.11.11.200"
        }]
      }
    }'

Pod IP Config

5: net1@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether aa:ac:37:3a:1a:91 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.10.10.20/24 brd 10.10.10.255 scope global net1
       valid_lft forever preferred_lft forever
    inet 11.11.11.20/24 brd 11.11.11.255 scope global net1
       valid_lft forever preferred_lft forever
    inet6 fe80::a8ac:37ff:fe3a:1a91/64 scope link 
       valid_lft forever preferred_lft forever

Ayush21298 avatar Jul 17 '22 16:07 Ayush21298

Test for IPv4/IPv6 dual-stack

NAD

apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
  name: whereabouts-conf
spec:
  config: '{
      "cniVersion": "0.3.0",
      "name": "whereaboutsexample",
      "type": "macvlan",
      "master": "eth0",
      "mode": "bridge",
      "ipam": {
        "type": "whereabouts",
        "ipRanges": [{
          "range": "10.10.10.10/24",
          "range_start": "10.10.10.20",
          "range_end": "10.10.10.200"
        }, {
          "range": "2001::1/64",
          "range_start": "2001::16",
          "range_end": "2001::64"
        }]
      }
    }'

Pod IP Config

5: net1@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether ee:f1:0a:a4:f3:cd brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.10.10.20/24 brd 10.10.10.255 scope global net1
       valid_lft forever preferred_lft forever
    inet6 2001::16/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::ecf1:aff:fea4:f3cd/64 scope link 
       valid_lft forever preferred_lft forever

Ayush21298 avatar Jul 17 '22 16:07 Ayush21298

@Ayush21298 Hi, is there any plan to support dual stack in the recent release?

zhouke1991 avatar Aug 18 '22 09:08 zhouke1991

@Ayush21298 Hi, is there any plan to support dual stack in the recent release?

@hhhybb Hi, I'll require some time to proceed with fixing some minor issues, adding backward compatibility and testing. If backward compatibility is not a major requirement, you can use this branch for basic DualStack functionality :)

Ayush21298 avatar Aug 18 '22 11:08 Ayush21298

@Ayush21298 Hi, is there any plan to support dual stack in the recent release?

@hhhybb Hi, I'll require some time to proceed with fixing some minor issues, adding backward compatibility and testing. If backward compatibility is not a major requirement, you can use this branch for basic DualStack functionality :)

@Ayush21298 Thanks for your reply, I have installed the old versions in the production environment and need backward compatibility when upgrading. I am looking forward to it can be merged into master. Thanks for your efforts.

zhouke1991 avatar Aug 21 '22 06:08 zhouke1991

Pull Request Test Coverage Report for Build 3385784200

  • 70 of 86 (81.4%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.5%) to 70.19%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/allocate/allocate.go 0 1 0.0%
pkg/controlloop/dummy_controller.go 2 3 66.67%
pkg/config/config.go 35 41 85.37%
pkg/controlloop/pod.go 20 28 71.43%
<!-- Total: 70 86
Totals Coverage Status
Change from base Build 3250004817: 0.5%
Covered Lines: 923
Relevant Lines: 1315

💛 - Coveralls

coveralls avatar Aug 25 '22 13:08 coveralls

Test for IPv4/IPv6 dual-stack along with Old Range configuration

NAD

apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
  name: whereabouts-conf
spec:
  config: '{
      "cniVersion": "0.3.0",
      "name": "whereaboutsexample",
      "type": "macvlan",
      "master": "eth0",
      "mode": "bridge",
      "ipam": {
        "type": "whereabouts",
        "range": "12.12.12.12/24",
        "ipRanges": [{
          "range": "10.10.10.10/24",
          "range_start": "10.10.10.20",
          "range_end": "10.10.10.200"
        }, {
          "range": "2001::1/64",
          "range_start": "2001::16",
          "range_end": "2001::64"
        }]
      }
    }'

Pod IP Config

5: net1@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 8e:58:0a:33:88:10 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.10.10.20/24 brd 10.10.10.255 scope global net1
       valid_lft forever preferred_lft forever
    inet 12.12.12.1/24 brd 12.12.12.255 scope global net1
       valid_lft forever preferred_lft forever
    inet6 2001::16/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::8c58:aff:fe33:8810/64 scope link 
       valid_lft forever preferred_lft forever

Ayush21298 avatar Aug 25 '22 13:08 Ayush21298

Test for IPv4/IPv6 dual-stack along with Old Range configuration

NAD

apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
  name: whereabouts-conf
spec:
  config: '{
      "cniVersion": "0.3.0",
      "name": "whereaboutsexample",
      "type": "macvlan",
      "master": "eth0",
      "mode": "bridge",
      "ipam": {
        "type": "whereabouts",
        "range": "12.12.12.12/24",
        "ipRanges": [{
          "range": "10.10.10.10/24",
          "range_start": "10.10.10.20",
          "range_end": "10.10.10.200"
        }, {
          "range": "2001::1/64",
          "range_start": "2001::16",
          "range_end": "2001::64"
        }]
      }
    }'

Pod IP Config

5: net1@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 8e:58:0a:33:88:10 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.10.10.20/24 brd 10.10.10.255 scope global net1
       valid_lft forever preferred_lft forever
    inet 12.12.12.1/24 brd 12.12.12.255 scope global net1
       valid_lft forever preferred_lft forever
    inet6 2001::16/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::8c58:aff:fe33:8810/64 scope link 
       valid_lft forever preferred_lft forever

Cool. Please add an e2e test with this behavior, by introducing a new context in here.

maiqueb avatar Aug 25 '22 13:08 maiqueb

Cool. Please add an e2e test with this behavior, by introducing a new context in here.

Sure :) I wanted to do that before the meeting, but got a bit delayed :sweat_smile:

Ayush21298 avatar Aug 25 '22 13:08 Ayush21298

Cool. Please add an e2e test with this behavior, by introducing a new context in here.

@maiqueb I have added both e2e test cases as well as unit tests for whereabouts' module :) Please review them when you are available ^^

Ayush21298 avatar Sep 11 '22 17:09 Ayush21298

@dougbtv Hi, I would like to start using multiple IP ranges right now, judging by the comments there is already a working version of this feature https://github.com/k8snetworkplumbingwg/whereabouts/pull/60 Can someone confirm that this PR is already in use by someone and is it stable?

And also if I now use https://github.com/k8snetworkplumbingwg/whereabouts/pull/60 Will it be possible to migrate to https://github.com/k8snetworkplumbingwg/whereabouts/pull/250 are they compatible ?

kmlebedev avatar Sep 26 '22 07:09 kmlebedev

#225 is merged @Ayush21298 we're good for a rebase, thanks!

dougbtv avatar Sep 30 '22 14:09 dougbtv

@kmlebedev -- #60 was rejected (my apologies to the contributor) so there's no guarantee of compatibility, my apologies but it was never in master. So you might need to figure out your own migration path.

dougbtv avatar Sep 30 '22 14:09 dougbtv

#225 is merged @Ayush21298 we're good for a rebase, thanks!

@dougbtv Thanks for letting me know. I'll notify you after rebasing :)

Ayush21298 avatar Sep 30 '22 15:09 Ayush21298

@dougbtv @maiqueb I have rebased the code :) Can you please have a look ?

Ayush21298 avatar Oct 01 '22 16:10 Ayush21298

@maiqueb Thank you so much for your review :)

I intended to rewrite the history properly once I got review for the overall structure of the code, since the changes were made iteratively due to some other PRs which had major changes in the code-base.

Thank you so much for putting an effort to review the PR commit-wise irrespective of the presence of hindrances like conflict resolution commits etc.

I'll update the code-base to address your review comments and then rewrite the history so that the updates can be included/excluded in the proper commits where they should be placed :)

Ayush21298 avatar Oct 05 '22 15:10 Ayush21298

@maiqueb Thank you so much for your review :)

I intended to rewrite the history properly once I got review for the overall structure of the code, since the changes were made iteratively due to some other PRs which had major changes in the code-base.

Thank you so much for putting an effort to review the PR commit-wise irrespective of the presence of hindrances like conflict resolution commits etc.

I'll update the code-base to address your review comments and then rewrite the history so that the updates can be included/excluded in the proper commits where they should be placed :)

Perfect! Just let me know when this becomes ready to be looked at.

maiqueb avatar Oct 05 '22 15:10 maiqueb

Perfect! Just let me know when this becomes ready to be looked at.

Sure. Thanks you so much again for your review :)

Ayush21298 avatar Oct 05 '22 15:10 Ayush21298

Oh I can't request review from both @dougbtv and @maiqueb at the same time :thinking:

Ayush21298 avatar Oct 15 '22 12:10 Ayush21298

@maiqueb I have squashed the code, re-based and rewritten the commit history :)

Most of your comments were addressed by this and for rest of them I did the appropriate changes in the code.

Please review it when you are available :)

Secondly, if you want, we can squash the commits more, but that will make the commit a bit complex for reviewing. Let me know if you want me to do that. Thanks :)

Ayush21298 avatar Oct 15 '22 12:10 Ayush21298

@maiqueb I have added a separate new commit with the changes for addressing the review comment for the ease in review. Once I get a green light from you, I'll add the respective sections in appropriate commits. Thanks :)

Ayush21298 avatar Oct 25 '22 16:10 Ayush21298

@maiqueb Thanks for your opinions :) I have removed the "old range" completely as we discussed in the meeting, addressed all your comments and added the related fixes in their respective commits. Please review it when you are available :)

Ayush21298 avatar Oct 29 '22 08:10 Ayush21298

@maiqueb Thanks for your review again :) Updated the code in respective commits to address the comments ^^

Ayush21298 avatar Nov 03 '22 11:11 Ayush21298

which release dual stack feature is available.

devenderkamble2101 avatar Nov 03 '22 13:11 devenderkamble2101

which release dual stack feature is available.

Hopefully from the next release :)

@dougbtv and @maiqueb can tell better ^^

Ayush21298 avatar Nov 03 '22 13:11 Ayush21298