endpoint

package
v0.0.0-...-686bfca Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Overview

* Copyright (c) 2023 Baidu, 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) 2023 Baidu, 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) 2023 Baidu, 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) 2023 Baidu, 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) 2023 Baidu, 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) 2023 Baidu, 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) 2023 Baidu, 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) 2023 Baidu, 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) 2023 Baidu, 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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendEndpointStatus

func AppendEndpointStatus(newStatus *ccev2.EndpointStatus, status models.EndpointState, code string) bool

AppendEndpointStatus appends node status to given pod endpoint status

func ConverteIPAllocation2EndpointAddress

func ConverteIPAllocation2EndpointAddress(result *ipam.AllocationResult, family ccev2.IPFamily) *ccev2.AddressPair

func DeleteEndpointAndWait

func DeleteEndpointAndWait(ctx context.Context, cceEndpointClient *watchers.CCEEndpointClient, oldEP *ccev2.CCEEndpoint) (err error)

DeleteEndpointAndWait delete endpoint and wait for it to be deleted

func GetEndpointCrossCache

func GetEndpointCrossCache(ctx context.Context, cceEndpointClient *watchers.CCEEndpointClient, namespace string, name string) (*ccev2.CCEEndpoint, error)

GetEndpointCrossCache try get endpoint from cache if endpoint is missing the try get from apiserver

func IsFixedIPEndpoint

func IsFixedIPEndpoint(resource *ccev2.CCEEndpoint) bool

func IsPSTSEndpoint

func IsPSTSEndpoint(resource *ccev2.CCEEndpoint) bool

func IsSameContainerID

func IsSameContainerID(ep *ccev2.CCEEndpoint, containerID string) bool

IsSameContainerID checks if two container ids are the same or not

func NewEndpointTemplate

func NewEndpointTemplate(containerID, netnsPath string, pod *corev1.Pod) *ccev2.CCEEndpoint

NewEndpointTemplate create a Elastic CCE Endpoint

func NewIPAM

func NewIPAM(nodeAddressing types.NodeAddressing, c ipam.Configuration, owner ipam.Owner, watcher *watchers.K8sWatcher, mtuConfig ipam.MtuConfiguration) ipam.CNIIPAMServer

Types

type CCEEndpointGetterUpdater

type CCEEndpointGetterUpdater interface {
	Create(node *ccev2.CCEEndpoint) (*ccev2.CCEEndpoint, error)
	Update(ewResource *ccev2.CCEEndpoint) (*ccev2.CCEEndpoint, error)
	UpdateStatus(newResource *ccev2.CCEEndpoint) (*ccev2.CCEEndpoint, error)
	Delete(namespace, name string) error
	Lister() ccelister.CCEEndpointLister
}

CCEEndpointGetterUpdater defines the interface used to interact with the k8s apiserver to retrieve and update the CCEEndpoint custom resource

type DirectAllocatorStarter

type DirectAllocatorStarter interface {
	StartEndpointManager(ctx context.Context, getterUpdater CCEEndpointGetterUpdater) (EndpointEventHandler, error)
}

DirectAllocatorStarter is the interface an IPAM implementation must provide in order

type DirectEndpointOperation

type DirectEndpointOperation interface {
	// FilterAvailableSubnet returns the best subnet for the endpoint
	FilterAvailableSubnet([]*ccev1.Subnet) []*ccev1.Subnet

	// AllocateIP allocates an IP for the endpoint
	// The meaning of reusing the IP address is to migrate the IP
	// address to be used by the pod from one node to another
	// if action.addressing is not nil, it means that the IP address is reused
	// if action.addressing is nil, it means that the IP address is newly allocated
	// Note: This method will be called repeatedly, and the implementer must support reentrant calls
	AllocateIP(ctx context.Context, action *DirectIPAction) error

	// DeleteIP When the fixed IP pod is recycled and the IP is no longer reused,
	// for example, the workload is permanently deleted. At this time, the fixed
	// the implement should only delete the IP address while its owner is euqal to action.owner
	// IP that should be retained should be recycled.
	DeleteIP(ctx context.Context, allocation *DirectIPAction) error
}

type DirectIPAction

type DirectIPAction struct {
	// NodeName is identifier describing the ip on which node
	NodeName string

	Owner string

	// IP4/6 addresses assigned to this Endpoint
	// this field used to dynamic allocate ip
	// +optional
	SubnetID string

	// IP4/6 addresses assigned to this Endpoint
	Addressing ccev2.AddressPairList

	// Interface is the identifier describing the ip on which interface
	// this field used as param to release ip
	// +optional
	Interface string

	// A list of node selector requirements by node's labels.
	// +optional
	NodeSelectorRequirement []corev1.NodeSelectorRequirement `json:"matchExpressions,omitempty" protobuf:"bytes,1,rep,name=matchExpressions"`
}

type DirectIPAllocator

type DirectIPAllocator interface {
	// ResyncPool is called to synchronize the latest list of interfaces and IPs
	ResyncPool(ctx context.Context, scopedLog *logrus.Entry) (map[string]ipamTypes.AllocationMap, error)

	// NodeEndpoint returns the NodeEndpointOperation
	NodeEndpoint(cep *ccev2.CCEEndpoint) (DirectEndpointOperation, error)
}

DirectIPAllocator is the interface an IPAM implementation must provide in order to provide IP allocation for a node. The structure implementing this API *must* be aware of the node connected to this implementation. This is achieved by considering the node context provided in AllocationImplementation.CreateNetResource() function and returning a NodeOperations implementation which performs operations in the context of that node.

type DirectIPAllocatorProvider

type DirectIPAllocatorProvider interface {
	Init(ctx context.Context) error
	StartEndpointManager(ctx context.Context, getterUpdater CCEEndpointGetterUpdater) (EndpointEventHandler, error)
}

DirectIPAllocatorProvider defines the functions of IPAM provider front-end these are implemented by e.g. pkg/ipam/allocator/{privatecloudbase}.

type EndpointAPIHandler

type EndpointAPIHandler struct {
	// contains filtered or unexported fields
}

EndpointAPIHandler is the handler for the endpoint API.

func NewEndpointAPIHandler

func NewEndpointAPIHandler(watcher *watchers.K8sWatcher) *EndpointAPIHandler

func (*EndpointAPIHandler) GetEndpointExtpluginStatus

func (handler *EndpointAPIHandler) GetEndpointExtpluginStatus(ctx context.Context, namespace, name, containerID string) (models.ExtFeatureData, error)

GetEndpointExtpluginStatus returns the status of the extplugin. this method will block until all external plugin status have been ready.

func (*EndpointAPIHandler) PutEndpointProbe

func (handler *EndpointAPIHandler) PutEndpointProbe(ctx context.Context, namespace, name, containerID, driver string) (*models.EndpointProbeResponse, error)

type EndpointAllocator

type EndpointAllocator struct {
	// contains filtered or unexported fields
}

EndpointAllocator It proxies the basic operation methods of ipam. Each time an IP application succeeds, a CCEEndpoint object will be created. During gc, the existing CCEEndpoint objects will be gc based on CCEEndpoint

func (*EndpointAllocator) ADD

func (e *EndpointAllocator) ADD(family, owner, containerID, netns string) (ipv4Result, ipv6Result *ipam.AllocationResult, err error)

ADD allocates an IP for the given owner and returns the allocated IP.

func (*EndpointAllocator) DEL

func (e *EndpointAllocator) DEL(owner, containerID string) (err error)

func (*EndpointAllocator) DebugStatus

func (e *EndpointAllocator) DebugStatus() string

func (*EndpointAllocator) Dump

func (e *EndpointAllocator) Dump() (allocv4 map[string]string, allocv6 map[string]string, status string)

func (*EndpointAllocator) Restore

func (e *EndpointAllocator) Restore()

Restore all the IP addresses applied for by the current machine to the node cache pool

func (*EndpointAllocator) RestoreFinished

func (e *EndpointAllocator) RestoreFinished()

type EndpointEventHandler

type EndpointEventHandler interface {
	Create(resource *ccev2.CCEEndpoint) error
	Update(resource *ccev2.CCEEndpoint) error
	Delete(namespace, endpointName string) error
	Resync(context.Context) error
}

EndpointEventHandler should implement the behavior to handle CCEEndpoint

type EndpointManager

type EndpointManager struct {
	// contains filtered or unexported fields
}

func NewEndpointManager

func NewEndpointManager(getterUpdater CCEEndpointGetterUpdater, reuseIPImplement DirectIPAllocator) *EndpointManager

func (*EndpointManager) Create

func (manager *EndpointManager) Create(resource *ccev2.CCEEndpoint) error

func (*EndpointManager) Delete

func (manager *EndpointManager) Delete(namespace, name string) error

Delete removes the endpoint from the endpointMap

func (*EndpointManager) Resync

func (manager *EndpointManager) Resync(ctx context.Context) error

func (*EndpointManager) Start

func (manager *EndpointManager) Start(ctx context.Context) error

Start kicks of the NodeManager by performing the initial state synchronization and starting the background sync go routine

func (*EndpointManager) Update

func (manager *EndpointManager) Update(resource *ccev2.CCEEndpoint) error

type EndpointMunalAllocatorProvider

type EndpointMunalAllocatorProvider interface {
	AllocateIP(ctx context.Context, log *logrus.Entry, resource *ccev2.CCEEndpoint) error
}

type K8sEventRegister

type K8sEventRegister interface {
	// K8sEventReceived is called to do metrics accounting for received
	// Kubernetes events, as well as calculating timeouts for k8s watcher
	// cache sync.
	K8sEventReceived(apiGroupResourceName string, scope string, action string, valid, equal bool)

	// K8sEventProcessed is called to do metrics accounting for each processed
	// Kubernetes event.
	K8sEventProcessed(scope string, action string, status bool)

	// RegisterNetResourceSetSubscriber allows registration of subscriber.NetResourceSet
	// implementations. Events for all NetResourceSet events (not just the local one)
	// will be sent to the subscriber.
	RegisterNetResourceSetSubscriber(s subscriber.NetResourceSet)
}

K8sEventRegister is used to register and handle events as they are processed by K8s controllers.

Directories

Path Synopsis
* Copyright (c) 2023 Baidu, Inc.
* Copyright (c) 2023 Baidu, Inc.

Jump to

Keyboard shortcuts

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