Documentation
¶
Overview ¶
Package k8s abstracts all Kubernetes specific behaviour
Index ¶
- Constants
- Variables
- func NewPodTable(db *statedb.DB) (statedb.RWTable[LocalPod], error)
- func NewPodTableAndReflector(jg job.Group, db *statedb.DB, cs client.Clientset) (statedb.Table[LocalPod], error)
- func PodByName(namespace, name string) statedb.Query[LocalPod]
- func WaitForNodeInformation(ctx context.Context, log logrus.FieldLogger, localNode LocalNodeResource, ...) error
- type LocalCiliumNodeResource
- type LocalNodeResource
- type LocalNodeResources
- type LocalPod
- type Resources
Constants ¶
const (
PodTableName = "k8s-pods"
)
Variables ¶
var ( PodNameIndex = newNameIndex[LocalPod]() PodTableCell = cell.Provide(NewPodTableAndReflector) )
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, k8s.CiliumEnvoyConfigResource, k8s.CiliumClusterwideEnvoyConfigResource, ), ) 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(params k8s.CiliumResourceParams) (LocalCiliumNodeResource, error) { return k8s.CiliumNodeResource( params, func(opts *metav1.ListOptions) { opts.FieldSelector = fields.ParseSelectorOrDie("metadata.name=" + nodeTypes.GetName()).String() }, ) }, ), ) )
var TablesCell = cell.Module( "k8s-tables", "StateDB tables of Kubernetes objects", PodTableCell, )
TablesCell provides a set of StateDB tables for common Kubernetes objects. The tables are populated with the StateDB k8s reflector (pkg/k8s/statedb.go).
NOTE: When adding new k8s tables make sure to provide and register from a single provider to ensure reflector starts before anyone depending on the table. See NewPodTableAndReflector for example.
Functions ¶
func NewPodTableAndReflector ¶
func NewPodTableAndReflector(jg job.Group, db *statedb.DB, cs client.Clientset) (statedb.Table[LocalPod], error)
NewPodTableAndReflector returns the read-only Table[LocalPod] and registers the k8s reflector. These are combined to ensure any dependency on Table[LocalPod] will start after the reflector, ensuring that Start hooks can wait for the table to initialize.
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 LocalPod ¶
type LocalPod struct { *slim_corev1.Pod // UpdatedAt is the time when [LocalPod] was last updated, e.g. it // shows when the pod change was received from the api-server. UpdatedAt time.Time `json:"updatedAt" yaml:"updatedAt"` }
LocalPod is Cilium's internal model of the pods running on this node.
func (LocalPod) TableHeader ¶
type Resources ¶
type Resources struct { cell.In Services resource.Resource[*slim_corev1.Service] Endpoints resource.Resource[*k8s.Endpoints] LocalNode LocalNodeResource LocalCiliumNode LocalCiliumNodeResource Namespaces resource.Resource[*slim_corev1.Namespace] NetworkPolicies resource.Resource[*slim_networkingv1.NetworkPolicy] CiliumNetworkPolicies resource.Resource[*cilium_api_v2.CiliumNetworkPolicy] CiliumClusterwideNetworkPolicies resource.Resource[*cilium_api_v2.CiliumClusterwideNetworkPolicy] CiliumCIDRGroups resource.Resource[*cilium_api_v2alpha1.CiliumCIDRGroup] CiliumSlimEndpoint resource.Resource[*types.CiliumEndpoint] CiliumEndpointSlice resource.Resource[*cilium_api_v2alpha1.CiliumEndpointSlice] CiliumNode resource.Resource[*cilium_api_v2.CiliumNode] }
Resources is a convenience struct to group all the agent k8s resources as cell constructor parameters.