types

package
v0.0.0-...-c4e93b7 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NSPoolKey = "ipam.harmonycloud.cn/nspool/%s/%s" //ns poolname

	NSPoolKeyPrefix = "ipam.harmonycloud.cn/nspool"

	ServiccePoolKey = "ipam.harmonycloud.cn/svcpool/%s/%s" //ns poolname

	ServiccePoolKeyPrefix = "ipam.harmonycloud.cn/svcpool"

	PodKey = "ipam.harmonycloud.cn/pod/%s/%s" //ns podname

	PodKeyPrefix = "ipam.harmonycloud.cn/pod/"

	PodIPFixedAnno = "hcipm_ip_fixed"

	PodIPAnno = "hcipam_ip"

	PodIPPoolAnno = "hcipam_ns_ippool"

	ServiceIPPoolAnno = "hcipam_service_ippool"
)

etcd key templates or prefixes, pod annotation keys

Variables

This section is empty.

Functions

func InetAtoN

func InetAtoN(ip net.IP) int64

InetAtoN convert an IP address to int64

func LastIP

func LastIP(CIDR types.IPNet) net.IP

LastIP determine the last IP of a subnet, excluding the broadcast if IPv4

Types

type IPAMConfig

type IPAMConfig struct {
	Name           string
	Type           string `json:"type"`
	MTU            int    `json:"mtu"`
	DatastoreType  string `json:"datastore_type"`
	EtcdEndpoints  string `json:"etcd_endpoints"`
	LogPath        string `json:"log_path"`
	LogLevel       string `json:"log_level"`
	EtcdKeyFile    string `json:"etcd_key_file"`
	EtcdCertFile   string `json:"etcd_cert_file"`
	EtcdCaCertFile string `json:"etcd_ca_cert_file"`
	EtcdUsername   string `json:"etcd_username"`
	EtcdPassword   string `json:"etcd_password"`
	Cronjob        string `json:"cronjob"`
}

IPAMConfig represents the IP related network configuration. This nests NSIPPool because we initially only supported a single range directly, and wish to preserve backwards compatibility

func LoadIPAMConfig

func LoadIPAMConfig(bytes []byte, envArgs string) (string, *IPAMConfig, string, error)

LoadIPAMConfig loads a IPAMConfig from byte slice.

type NSIPPool

type NSIPPool struct {
	Name    string      `json:"name"`
	Start   net.IP      `json:"start"` // The first ip, inclusive
	End     net.IP      `json:"end"`   // The last ip, inclusive
	Subnet  types.IPNet `json:"subnet"`
	Gateway net.IP      `json:"gateway"`

	//Routes []*types.Route `json:"routes,omitempty"`
	Total int `json:"total"`
	Used  int `json:"used"`

	CIDR types.IPNet `json:"cidr,omitempty"`

	VlanID int `json:"vlanid,omitempty"`

	Namespace string `json:"namespace"`

	LastAssignedIP net.IP `json:"lastAssignedIP,omitempty"`

	PodMap map[string]PodNetwork `json:"podMap"`
}

NSIPPool is a IPPool in a certain namespace

func (*NSIPPool) Canonicalize

func (ippool *NSIPPool) Canonicalize() error

Canonicalize takes a given range and ensures that all information is consistent, filling out Start, End, and Gateway with sane values if missing

func (NSIPPool) ContainsInSubnet

func (ippool NSIPPool) ContainsInSubnet(addr net.IP) bool

ContainsInSubnet checks if a given ip is contained in the subnet of nsIPPool

func (NSIPPool) Overlaps

func (ippool NSIPPool) Overlaps(r1 NSIPPool) bool

Overlaps returns true if there is any overlap between ranges

func (NSIPPool) String

func (ippool NSIPPool) String() string

type Net

type Net struct {
	Name       string      `json:"name"`
	CNIVersion string      `json:"cniVersion"`
	Bridge     string      `json:"bridge"`
	IPAM       *IPAMConfig `json:"ipam"`
}

Net is the top-level network config - IPAM plugins are passed the full configuration of the calling plugin, not just the IPAM section.

type PodNetwork

type PodNetwork struct {
	PodIP         net.IP    `json:"podIP,omitempty"`
	PodName       string    `json:"podName,omitempty"`
	SvcName       string    `json:"svcName,omitempty"`
	SvcIPPoolName string    `json:"svcIPPoolName,omitempty"`
	Namespace     string    `json:"namespace,omitempty"`
	StsName       string    `json:"stsName,omitempty"`
	StsDeleted    bool      `json:"stsDeleted,omitempty"`
	FixedIP       bool      `json:"fixedIP,omitempty"`
	ModifyTime    time.Time `json:"modifyTime,omitempty"`
}

PodNetwork contains all info about an IP address

type ServiceIPPool

type ServiceIPPool struct {
	Name  string `json:"name"`  //namespace-service-ippoolcli-n
	Start net.IP `json:"start"` // The first ip, inclusive
	End   net.IP `json:"end"`   // The last ip, inclusive
	//Routes []*types.Route `json:"routes,omitempty"`
	Total          int    `json:"total"`
	Used           int    `json:"used"`
	ServiceName    string `json:"serviceName"`
	Namespace      string `json:"namespace"`
	NSIPPoolName   string `json:"nsIPPoolName"`
	Deleted        bool   `json:"deleted,omitempty"`
	LastAssignedIP net.IP `json:"lastAssignedIP,omitempty"`
}

ServiceIPPool is a IPPool for a certain service

Jump to

Keyboard shortcuts

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