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

Changes to support ebpf and ipv6 #2945

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions pkg/controller/installation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,20 @@ func validateCustomResource(instance *operatorv1.Installation) error {
}
}

if bpfDataplane && v4pool != nil && v6pool != nil {
return fmt.Errorf("bpf dataplane does not support dual stack")
}

if v4pool != nil {
_, cidr, err := net.ParseCIDR(v4pool.CIDR)
if err != nil {
return fmt.Errorf("ipPool.CIDR(%s) is invalid: %s", v4pool.CIDR, err)
}

if bpfDataplane && instance.Spec.CalicoNetwork.NodeAddressAutodetectionV4 == nil {
return fmt.Errorf("spec.calicoNetwork.nodeAddressAutodetectionV4 is required for the BPF dataplane")
}

if instance.Spec.CNI.Type == operatorv1.PluginCalico {
switch instance.Spec.CNI.IPAM.Type {
case operatorv1.IPAMPluginCalico:
Expand Down Expand Up @@ -240,8 +248,8 @@ func validateCustomResource(instance *operatorv1.Installation) error {
return fmt.Errorf("IPIP encapsulation is not supported by IPv6 pools, but it is set for %s", v6pool.CIDR)
}

if bpfDataplane {
return fmt.Errorf("IPv6 IP pool is specified but eBPF mode does not support IPv6")
if bpfDataplane && instance.Spec.CalicoNetwork.NodeAddressAutodetectionV6 == nil {
return fmt.Errorf("spec.calicoNetwork.nodeAddressAutodetectionV6 is required for the BPF dataplane")
}

// Verify NAT outgoing values.
Expand Down Expand Up @@ -291,10 +299,6 @@ func validateCustomResource(instance *operatorv1.Installation) error {
}
}

if bpfDataplane && instance.Spec.CalicoNetwork.NodeAddressAutodetectionV4 == nil {
return fmt.Errorf("spec.calicoNetwork.nodeAddressAutodetectionV4 is required for the BPF dataplane")
}

if instance.Spec.CalicoNetwork.NodeAddressAutodetectionV4 != nil {
err := validateNodeAddressDetection(instance.Spec.CalicoNetwork.NodeAddressAutodetectionV4)
if err != nil {
Expand Down
34 changes: 32 additions & 2 deletions pkg/controller/installation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var _ = Describe("Installation validation tests", func() {
Expect(err).NotTo(HaveOccurred())
})

It("should prevent IPv6 if BPF is enabled", func() {
It("should allow IPv6 if BPF is enabled", func() {
bpf := operator.LinuxDataplaneBPF
instance.Spec.CalicoNetwork.LinuxDataplane = &bpf
instance.Spec.CalicoNetwork.IPPools = []operator.IPPool{
Expand All @@ -85,8 +85,38 @@ var _ = Describe("Installation validation tests", func() {
NodeSelector: "all()",
},
}
instance.Spec.CalicoNetwork.NodeAddressAutodetectionV6 = &operator.NodeAddressAutodetection{
CanReach: "2001:4860:4860::8888",
}
err := validateCustomResource(instance)
Expect(err).To(BeNil())
})

It("should not allow dual stack (both IPv4 and IPv6) if BPF is enabled", func() {
bpf := operator.LinuxDataplaneBPF
instance.Spec.CalicoNetwork.LinuxDataplane = &bpf
instance.Spec.CalicoNetwork.IPPools = []operator.IPPool{
{
CIDR: "1eef::/64",
NATOutgoing: operator.NATOutgoingEnabled,
Encapsulation: operator.EncapsulationNone,
NodeSelector: "all()",
},
{
CIDR: "192.168.0.0/27",
Encapsulation: operator.EncapsulationNone,
NATOutgoing: operator.NATOutgoingEnabled,
NodeSelector: "all()",
},
}
instance.Spec.CalicoNetwork.NodeAddressAutodetectionV6 = &operator.NodeAddressAutodetection{
CanReach: "2001:4860:4860::8888",
}
instance.Spec.CalicoNetwork.NodeAddressAutodetectionV4 = &operator.NodeAddressAutodetection{
CanReach: "8.8.8.8",
}
err := validateCustomResource(instance)
Expect(err).To(MatchError("IPv6 IP pool is specified but eBPF mode does not support IPv6"))
Expect(err).To(MatchError("bpf dataplane does not support dual stack"))
})

It("should allow IPv6 VXLAN", func() {
Expand Down
16 changes: 8 additions & 8 deletions pkg/crds/calico/crd.projectcalico.org_bgpfilters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ spec:
type: string
matchOperator:
type: string
source:
type: string
required:
- action
- cidr
- matchOperator
type: object
type: array
exportV6:
Expand All @@ -66,10 +66,10 @@ spec:
type: string
matchOperator:
type: string
source:
type: string
required:
- action
- cidr
- matchOperator
type: object
type: array
importV4:
Expand All @@ -85,10 +85,10 @@ spec:
type: string
matchOperator:
type: string
source:
type: string
required:
- action
- cidr
- matchOperator
type: object
type: array
importV6:
Expand All @@ -104,10 +104,10 @@ spec:
type: string
matchOperator:
type: string
source:
type: string
required:
- action
- cidr
- matchOperator
type: object
type: array
type: object
Expand Down
23 changes: 22 additions & 1 deletion pkg/crds/calico/crd.projectcalico.org_felixconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,25 @@ spec:
[Default: unset - means logs are emitted when BPFLogLevel id debug
and BPFLogFilters not set.]'
type: string
bpfConnectTimeLoadBalancing:
description: 'BPFConnectTimeLoadBalancing when in BPF mode, controls
whether Felix installs the connect-time load balancer. The connect-time
load balancer is required for the host to be able to reach Kubernetes
services and it improves the performance of pod-to-service connections.When
set to TCP, connect time load balancing is available only for services
with TCP ports. [Default: TCP]'
enum:
- TCP
- Enabled
- Disabled
type: string
bpfConnectTimeLoadBalancingEnabled:
description: 'BPFConnectTimeLoadBalancingEnabled when in BPF mode,
controls whether Felix installs the connection-time load balancer. The
connect-time load balancer is required for the host to be able to
reach Kubernetes services and it improves the performance of pod-to-service
connections. The only reason to disable it is for debugging purposes. [Default:
connections. The only reason to disable it is for debugging purposes.
This will be deprecated. Use BPFConnectTimeLoadBalancing [Default:
true]'
type: boolean
bpfDSROptoutCIDRs:
Expand Down Expand Up @@ -138,6 +151,14 @@ spec:
conntrack in BPF mode for workloads and services. [Default: true
- bypass Linux conntrack]'
type: boolean
bpfHostNetworkedNATWithoutCTLB:
description: 'BPFHostNetworkedNATWithoutCTLB when in BPF mode, controls
whether Felix does a NAT without CTLB. This along with BPFConnectTimeLoadBalancing
determines the CTLB behavior. [Default: Enabled]'
enum:
- Enabled
- Disabled
type: string
bpfKubeProxyEndpointSlicesEnabled:
description: BPFKubeProxyEndpointSlicesEnabled in BPF mode, controls
whether Felix's embedded kube-proxy accepts EndpointSlices or not.
Expand Down