forked from cilium/cilium
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcell.go
More file actions
92 lines (76 loc) · 2.78 KB
/
Copy pathcell.go
File metadata and controls
92 lines (76 loc) · 2.78 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package ipamcell
import (
"github.com/cilium/hive/cell"
ipamrestapi "github.com/cilium/cilium/api/v1/server/restapi/ipam"
"github.com/cilium/cilium/daemon/k8s"
"github.com/cilium/cilium/pkg/datapath/linux/sysctl"
datapathOption "github.com/cilium/cilium/pkg/datapath/option"
datapathTypes "github.com/cilium/cilium/pkg/datapath/types"
"github.com/cilium/cilium/pkg/endpointmanager"
"github.com/cilium/cilium/pkg/ipam"
ipamapi "github.com/cilium/cilium/pkg/ipam/api"
ipamMetadata "github.com/cilium/cilium/pkg/ipam/metadata"
"github.com/cilium/cilium/pkg/ipmasq"
k8sClient "github.com/cilium/cilium/pkg/k8s/client"
"github.com/cilium/cilium/pkg/k8s/watchers"
"github.com/cilium/cilium/pkg/mtu"
"github.com/cilium/cilium/pkg/node"
"github.com/cilium/cilium/pkg/nodediscovery"
"github.com/cilium/cilium/pkg/option"
)
// Cell provides access to the IP address management
var Cell = cell.Module(
"ipam",
"IP Address Management",
cell.Provide(newIPAddressManager),
cell.Provide(newIPAMAPIHandler),
// IPAM metadata manager, determines which IPAM pool a pod should allocate from
ipamMetadata.Cell,
)
type ipamParams struct {
cell.In
AgentConfig *option.DaemonConfig
NodeAddressing datapathTypes.NodeAddressing
LocalNodeStore *node.LocalNodeStore
K8sEventReporter *watchers.K8sEventReporter
NodeResource k8s.LocalCiliumNodeResource
MTU mtu.MTU
Clientset k8sClient.Clientset
IPAMMetadataManager ipamMetadata.Manager
NodeDiscovery *nodediscovery.NodeDiscovery
Sysctl sysctl.Sysctl
IPMasqAgent *ipmasq.IPMasqAgent
}
func newIPAddressManager(params ipamParams) *ipam.IPAM {
return ipam.NewIPAM(params.NodeAddressing, params.AgentConfig, params.NodeDiscovery, params.LocalNodeStore, params.K8sEventReporter, params.NodeResource, params.MTU, params.Clientset, params.IPAMMetadataManager, params.Sysctl, params.IPMasqAgent)
}
type ipamAPIHandlerParams struct {
cell.In
IPAM *ipam.IPAM
EndpointManager endpointmanager.EndpointManager
}
type ipamAPIHandlerOut struct {
cell.Out
IpamDeleteIpamIPHandler ipamrestapi.DeleteIpamIPHandler
IpamPostIpamHandler ipamrestapi.PostIpamHandler
IpamPostIpamIPHandler ipamrestapi.PostIpamIPHandler
}
func newIPAMAPIHandler(params ipamAPIHandlerParams) ipamAPIHandlerOut {
if option.Config.DatapathMode == datapathOption.DatapathModeLBOnly {
return ipamAPIHandlerOut{}
}
return ipamAPIHandlerOut{
IpamDeleteIpamIPHandler: &ipamapi.IpamDeleteIpamIPHandler{
IPAM: params.IPAM,
EndpointManager: params.EndpointManager,
},
IpamPostIpamHandler: &ipamapi.IpamPostIpamHandler{
IPAM: params.IPAM,
},
IpamPostIpamIPHandler: &ipamapi.IpamPostIpamIPHandler{
IPAM: params.IPAM,
},
}
}