Documentation ¶
Overview ¶
Copyright 2018 Tigera Inc
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2015-2018 Tigera Inc ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func AddIPAM(conf types.NetConf, args *skel.CmdArgs, logger *logrus.Entry) (*current.Result, error)
- func AddIgnoreUnknownArgs() error
- func CleanUpNamespace(args *skel.CmdArgs, logger *logrus.Entry) error
- func ConfigureLogging(logLevel string)
- func CreateClient(conf types.NetConf) (client.Interface, error)
- func CreateOrUpdate(ctx context.Context, client client.Interface, wep *api.WorkloadEndpoint) (*api.WorkloadEndpoint, error)
- func CreateResultFromEndpoint(wep *api.WorkloadEndpoint) (*current.Result, error)
- func DeleteIPAM(conf types.NetConf, args *skel.CmdArgs, logger *logrus.Entry) error
- func DetermineNodename(conf types.NetConf) (nodename string)
- func DoNetworking(args *skel.CmdArgs, conf types.NetConf, result *current.Result, ...) (hostVethName, contVethMAC string, err error)
- func GetHandleID(netName string, containerID string, workload string) (string, error)
- func Min(a, b int) int
- func PopulateEndpointNets(wep *api.WorkloadEndpoint, result *current.Result) error
- func ReleaseIPAllocation(logger *logrus.Entry, conf types.NetConf, args *skel.CmdArgs)
- func ReplaceHostLocalIPAMPodCIDRs(logger *logrus.Entry, stdinData map[string]interface{}, ...) error
- func ResolvePools(ctx context.Context, c client.Interface, pools []string, isv4 bool) ([]cnet.IPNet, error)
- func SanitizeMesosLabel(s string) string
- func SetupRoutes(hostVeth netlink.Link, result *current.Result) error
- func ValidateNetworkName(name string) error
- type WEPIdentifiers
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AddIPAM ¶
AddIPAM calls through to the configured IPAM plugin. It also contains IPAM plugin specific logic based on the configured plugin.
func AddIgnoreUnknownArgs ¶
func AddIgnoreUnknownArgs() error
AddIgnoreUnknownArgs appends the 'IgnoreUnknown=1' option to CNI_ARGS before calling the IPAM plugin. Otherwise, it will complain about the Kubernetes arguments. See https://github.com/kubernetes/kubernetes/pull/24983
func CleanUpNamespace ¶
CleanUpNamespace deletes the devices in the network namespace.
func ConfigureLogging ¶
func ConfigureLogging(logLevel string)
Set up logging for both Calico and libcalico using the provided log level,
func CreateOrUpdate ¶
func CreateOrUpdate(ctx context.Context, client client.Interface, wep *api.WorkloadEndpoint) (*api.WorkloadEndpoint, error)
CreateOrUpdate creates the WorkloadEndpoint if ResourceVersion is not specified, or Update if it's specified.
func CreateResultFromEndpoint ¶
func CreateResultFromEndpoint(wep *api.WorkloadEndpoint) (*current.Result, error)
CreateResultFromEndpoint takes a WorkloadEndpoint, extracts IP information and populates that into a CNI Result.
func DeleteIPAM ¶
DeleteIPAM calls IPAM plugin to release the IP address. It also contains IPAM plugin specific logic based on the configured plugin, and is the logical counterpart to AddIPAM.
func DetermineNodename ¶
DetermineNodename gets the node name, in order of priority: 1. Nodename field in NetConf 2. Nodename from the file /var/lib/calico/nodename 3. Hostname field in NetConf (DEPRECATED). 4. OS Hostname.
func DoNetworking ¶
func DoNetworking( args *skel.CmdArgs, conf types.NetConf, result *current.Result, logger *logrus.Entry, desiredVethName string, routes []*net.IPNet, ) (hostVethName, contVethMAC string, err error)
DoNetworking performs the networking for the given config and IPAM result
func GetHandleID ¶
func PopulateEndpointNets ¶
func PopulateEndpointNets(wep *api.WorkloadEndpoint, result *current.Result) error
PopulateEndpointNets takes a WorkloadEndpoint and a CNI Result, extracts IP address and mask and populates that information into the WorkloadEndpoint.
func ReleaseIPAllocation ¶
ReleaseIPAllocation is called to cleanup IPAM allocations if something goes wrong during CNI ADD execution. It forces the CNI_COMMAND to be DEL.
func ReplaceHostLocalIPAMPodCIDRs ¶
func ReplaceHostLocalIPAMPodCIDRs(logger *logrus.Entry, stdinData map[string]interface{}, getPodCIDR func() (string, error)) error
ReplaceHostLocalIPAMPodCIDRs extracts the host-local IPAM config section and replaces our special-case "usePodCidr" subnet value with pod CIDR retrieved by the passed-in getPodCIDR function. Typically, the passed-in function would access the datastore to retrieve the podCIDR. However, for tear-down we use a dummy value that returns 0.0.0.0/0.
To make sure that unknown fields are round-tripped, we manipulate the JSON as maps and slices rather than by unmarshaling it into a struct. The structure of the JSON is as follows; we support replacing usePodCidr in either the "ipam" dict or its nested ranges section:
{ "cniVersion": "%s", ... "ipam": { "type": "host-local", "subnet": "usePodCidr", "ranges": [ [ { "subnet": "usePodCidr" } ] ] } ... }
func ResolvePools ¶
func ResolvePools(ctx context.Context, c client.Interface, pools []string, isv4 bool) ([]cnet.IPNet, error)
ResolvePools takes an array of CIDRs or IP Pool names and resolves it to a slice of pool CIDRs.
func SanitizeMesosLabel ¶
SanitizeMesosLabel converts a string from a valid mesos label to a valid Calico label. Mesos labels have no restriction outside of being unicode.
func SetupRoutes ¶
SetupRoutes sets up the routes for the host side of the veth pair.
func ValidateNetworkName ¶
ValidateNetworkName checks that the network name meets felix's expectations
Types ¶
type WEPIdentifiers ¶
type WEPIdentifiers struct { Namespace string WEPName string names.WorkloadEndpointIdentifiers }
func GetIdentifiers ¶
func GetIdentifiers(args *skel.CmdArgs, nodename string) (*WEPIdentifiers, error)
GetIdentifiers takes CNI command arguments, and extracts identifiers i.e. pod name, pod namespace, container ID, endpoint(container interface name) and orchestratorID based on the orchestrator.