plugin

package
v1.2.1-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package plugin implements fsm cni plugin.

Package plugin implements ecnet cni plugin.

Index

Constants

This section is empty.

Variables

View Source
var (
	// KubeScheme returns a scheme will all known related types added
	KubeScheme = kubeScheme()
)

Functions

func BuildClientCmd

func BuildClientCmd(kubeconfig, context string, overrides ...func(*clientcmd.ConfigOverrides)) clientcmd.ClientConfig

BuildClientCmd builds a client cmd config from a kubeconfig filepath and context. It overrides the current context with the one provided (empty to use default).

This is a modified version of k8s.io/client-go/tools/clientcmd/BuildConfigFromFlags with the difference that it loads default configs if not running in-cluster.

func BuildClientConfig

func BuildClientConfig(kubeconfig, context string) (*rest.Config, error)

BuildClientConfig builds a client rest config from a kubeconfig filepath and context. It overrides the current context with the one provided (empty to use default).

This is a modified version of k8s.io/client-go/tools/clientcmd/BuildConfigFromFlags with the difference that it loads default configs if not running in-cluster.

func CmdAdd

func CmdAdd(args *skel.CmdArgs) error

CmdAdd is the implementation of the cmdAdd interface of CNI plugin

func CmdCheck

func CmdCheck(*skel.CmdArgs) (err error)

CmdCheck is the implementation of the cmdCheck interface of CNI plugin

func CmdDelete

func CmdDelete(args *skel.CmdArgs) error

CmdDelete is the implementation of the cmdDelete interface of CNI plugin

func DefaultRestConfig

func DefaultRestConfig(kubeconfig, configContext string, fns ...func(*rest.Config)) (*rest.Config, error)

DefaultRestConfig returns the rest.Config for the given kube config file and context.

func SetRestDefaults

func SetRestDefaults(config *rest.Config) *rest.Config

SetRestDefaults is a helper function that sets default values for the given rest.Config. This function is idempotent.

Types

type Config

type Config struct {
	types.NetConf // You may wish to not nest this type
	RuntimeConfig *struct {
	} `json:"runtimeConfig"`

	// This is the previous result, when called in the context of a chained
	// plugin. Because this plugin supports multiple versions, we'll have to
	// parse this in two passes. If your plugin is not chained, this can be
	// removed (though you may wish to error if a non-chainable plugin is
	// chained.
	// If you need to modify the result before returning it, you will need
	// to actually convert it to a concrete versioned struct.
	RawPrevResult *map[string]any `json:"prevResult"`
	PrevResult    *cniv1.Result   `json:"-"`

	// Add plugin-specific flags here
	LogLevel        string     `json:"log_level"`
	LogUDSAddress   string     `json:"log_uds_address"`
	Kubernetes      Kubernetes `json:"kubernetes"`
	HostNSEnterExec bool       `json:"hostNSEnterExec"`
}

Config is whatever you expect your configuration json to be. This is whatever is passed in on stdin. Your plugin may wish to expose its functionality via runtime args, see CONVENTIONS.md in the CNI spec.

type K8sArgs

type K8sArgs struct {
	types.CommonArgs
	IP                         net.IP
	K8S_POD_NAME               types.UnmarshallableString // nolint: revive, stylecheck
	K8S_POD_NAMESPACE          types.UnmarshallableString // nolint: revive, stylecheck
	K8S_POD_INFRA_CONTAINER_ID types.UnmarshallableString // nolint: revive, stylecheck
}

K8sArgs is the valid CNI_ARGS used for Kubernetes The field names need to match exact keys in kubelet args for unmarshalling

type Kubernetes

type Kubernetes struct {
	K8sAPIRoot           string   `json:"k8s_api_root"`
	Kubeconfig           string   `json:"kubeconfig"`
	InterceptRuleMgrType string   `json:"intercept_type"`
	NodeName             string   `json:"node_name"`
	ExcludeNamespaces    []string `json:"exclude_namespaces"`
	CNIBinDir            string   `json:"cni_bin_dir"`
}

Kubernetes a K8s specific struct to hold config

Jump to

Keyboard shortcuts

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