utils

package
v1.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2017 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Copyright 2015 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

Constants

This section is empty.

Variables

This section is empty.

Functions

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 CleanUpIPAM added in v1.7.0

func CleanUpIPAM(conf NetConf, args *skel.CmdArgs, logger *log.Entry) error

CleanUpIPAM calls IPAM plugin to release the IP address. It also contains IPAM plugin specific changes needed before calling the plugin.

func CleanUpNamespace added in v1.7.0

func CleanUpNamespace(args *skel.CmdArgs, logger *log.Entry) error

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 CreateClient

func CreateClient(conf NetConf) (*client.Client, error)

func CreateContextLogger

func CreateContextLogger(workload string) *log.Entry

Create a logger which always includes common fields

func CreateResultFromEndpoint

func CreateResultFromEndpoint(ep *api.WorkloadEndpoint) (*current.Result, error)

func DoNetworking

func DoNetworking(args *skel.CmdArgs, conf NetConf, result *current.Result, logger *log.Entry, desiredVethName string) (hostVethName, contVethMAC string, err error)

DoNetworking performs the networking for the given config and IPAM result

func GetIdentifiers

func GetIdentifiers(args *skel.CmdArgs) (workloadID string, orchestratorID string, err error)

func Min added in v1.8.0

func Min(a, b int) int

func ParsePools added in v1.6.0

func ParsePools(pools []string, isv4 bool) ([]cnet.IPNet, error)

Takes as array of IPv4 or IPv6 pools and parses them into an array of IPnet's

func PopulateEndpointNets

func PopulateEndpointNets(endpoint *api.WorkloadEndpoint, result *current.Result) error

func ReleaseIPAllocation

func ReleaseIPAllocation(logger *log.Entry, ipamType string, stdinData []byte)

ReleaseIPAllocation is called to cleanup IPAM allocations if something goes wrong during CNI ADD execution.

func SetupRoutes added in v1.11.1

func SetupRoutes(hostVeth netlink.Link, result *current.Result) error

SetupRoutes sets up the routes for the host side of the veth pair.

func ValidateNetworkName

func ValidateNetworkName(name string) error

ValidateNetworkName checks that the network name meets felix's expectations

Types

type Args

type Args struct {
	Mesos Mesos `json:"org.apache.mesos,omitempty"`
}

type K8sArgs

type K8sArgs struct {
	types.CommonArgs
	IP                         net.IP
	K8S_POD_NAME               types.UnmarshallableString
	K8S_POD_NAMESPACE          types.UnmarshallableString
	K8S_POD_INFRA_CONTAINER_ID types.UnmarshallableString
}

K8sArgs is the valid CNI_ARGS used for Kubernetes

type Kubernetes

type Kubernetes struct {
	K8sAPIRoot string `json:"k8s_api_root"`
	Kubeconfig string `json:"kubeconfig"`
	NodeName   string `json:"node_name"`
}

Kubernetes a K8s specific struct to hold config

type Mesos

type Mesos struct {
	NetworkInfo NetworkInfo `json:"network_info"`
}

type NetConf

type NetConf struct {
	CNIVersion string `json:"cniVersion,omitempty"`
	Name       string `json:"name"`
	Type       string `json:"type"`
	IPAM       struct {
		Name       string
		Type       string   `json:"type"`
		Subnet     string   `json:"subnet"`
		AssignIpv4 *string  `json:"assign_ipv4"`
		AssignIpv6 *string  `json:"assign_ipv6"`
		IPv4Pools  []string `json:"ipv4_pools,omitempty"`
		IPv6Pools  []string `json:"ipv6_pools,omitempty"`
	} `json:"ipam,omitempty"`
	MTU            int        `json:"mtu"`
	Hostname       string     `json:"hostname"`
	Nodename       string     `json:"nodename"`
	DatastoreType  string     `json:"datastore_type"`
	EtcdAuthority  string     `json:"etcd_authority"`
	EtcdEndpoints  string     `json:"etcd_endpoints"`
	LogLevel       string     `json:"log_level"`
	Policy         Policy     `json:"policy"`
	Kubernetes     Kubernetes `json:"kubernetes"`
	Args           Args       `json:"args"`
	EtcdScheme     string     `json:"etcd_scheme"`
	EtcdKeyFile    string     `json:"etcd_key_file"`
	EtcdCertFile   string     `json:"etcd_cert_file"`
	EtcdCaCertFile string     `json:"etcd_ca_cert_file"`
}

NetConf stores the common network config for Calico CNI plugin

type NetworkInfo

type NetworkInfo struct {
	Name   string `json:"name"`
	Labels struct {
		Labels []struct {
			Key   string `json:"key"`
			Value string `json:"value"`
		} `json:"labels,omitempty"`
	} `json:"labels,omitempty"`
}

type Policy

type Policy struct {
	PolicyType              string `json:"type"`
	K8sAPIRoot              string `json:"k8s_api_root"`
	K8sAuthToken            string `json:"k8s_auth_token"`
	K8sClientCertificate    string `json:"k8s_client_certificate"`
	K8sClientKey            string `json:"k8s_client_key"`
	K8sCertificateAuthority string `json:"k8s_certificate_authority"`
}

Policy is a struct to hold policy config (which currently happens to also contain some K8s config)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL