-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
cell.go
53 lines (44 loc) · 1.69 KB
/
cell.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package tunnel
import (
"github.com/cilium/cilium/pkg/defaults"
"github.com/cilium/cilium/pkg/hive/cell"
"github.com/cilium/cilium/pkg/option"
)
// Cell is a cell that provides the parameters for the Cilium tunnel,
// based on user configuration and requests from external modules.
var Cell = cell.Module(
"datapath-tunnel-config",
"Tunneling configurations",
cell.Config(userCfg{TunnelProtocol: defaults.TunnelProtocol}),
cell.Provide(
newConfig,
// Provide the datapath options.
Config.datapathConfigProvider,
// Enable tunnel configuration when it is the primary routing mode.
func(dcfg *option.DaemonConfig) EnablerOut {
return NewEnabler(dcfg.TunnelingEnabled())
},
// Enable tunnel configuration when DSR Geneve is enabled (this is currently
// handled here, as the corresponding logic has not yet been modularized).
func(dcfg *option.DaemonConfig) EnablerOut {
return NewEnabler(
(dcfg.EnableNodePort ||
dcfg.KubeProxyReplacement == option.KubeProxyReplacementStrict ||
dcfg.KubeProxyReplacement == option.KubeProxyReplacementTrue) &&
dcfg.LoadBalancerUsesDSR() &&
dcfg.LoadBalancerDSRDispatch == option.DSRDispatchGeneve,
// The datapath logic takes care of the MTU overhead. So no need to
// take it into account here.
// See encap_geneve_dsr_opt[4,6] in nodeport.h
WithoutMTUAdaptation(),
)
},
// Enable tunnel configuration when High Scale IPCache is enabled (this is
// currently handled here, as the corresponding logic has not yet been modularized).
func(dcfg *option.DaemonConfig) EnablerOut {
return NewEnabler(dcfg.EnableHighScaleIPcache)
},
),
)