resources

package
v0.0.0-...-8f3027a Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0, Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BGPConfigResourceName = "BGPConfigurations"
	BGPConfigCRDName      = "bgpconfigurations.crd.projectcalico.org"
)
View Source
const (
	BGPFilterResourceName = "BGPFilters"
	BGPFilterCRDName      = "BGPFilters.crd.projectcalico.org"
)
View Source
const (
	BGPPeerResourceName = "BGPPeers"
	BGPPeerCRDName      = "bgppeers.crd.projectcalico.org"
)
View Source
const (
	CalicoNodeStatusResourceName = "CalicoNodeStatuses"
	CalicoNodeStatusCRDName      = "CalicoNodeStatuses.crd.projectcalico.org"
)
View Source
const (
	ClusterInfoResourceName = "ClusterInformations"
	ClusterInfoCRDName      = "clusterinformations.crd.projectcalico.org"
)
View Source
const (
	FelixConfigResourceName = "FelixConfigurations"
	FelixConfigCRDName      = "felixconfigurations.crd.projectcalico.org"
)
View Source
const (
	GlobalNetworkPolicyResourceName = "GlobalNetworkPolicies"
	GlobalNetworkPolicyCRDName      = "globalnetworkpolicies.crd.projectcalico.org"
)
View Source
const (
	GlobalNetworkSetResourceName = "GlobalNetworkSets"
	GlobalNetworkSetCRDName      = "globalnetworksets.crd.projectcalico.org"
)
View Source
const (
	HostEndpointResourceName = "HostEndpoints"
	HostEndpointCRDName      = "hostendpoints.crd.projectcalico.org"
)
View Source
const (
	BlockAffinityResourceName = "BlockAffinities"
	BlockAffinityCRDName      = "blockaffinities.crd.projectcalico.org"
)
View Source
const (
	IPAMBlockResourceName = "IPAMBlocks"
	IPAMBlockCRDName      = "ipamblocks.crd.projectcalico.org"
)
View Source
const (
	IPAMConfigResourceName = "IPAMConfigs"
	IPAMConfigCRDName      = "ipamconfigs.crd.projectcalico.org"
)
View Source
const (
	IPAMHandleResourceName = "IPAMHandles"
	IPAMHandleCRDName      = "ipamhandles.crd.projectcalico.org"
)
View Source
const (
	IPPoolResourceName = "IPPools"
	IPPoolCRDName      = "ippools.crd.projectcalico.org"
)
View Source
const (
	IPReservationResourceName = "IPReservations"
	IPReservationCRDName      = "ipreservations.crd.projectcalico.org"
)
View Source
const (
	KubeControllersConfigResourceName = "KubeControllersConfigurations"
	KubeControllersConfigCRDName      = "kubecontrollersconfigurations.crd.projectcalico.org"
)
View Source
const (
	NetworkPolicyResourceName = "NetworkPolicies"
	NetworkPolicyCRDName      = "networkpolicies.crd.projectcalico.org"
)
View Source
const (
	NetworkSetResourceName = "NetworkSets"
	NetworkSetCRDName      = "networksets.crd.projectcalico.org"
)
View Source
const (
	TierResourceName = "Tiers"
	TierCRDName      = "tiers.crd.projectcalico.org"
)

Variables

This section is empty.

Functions

func ContextWithPatchMode

func ContextWithPatchMode(ctx context.Context, mode PatchMode) context.Context

func ConvertK8sResourceToCalicoResource

func ConvertK8sResourceToCalicoResource(res Resource) error

Retrieve all of the Calico Metadata from the k8s resource annotations for CRD backed resources. This should remove the relevant Calico Metadata annotation when it has finished.

func IPAMBlockV1toV3

func IPAMBlockV1toV3(kvpv1 *model.KVPair) *model.KVPair

func IPAMBlockV3toV1

func IPAMBlockV3toV1(kvpv3 *model.KVPair) (*model.KVPair, error)

func IPPoolV3ToV1

func IPPoolV3ToV1(kvp *model.KVPair) (*model.KVPair, error)

func K8sErrorToCalico

func K8sErrorToCalico(ke error, id interface{}) error

K8sErrorToCalico returns the equivalent libcalico error for the given kubernetes error.

func K8sNodeToCalico

func K8sNodeToCalico(k8sNode *kapiv1.Node, usePodCIDR bool) (*model.KVPair, error)

K8sNodeToCalico converts a Kubernetes format node, with Calico annotations, to a Calico Node.

func SetCalicoMetadataFromK8sAnnotations

func SetCalicoMetadataFromK8sAnnotations(calicoRes Resource, k8sRes Resource)

Extract the Calico resource Metadata from the k8s resource annotations for non-CRD backed resources. This extracts the Annotations and Labels stored as a annotation, and fills in the CreationTimestamp and UID from the k8s resource.

func SetK8sAnnotationsFromCalicoMetadata

func SetK8sAnnotationsFromCalicoMetadata(k8sRes Resource, calicoRes Resource)

Store Calico Metadata in the k8s resource annotations for non-CRD backed resources. Currently this just stores Annotations and Labels and drops all other metadata attributes.

Types

type ConvertK8sResourceToKVPair

type ConvertK8sResourceToKVPair func(Resource) (*model.KVPair, error)

Function signature for conversion function to convert a K8s resource to a KVPair equivalent.

type ConvertK8sResourceToKVPairs

type ConvertK8sResourceToKVPairs func(Resource) ([]*model.KVPair, error)

Function signature for conversion function to convert a K8s resource to a KVPair equivalent.

func ConvertK8sResourceOneToOneAdapter

func ConvertK8sResourceOneToOneAdapter(oneToOne ConvertK8sResourceToKVPair) ConvertK8sResourceToKVPairs

ConvertK8sResourceOneToOneAdapter converts a ConvertK8sResourceToKVPair function to a ConvertK8sResourceToKVPairs function

type IPPoolv1v3Converter

type IPPoolv1v3Converter struct{}

IPPoolv1v3Converter implements VersionConverter interface.

func (IPPoolv1v3Converter) ConvertFromK8s

func (c IPPoolv1v3Converter) ConvertFromK8s(inRes Resource) (Resource, error)

ConvertFromK8s converts v1 IPPool Resource to v3 IPPool resource

type K8sNodeResourceClient

type K8sNodeResourceClient interface {
	K8sResourceClient
	ExtractResourcesFromNode(node *apiv1.Node) ([]*model.KVPair, error)
}

K8sNodeResourceClient extends the K8sResourceClient to add a helper method to extract resources from the supplied K8s Node. This convenience interface is expected to be removed in a future libcalico-go release.

type K8sResourceClient

type K8sResourceClient interface {
	// Create creates the object specified in the KVPair, which must not
	// already exist. On success, returns a KVPair for the object with
	// revision  information filled-in.
	Create(ctx context.Context, object *model.KVPair) (*model.KVPair, error)

	// Update modifies the existing object specified in the KVPair.
	// On success, returns a KVPair for the object with revision
	// information filled-in.  If the input KVPair has revision
	// information then the update only succeeds if the revision is still
	// current.
	Update(ctx context.Context, object *model.KVPair) (*model.KVPair, error)

	// Delete removes the object specified by the Key.  If the call
	// contains revision information, the delete only succeeds if the
	// revision is still current.
	Delete(ctx context.Context, key model.Key, revision string, uid *types.UID) (*model.KVPair, error)

	// DeleteKVP removes the object specified by the KVPair.  If the KVPair
	// contains revision information, the delete only succeeds if the
	// revision is still current.
	DeleteKVP(ctx context.Context, object *model.KVPair) (*model.KVPair, error)

	// Get returns the object identified by the given key as a KVPair with
	// revision information.
	Get(ctx context.Context, key model.Key, revision string) (*model.KVPair, error)

	// List returns a slice of KVPairs matching the input list options.
	// list should be passed one of the model.<Type>ListOptions structs.
	// Non-zero fields in the struct are used as filters.
	List(ctx context.Context, list model.ListInterface, revision string) (*model.KVPairList, error)

	// Watch returns a WatchInterface used for watching resources matching the
	// input list options.
	Watch(ctx context.Context, list model.ListInterface, revision string) (api.WatchInterface, error)

	// EnsureInitialized ensures that the backend is initialized
	// any ready to be used.
	EnsureInitialized() error
}

K8sResourceClient is the interface to the k8s datastore for CRUD operations on an individual resource (one for each of the *model* types supported by the K8s backend).

Defining a separate client interface from api.Client allows the k8s-specific client to diverge.

func NewCalicoNodeStatusClient

func NewCalicoNodeStatusClient(c *kubernetes.Clientset, r *rest.RESTClient) K8sResourceClient

func NewGlobalNetworkPolicyClient

func NewGlobalNetworkPolicyClient(c *kubernetes.Clientset, r *rest.RESTClient) K8sResourceClient

func NewGlobalNetworkSetClient

func NewGlobalNetworkSetClient(c *kubernetes.Clientset, r *rest.RESTClient) K8sResourceClient

func NewKubeControllersConfigClient

func NewKubeControllersConfigClient(c *kubernetes.Clientset, r *rest.RESTClient) K8sResourceClient

func NewKubernetesAdminNetworkPolicyClient

func NewKubernetesAdminNetworkPolicyClient(
	anpClient *adminpolicyclient.PolicyV1alpha1Client,
) K8sResourceClient

NewKubernetesAdminNetworkPolicyClient returns a new client for interacting with Kubernetes AdminNetworkPolicy objects. Note that this client is only intended for use by the felix syncer in KDD mode, and as such is largely unimplemented except for the functions required by the syncer.

func NewKubernetesEndpointSliceClient

func NewKubernetesEndpointSliceClient(c *kubernetes.Clientset) K8sResourceClient

NewKubernetesEndpointSliceClient returns a new client for interacting with Kubernetes EndpointSlice objects. Note that this client is only intended for use by the felix syncer in KDD mode, and as such is largely unimplemented except for the functions required by the syncer.

func NewKubernetesNetworkPolicyClient

func NewKubernetesNetworkPolicyClient(c *kubernetes.Clientset) K8sResourceClient

NewKubernetesNetworkPolicyClient returns a new client for interacting with Kubernetes NetworkPolicy objects. Note that this client is only intended for use by the felix syncer in KDD mode, and as such is largely unimplemented except for the functions required by the syncer.

func NewNodeClient

func NewNodeClient(c *kubernetes.Clientset, usePodCIDR bool) K8sResourceClient

func NewProfileClient

func NewProfileClient(c *kubernetes.Clientset) K8sResourceClient

func NewServiceClient

func NewServiceClient(c *kubernetes.Clientset) K8sResourceClient

func NewWorkloadEndpointClient

func NewWorkloadEndpointClient(c kubernetes.Interface) K8sResourceClient

type PatchMode

type PatchMode string
const (
	PatchModeCNI         PatchMode = "patchModeCNI"
	PatchModeUnspecified PatchMode = "patchModeUnspecified"
)

func PatchModeOf

func PatchModeOf(ctx context.Context) PatchMode

type Resource

type Resource interface {
	runtime.Object
	metav1.ObjectMetaAccessor
}

Interface that all Kubernetes and Calico resources implement.

func ConvertCalicoResourceToK8sResource

func ConvertCalicoResourceToK8sResource(resIn Resource) (Resource, error)

Store Calico Metadata in the k8s resource annotations for CRD backed resources. This should store all Metadata except for those stored in Annotations and Labels and store them in annotations.

type ResourceList

type ResourceList interface {
	runtime.Object
	metav1.ListMetaAccessor
}

Interface that all Kubernetes and Calico resource lists implement.

type Validator

type Validator interface {
	Validate(Resource) error
}

Validator validates a resource.

type VersionConverter

type VersionConverter interface {
	ConvertFromK8s(Resource) (Resource, error)
}

VersionConverter converts v1 or v3 k8s resources into v3 resources. For a v3 resource, the conversion should be a no-op.

type WorkloadEndpointClient

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

Implements the api.Client interface for WorkloadEndpoints.

func (*WorkloadEndpointClient) Create

func (*WorkloadEndpointClient) Delete

func (c *WorkloadEndpointClient) Delete(ctx context.Context, key model.Key, revision string, uid *types.UID) (*model.KVPair, error)

func (*WorkloadEndpointClient) DeleteKVP

func (c *WorkloadEndpointClient) DeleteKVP(ctx context.Context, kvp *model.KVPair) (*model.KVPair, error)

func (*WorkloadEndpointClient) EnsureInitialized

func (c *WorkloadEndpointClient) EnsureInitialized() error

func (*WorkloadEndpointClient) Get

func (c *WorkloadEndpointClient) Get(ctx context.Context, key model.Key, revision string) (*model.KVPair, error)

func (*WorkloadEndpointClient) List

func (*WorkloadEndpointClient) Update

func (*WorkloadEndpointClient) Watch

Jump to

Keyboard shortcuts

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