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 (c) 2018-2021 Tigera, Inc. All rights reserved.
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 (c) 2015-2020 Tigera, Inc. All rights reserved.
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) (*cniv1.Result, error)
- func AddIgnoreUnknownArgs() error
- func CheckForSpuriousDockerAdd(args *skel.CmdArgs, conf types.NetConf, epIDs WEPIdentifiers, ...) (*cniv1.Result, error)
- func ConfigureLogging(conf types.NetConf)
- 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) (*cniv1.Result, error)
- func DeleteIPAM(conf types.NetConf, args *skel.CmdArgs, logger *logrus.Entry) error
- func DetermineNodename(conf types.NetConf) (nodename string)
- func EnsureVXLANTunnelAddr(ctx context.Context, calicoClient calicoclient.Interface, nodeName string, ...) error
- func GetHandleID(netName, containerID, workload string) string
- func MTUFromFile(filename string) (int, error)
- func Min(a, b int) int
- func PopulateEndpointNets(wep *api.WorkloadEndpoint, result *cniv1.Result) error
- func RegisterDeletedWep(containerID string) 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 UpdateHostLocalIPAMDataForWindows(subnet string, ipamData map[string]interface{}) 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 ConfigureLogging ¶
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) (*cniv1.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 EnsureVXLANTunnelAddr ¶
func GetHandleID ¶
func MTUFromFile ¶
MTUFromFile reads the /var/lib/calico/mtu file if it exists and returns the MTU within.
func PopulateEndpointNets ¶
func PopulateEndpointNets(wep *api.WorkloadEndpoint, result *cniv1.Result) error
PopulateEndpointNets takes a WorkloadEndpoint and a CNI Result, extracts IP address and mask and populates that information into the WorkloadEndpoint.
func RegisterDeletedWep ¶
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{}, getPodCIDRs func() (string, 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 UpdateHostLocalIPAMDataForWindows ¶
This function will update host-local IPAM data based on input from cni.conf
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.