k8s

package
v1.15.4 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package k8s abstracts all Kubernetes specific behaviour

Index

Constants

This section is empty.

Variables

View Source
var (
	// ResourcesCell provides a set of handles to Kubernetes resources used throughout the
	// agent. Each of the resources share a client-go informer and backing store so we only
	// have one watch API call for each resource kind and that we maintain only one copy of each object.
	//
	// See pkg/k8s/resource/resource.go for documentation on the Resource[T] type.
	ResourcesCell = cell.Module(
		"k8s-resources",
		"Agent Kubernetes resources",

		cell.Config(k8s.DefaultConfig),
		LocalNodeCell,
		cell.Provide(
			k8s.ServiceResource,
			k8s.EndpointsResource,
			k8s.NamespaceResource,
			k8s.NetworkPolicyResource,
			k8s.CiliumNetworkPolicyResource,
			k8s.CiliumClusterwideNetworkPolicyResource,
			k8s.CiliumCIDRGroupResource,
			k8s.CiliumNodeResource,
			k8s.CiliumSlimEndpointResource,
			k8s.CiliumEndpointSliceResource,
		),
	)

	LocalNodeCell = cell.Module(
		"k8s-local-node-resources",
		"Agent Kubernetes local node resources",

		cell.Provide(
			func(lc cell.Lifecycle, cs client.Clientset) (LocalNodeResource, error) {
				return k8s.NodeResource(
					lc, cs,
					func(opts *metav1.ListOptions) {
						opts.FieldSelector = fields.ParseSelectorOrDie("metadata.name=" + nodeTypes.GetName()).String()
					},
				)
			},
			func(lc cell.Lifecycle, cs client.Clientset) (LocalCiliumNodeResource, error) {
				return k8s.CiliumNodeResource(
					lc, cs,
					func(opts *metav1.ListOptions) {
						opts.FieldSelector = fields.ParseSelectorOrDie("metadata.name=" + nodeTypes.GetName()).String()
					},
				)
			},
			func(lc cell.Lifecycle, cs client.Clientset) (LocalPodResource, error) {
				return k8s.PodResource(
					lc, cs,
					func(opts *metav1.ListOptions) {
						opts.FieldSelector = fields.ParseSelectorOrDie("spec.nodeName=" + nodeTypes.GetName()).String()
					},
				)
			},
		),
	)
)

Functions

func WaitForNodeInformation added in v1.15.0

func WaitForNodeInformation(ctx context.Context, log logrus.FieldLogger, localNode LocalNodeResource, localCiliumNode LocalCiliumNodeResource) error

WaitForNodeInformation retrieves the node information via the CiliumNode or Kubernetes Node resource. This function will block until the information is received.

Types

type LocalCiliumNodeResource

type LocalCiliumNodeResource resource.Resource[*cilium_api_v2.CiliumNode]

LocalCiliumNodeResource is a resource.Resource[*cilium_api_v2.CiliumNode] but one which will only stream updates for the CiliumNode object associated with the node we are currently running on.

type LocalNodeResource

type LocalNodeResource resource.Resource[*slim_corev1.Node]

LocalNodeResource is a resource.Resource[*slim_corev1.Node] but one which will only stream updates for the node object associated with the node we are currently running on.

type LocalNodeResources added in v1.15.0

type LocalNodeResources struct {
	cell.In

	LocalNode       LocalNodeResource
	LocalCiliumNode LocalCiliumNodeResource
}

LocalNodeResources is a convenience struct to group CiliumNode and Node resources as cell constructor parameters.

type LocalPodResource

type LocalPodResource resource.Resource[*slim_corev1.Pod]

LocalPodResource is a resource.Resource[*slim_corev1.Pod] but one which will only stream updates for pod objects scheduled on the node we are currently running on.

type Resources

Resources is a convenience struct to group all the agent k8s resources as cell constructor parameters.

Jump to

Keyboard shortcuts

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