Skip to content

Refactor Metallb svc controller and speaker to support dual-stack - #1065

Merged
fedepaol merged 3 commits into
metallb:mainfrom
msherif1234:dual_stack
Nov 24, 2021
Merged

fedepaol merged 3 commits into
metallb:mainfrom
msherif1234:dual_stack

Conversation

@msherif1234

@msherif1234 msherif1234 commented Nov 19, 2021 •

Copy link
Copy Markdown
Contributor

Refactor Metallb service controller to support dual stack, this PR is continuation of the effort started by
PR #727 while trying to share most of the code between single stack and dual stack services, also it modifies to speaker code to return more than one address instead of one Loadbalancer IP.

- Testing

  • bring up kind dual-stack cluster
  • create metallb configmap
 k -n metallb-system get configmap config -o yaml
apiVersion: v1
data:
  config: |
    peers:
    - peer-address: fc00:f853:ccd:e793::5
      peer-asn: 64512
      my-asn: 64512
    address-pools:
    - name: dev-env-bgp
      protocol: bgp
      addresses:
      - 192.168.10.0/24
      - fc00:f853:0ccd:e799::/124
kind: ConfigMap
  • create dual-stack svc
 k create -f dev-env/testsvc_dualstack.yaml 
  • loadbalancer svc
 k get svc nginx 
NAME    TYPE           CLUSTER-IP   EXTERNAL-IP                         PORT(S)        AGE
nginx   LoadBalancer   10.96.6.42   192.168.10.0,fc00:f853:ccd:e799::   80:30253/TCP   18s
 cat testsvc_dualstack.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1
        ports:
        - name: http
          containerPort: 80

---
apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  ipFamilyPolicy: PreferDualStack
  ipFamilies:
  - IPv4
  - IPv6
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: nginx
  type: LoadBalancer

@msherif1234
msherif1234 force-pushed the dual_stack branch 2 times, most recently from c93e057 to 1c79047 Compare November 19, 2021 12:39
@msherif1234 msherif1234 changed the title WIP refactor controller to allow dual-stack support WIP Refactor Metallb svc controller and speaker to support dual-stack Nov 19, 2021
@msherif1234
msherif1234 force-pushed the dual_stack branch 2 times, most recently from 3a85781 to 96db081 Compare November 20, 2021 12:14
@msherif1234 msherif1234 changed the title WIP Refactor Metallb svc controller and speaker to support dual-stack Refactor Metallb svc controller and speaker to support dual-stack Nov 20, 2021
@msherif1234
msherif1234 force-pushed the dual_stack branch 8 times, most recently from 6a0203e to b2b80fb Compare November 21, 2021 13:18

@fedepaol fedepaol left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did a quick round over the controller, haven't looked at the speaker or tests yet.

Comment thread internal/allocator/allocator.go Resolved
Comment thread controller/service.go Resolved
Comment thread controller/service.go Resolved
Comment thread controller/service.go Resolved
Comment thread controller/service.go Resolved
Comment thread internal/allocator/allocator.go Resolved
Comment thread internal/allocator/allocator.go Resolved
Comment thread internal/allocator/allocator.go Resolved
Comment thread internal/allocator/allocator.go Resolved
Comment thread internal/allocator/allocator.go Resolved
Comment thread controller/service.go Resolved
Comment thread controller/service.go Resolved
Comment thread controller/service.go Resolved
Comment thread controller/service.go Resolved
Comment thread controller/service.go Resolved
Comment thread internal/ipfamily/ipfamily.go Resolved
Comment thread speaker/layer2_controller.go Resolved
Comment thread speaker/main.go Resolved
Comment thread internal/layer2/announcer.go Resolved
Comment thread speaker/main.go Resolved
@fedepaol

Copy link
Copy Markdown
Member

A general comment: we should also extend unit tests to cover dual stack.

@msherif1234
msherif1234 force-pushed the dual_stack branch 2 times, most recently from 07b2a79 to 2705a1c Compare November 22, 2021 15:16
Comment thread controller/service.go Resolved
Comment thread controller/service.go Resolved
Comment thread controller/service.go Resolved
Comment thread controller/service.go Resolved
Comment thread controller/service.go Resolved
Comment thread speaker/layer2_controller.go Resolved
Comment thread speaker/layer2_controller.go Resolved
Comment thread speaker/layer2_controller.go Resolved
Comment thread speaker/main.go Resolved
Comment thread speaker/main.go Resolved
@msherif1234
msherif1234 force-pushed the dual_stack branch 2 times, most recently from b22d9b0 to d157fb9 Compare November 23, 2021 16:33
Comment thread controller/service.go Resolved
Comment thread controller/service.go Resolved
Comment thread internal/allocator/allocator.go Resolved
Comment thread speaker/bgp_controller.go Resolved
Comment thread speaker/layer2_controller.go Resolved
@fedepaol

Copy link
Copy Markdown
Member

LGTM, let's rebase to import the tests and 🤞

@msherif1234
msherif1234 force-pushed the dual_stack branch 3 times, most recently from 8e70dc2 to c1a5c6d Compare November 24, 2021 11:06
… dual-stack support

- update service controller to process multiple loadbalancer and cluster IPs
- update allocator to allow allocating multiple IPs from different address family from the same pool
- added new package ipfamily and unit-test to retrieve address family from addresses and cidr
- update controller and allocator unit-test to handle multiple IPs and added dual-stack test cases
Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
- speaker is changes to return multiple IPs for loadbalancer service
- added new custom IPs equality API
- updated speaker APIs to handle multiple IPs
Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
@fedepaol

Copy link
Copy Markdown
Member

New tests passed, single stack passed.
All comments addressed, the v6 failure is related to the well known flake.
LGTM

@fedepaol
fedepaol merged commit f691c94 into metallb:main Nov 24, 2021
sabinaaledort pushed a commit to sabinaaledort/metallb that referenced this pull request Nov 30, 2021
…tallb#1065)

* Refactor Metallb service controller to handle multiple IPs needed for dual-stack support

- update service controller to process multiple loadbalancer and cluster IPs
- update allocator to allow allocating multiple IPs from different address family from the same pool
- added new package ipfamily and unit-test to retrieve address family from addresses and cidr
- update controller and allocator unit-test to handle multiple IPs and added dual-stack test cases
Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>

* Refactor speaker's bgp and layer2 controllers to support multiple IPs

- speaker is changes to return multiple IPs for loadbalancer service
- added new custom IPs equality API
- updated speaker APIs to handle multiple IPs
Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>

* Enable CI run for dual-stack

Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
@kub3let

kub3let commented Dec 10, 2021

Copy link
Copy Markdown

There is no documentation, testsvc_dualstack.yaml is not in the project.

What does the service deploy need to look like to set dualstack static ip's ?

Like if I want to set the ip's 192.168.1.151 and 68d9:f187:b07b:15c2::151

@msherif1234

Copy link
Copy Markdown
Contributor Author

There is no documentation, testsvc_dualstack.yaml is not in the project.

What does the service deploy need to look like to set dualstack static ip's ?

Like if I want to set the ip's 192.168.1.151 and 68d9:f187:b07b:15c2::151

  • I was asked during review to not commit the dual stack test yaml file since we have dual-stack CI, I added the yaml file in this PR description for referrence.
  • regarding svc static loadbalancer IP assignment, k8s loadbalancer svc API doesn't allow passing multiple loadbalancer IPs, so in dual stack case we will emit and error log when this happens

@kub3let

kub3let commented Dec 11, 2021

Copy link
Copy Markdown

ok then I misunderstood, I will continue to use 2 services.

rata pushed a commit to kinvolk/metallb that referenced this pull request Feb 17, 2022
…tallb#1065)

* Refactor Metallb service controller to handle multiple IPs needed for dual-stack support

- update service controller to process multiple loadbalancer and cluster IPs
- update allocator to allow allocating multiple IPs from different address family from the same pool
- added new package ipfamily and unit-test to retrieve address family from addresses and cidr
- update controller and allocator unit-test to handle multiple IPs and added dual-stack test cases
Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>

* Refactor speaker's bgp and layer2 controllers to support multiple IPs

- speaker is changes to return multiple IPs for loadbalancer service
- added new custom IPs equality API
- updated speaker APIs to handle multiple IPs
Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>

* Enable CI run for dual-stack

Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
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.

3 participants