2018-04-17 16:03:02 +00:00
|
|
|
|
// Copyright (c) 2017 Intel Corporation
|
|
|
|
|
//
|
|
|
|
|
// 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.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
package types
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"net"
|
|
|
|
|
|
|
|
|
|
"github.com/containernetworking/cni/pkg/types"
|
2018-06-13 20:14:02 +00:00
|
|
|
|
"github.com/containernetworking/cni/pkg/types/current"
|
2018-04-23 17:30:41 +00:00
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
2018-04-17 16:03:02 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// NetConf for cni config file written in json
|
|
|
|
|
type NetConf struct {
|
|
|
|
|
types.NetConf
|
2018-06-13 20:14:02 +00:00
|
|
|
|
|
|
|
|
|
// support chaining for master interface and IP decisions
|
|
|
|
|
// occurring prior to running ipvlan plugin
|
|
|
|
|
RawPrevResult *map[string]interface{} `json:"prevResult"`
|
|
|
|
|
PrevResult *current.Result `json:"-"`
|
|
|
|
|
|
2018-05-01 18:08:39 +00:00
|
|
|
|
ConfDir string `json:"confDir"`
|
|
|
|
|
CNIDir string `json:"cniDir"`
|
2018-07-26 23:04:52 +00:00
|
|
|
|
BinDir string `json:"binDir"`
|
2018-05-01 18:08:39 +00:00
|
|
|
|
// RawDelegates is private to the NetConf class; use Delegates instead
|
|
|
|
|
RawDelegates []map[string]interface{} `json:"delegates"`
|
|
|
|
|
Delegates []*DelegateNetConf `json:"-"`
|
2018-07-30 10:59:13 +00:00
|
|
|
|
NetStatus []*NetworkStatus `json:"-"`
|
2018-05-01 18:08:39 +00:00
|
|
|
|
Kubeconfig string `json:"kubeconfig"`
|
2018-07-12 03:15:53 +00:00
|
|
|
|
LogFile string `json:"logFile"`
|
|
|
|
|
LogLevel string `json:"logLevel"`
|
2018-05-01 18:08:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-30 10:59:13 +00:00
|
|
|
|
type NetworkStatus struct {
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Interface string `json:"interface,omitempty"`
|
|
|
|
|
IPs []string `json:"ips,omitempty"`
|
|
|
|
|
Mac string `json:"mac,omitempty"`
|
|
|
|
|
Default bool `json:"default,omitempty"`
|
|
|
|
|
DNS types.DNS `json:"dns,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 18:08:39 +00:00
|
|
|
|
type DelegateNetConf struct {
|
2018-07-26 23:04:52 +00:00
|
|
|
|
Conf types.NetConf
|
|
|
|
|
ConfList types.NetConfList
|
2018-05-01 18:08:39 +00:00
|
|
|
|
IfnameRequest string `json:"ifnameRequest,omitempty"`
|
|
|
|
|
// MasterPlugin is only used internal housekeeping
|
|
|
|
|
MasterPlugin bool `json:"-"`
|
2018-07-26 23:04:52 +00:00
|
|
|
|
// Conflist plugin is only used internal housekeeping
|
|
|
|
|
ConfListPlugin bool `json:"-"`
|
2018-05-01 18:08:39 +00:00
|
|
|
|
|
2018-06-20 02:27:42 +00:00
|
|
|
|
// Raw JSON
|
2018-05-01 18:08:39 +00:00
|
|
|
|
Bytes []byte
|
2018-04-17 16:03:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-12 13:42:56 +00:00
|
|
|
|
type NetworkAttachmentDefinition struct {
|
2018-04-23 17:30:41 +00:00
|
|
|
|
metav1.TypeMeta `json:",inline"`
|
|
|
|
|
// Note that ObjectMeta is mandatory, as an object
|
|
|
|
|
// name is required
|
|
|
|
|
Metadata metav1.ObjectMeta `json:"metadata,omitempty" description:"standard object metadata"`
|
|
|
|
|
|
|
|
|
|
// Specification describing how to invoke a CNI plugin to
|
|
|
|
|
// add or remove network attachments for a Pod.
|
|
|
|
|
// In the absence of valid keys in a Spec, the runtime (or
|
|
|
|
|
// meta-plugin) should load and execute a CNI .configlist
|
|
|
|
|
// or .config (in that order) file on-disk whose JSON
|
|
|
|
|
// “name” key matches this Network object’s name.
|
|
|
|
|
// +optional
|
2018-07-12 13:42:56 +00:00
|
|
|
|
Spec NetworkAttachmentDefinitionSpec `json:"spec"`
|
2018-04-23 17:30:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-12 13:42:56 +00:00
|
|
|
|
type NetworkAttachmentDefinitionSpec struct {
|
2018-04-23 17:30:41 +00:00
|
|
|
|
// Config contains a standard JSON-encoded CNI configuration
|
|
|
|
|
// or configuration list which defines the plugin chain to
|
|
|
|
|
// execute. If present, this key takes precedence over
|
|
|
|
|
// ‘Plugin’.
|
|
|
|
|
// +optional
|
|
|
|
|
Config string `json:"config"`
|
2018-04-17 16:03:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-20 02:27:42 +00:00
|
|
|
|
// NetworkSelectionElement represents one element of the JSON format
|
|
|
|
|
// Network Attachment Selection Annotation as described in section 4.1.2
|
|
|
|
|
// of the CRD specification.
|
|
|
|
|
type NetworkSelectionElement struct {
|
|
|
|
|
// Name contains the name of the Network object this element selects
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
// Namespace contains the optional namespace that the network referenced
|
|
|
|
|
// by Name exists in
|
|
|
|
|
Namespace string `json:"namespace,omitempty"`
|
|
|
|
|
// IPRequest contains an optional requested IP address for this network
|
|
|
|
|
// attachment
|
|
|
|
|
IPRequest string `json:"ipRequest,omitempty"`
|
|
|
|
|
// MacRequest contains an optional requested MAC address for this
|
|
|
|
|
// network attachment
|
|
|
|
|
MacRequest string `json:"macRequest,omitempty"`
|
|
|
|
|
// InterfaceRequest contains an optional requested name for the
|
|
|
|
|
// network interface this attachment will create in the container
|
|
|
|
|
InterfaceRequest string `json:"interfaceRequest,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-17 16:03:02 +00:00
|
|
|
|
// K8sArgs is the valid CNI_ARGS used for Kubernetes
|
|
|
|
|
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
|
|
|
|
|
}
|
2018-09-10 15:27:07 +00:00
|
|
|
|
|
|
|
|
|
// ResourceInfo is struct to hold Pod device allocation information
|
|
|
|
|
type ResourceInfo struct {
|
|
|
|
|
Index int
|
|
|
|
|
DeviceIDs []string
|
|
|
|
|
}
|