github.com/elfadel/cilium@v1.6.12/pkg/datapath/node.go (about) 1 // Copyright 2018-2019 Authors of Cilium 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package datapath 16 17 import ( 18 "net" 19 20 "github.com/cilium/cilium/pkg/cidr" 21 "github.com/cilium/cilium/pkg/mtu" 22 "github.com/cilium/cilium/pkg/node" 23 ) 24 25 // LocalNodeConfiguration represents the configuration of the local node 26 type LocalNodeConfiguration struct { 27 // MtuConfig is the MTU configuration of the node. 28 // 29 // This field is immutable at runtime. The value will not change in 30 // subsequent calls to NodeConfigurationChanged(). 31 MtuConfig mtu.Configuration 32 33 // AuxiliaryPrefixes is the list of auxiliary prefixes that should be 34 // configured in addition to the node PodCIDR 35 // 36 // This field is mutable. The implementation of 37 // NodeConfigurationChanged() must adjust the routes accordingly. 38 AuxiliaryPrefixes []*cidr.CIDR 39 40 // EnableIPv4 enables use of IPv4. Routing to the IPv4 allocation CIDR 41 // of other nodes must be enabled. 42 // 43 // This field is immutable at runtime. The value will not change in 44 // subsequent calls to NodeConfigurationChanged(). 45 EnableIPv4 bool 46 47 // EnableIPv6 enables use of IPv6. Routing to the IPv6 allocation CIDR 48 // of other nodes must be enabled. 49 // 50 // This field is immutable at runtime. The value will not change in 51 // subsequent calls to NodeConfigurationChanged(). 52 EnableIPv6 bool 53 54 // UseSingleClusterRoute enables the use of a single cluster-wide route 55 // to direct traffic from the host into the Cilium datapath. This 56 // avoids the requirement to install a separate route for each node 57 // CIDR and can thus improve the overhead when operating large clusters 58 // with significant node event churn due to auto-scaling. 59 // 60 // Use of UseSingleClusterRoute must be compatible with 61 // EnableAutoDirectRouting. When both are enabled, any direct node 62 // route must take precedence over the cluster-wide route as per LPM 63 // routing definition. 64 // 65 // This field is mutable. The implementation of 66 // NodeConfigurationChanged() must adjust the routes accordingly. 67 UseSingleClusterRoute bool 68 69 // EnableEncapsulation enables use of encapsulation in communication 70 // between nodes. 71 // 72 // This field is immutable at runtime. The value will not change in 73 // subsequent calls to NodeConfigurationChanged(). 74 EnableEncapsulation bool 75 76 // EnableAutoDirectRouting enables the use of direct routes for 77 // communication between nodes if two nodes have direct L2 78 // connectivity. 79 // 80 // EnableAutoDirectRouting must be compatible with EnableEncapsulation 81 // and must provide a fallback to use encapsulation if direct routing 82 // is not feasible and encapsulation is enabled. 83 // 84 // This field is immutable at runtime. The value will not change in 85 // subsequent calls to NodeConfigurationChanged(). 86 EnableAutoDirectRouting bool 87 88 // EnableLocalNodeRoute enables installation of the route which points 89 // the allocation prefix of the local node. Disabling this option is 90 // useful when another component is responsible for the routing of the 91 // allocation CIDR IPs into Cilium endpoints. 92 EnableLocalNodeRoute bool 93 94 // EnableIPSec enables IPSec routes 95 EnableIPSec bool 96 97 // EncryptNode enables encrypting NodeIP traffic requires EnableIPSec 98 EncryptNode bool 99 100 // IPv4PodSubnets is a list of IPv4 subnets that pod IPs are assigned from 101 // these are then used when encryption is enabled to configure the node 102 // for encryption over these subnets at node initialization. 103 IPv4PodSubnets []*net.IPNet 104 105 // IPv6PodSubnets is a list of IPv6 subnets that pod IPs are assigned from 106 // these are then used when encryption is enabled to configure the node 107 // for encryption over these subnets at node initialization. 108 IPv6PodSubnets []*net.IPNet 109 } 110 111 // NodeHandler handles node related events such as addition, update or deletion 112 // of nodes or changes to the local node configuration. 113 // 114 // Node events apply to the local node as well as to remote nodes. The 115 // implementation can differ between the own local node and remote nodes by 116 // calling node.IsLocal(). 117 type NodeHandler interface { 118 // NodeAdd is called when a node is discovered for the first time. 119 NodeAdd(newNode node.Node) error 120 121 // NodeUpdate is called when a node definition changes. Both the old 122 // and new node definition is provided. NodeUpdate() is never called 123 // before NodeAdd() is called for a particular node. 124 NodeUpdate(oldNode, newNode node.Node) error 125 126 // NodeDelete is called after a node has been deleted 127 NodeDelete(node node.Node) error 128 129 // NodeValidateImplementation is called to validate the implementation 130 // of the node in the datapath 131 NodeValidateImplementation(node node.Node) error 132 133 // NodeConfigurationChanged is called when the local node configuration 134 // has changed 135 NodeConfigurationChanged(config LocalNodeConfiguration) error 136 }