k8s

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	K8sAPIGroupCiliumEndpointV2 = "cilium/v2::CiliumEndpoint"
	K8sAPIGroupServiceV1Core    = "core/v1::Service"
)

Variables

View Source
var Cell = cell.Module(
	"k8s-watcher",
	"Kubernetes watchers needed by the agent",

	cell.Provide(
		func(cell.Lifecycle, client.Clientset) (daemonk8s.LocalPodResource, error) {
			return &fakeresource[*slim_corev1.Pod]{}, nil
		},
		func() resource.Resource[*slim_corev1.Namespace] {
			return &fakeresource[*slim_corev1.Namespace]{}
		},
		func() daemonk8s.LocalNodeResource {
			return &fakeresource[*slim_corev1.Node]{}
		},
		func() daemonk8s.LocalCiliumNodeResource {
			return &fakeresource[*cilium_api_v2.CiliumNode]{}
		},
		func() resource.Resource[*slim_networkingv1.NetworkPolicy] {
			return &fakeresource[*slim_networkingv1.NetworkPolicy]{}
		},
		func() resource.Resource[*cilium_api_v2.CiliumNetworkPolicy] {
			return &fakeresource[*cilium_api_v2.CiliumNetworkPolicy]{}
		},
		func() resource.Resource[*cilium_api_v2.CiliumClusterwideNetworkPolicy] {
			return &fakeresource[*cilium_api_v2.CiliumClusterwideNetworkPolicy]{}
		},
		func() resource.Resource[*cilium_api_v2alpha1.CiliumCIDRGroup] {
			return &fakeresource[*cilium_api_v2alpha1.CiliumCIDRGroup]{}
		},
		func() resource.Resource[*cilium_api_v2alpha1.CiliumEndpointSlice] {
			return &fakeresource[*cilium_api_v2alpha1.CiliumEndpointSlice]{}
		},
		func() resource.Resource[*cilium_api_v2.CiliumNode] {
			return &fakeresource[*cilium_api_v2.CiliumNode]{}
		},
		func() daemonk8s.EndpointsNonHeadless {
			return &fakeresource[*ciliumk8s.Endpoints]{}
		},
		func() watchers.WatcherConfiguration {
			return &watcherconfig{}
		},
	),

	cell.Provide(func(lc cell.Lifecycle, cs client.Clientset) (resource.Resource[*types.CiliumEndpoint], error) {
		return ciliumk8s.CiliumSlimEndpointResource(lc, cs, nil)
	}),

	cell.Provide(func(lc cell.Lifecycle, cs client.Clientset) (resource.Resource[*ciliumk8s.Endpoints], error) {

		return ciliumk8s.EndpointsResource(lc, ciliumk8s.Config{
			EnableK8sEndpointSlice: true,
			K8sServiceProxyName:    "",
		}, cs)
	}),

	cell.Provide(func(lc cell.Lifecycle, cs client.Clientset) (resource.Resource[*slim_corev1.Service], error) {

		return ciliumk8s.ServiceResource(
			lc,
			ciliumk8s.Config{
				EnableK8sEndpointSlice: false,
			},
			cs,
			func(*metav1.ListOptions) {},
		)
	}),

	cell.Provide(func(lc cell.Lifecycle, cs client.Clientset) (daemonk8s.ServiceNonHeadless, error) {

		return ciliumk8s.ServiceResource(
			lc,
			ciliumk8s.Config{
				EnableK8sEndpointSlice: false,
			},
			cs,
			func(*metav1.ListOptions) {},
		)
	}),

	cell.Provide(func() *ipcache.IPCache {
		iao := &identityAllocatorOwner{}
		idAlloc := &cachingIdentityAllocator{
			cache.NewCachingIdentityAllocator(iao),
			nil,
		}
		return ipcache.NewIPCache(&ipcache.Configuration{
			Context:           context.Background(),
			IdentityAllocator: idAlloc,
			PolicyHandler:     &policyhandler{},
			DatapathHandler:   &datapathhandler{},
		})
	}),

	cell.Provide(func() *ciliumk8s.ServiceCache {
		option.Config.K8sServiceCacheSize = 1000
		return ciliumk8s.NewServiceCache(&nodeaddressing{})
	}),

	cell.Provide(func() node.LocalNodeSynchronizer {
		return &nodeSynchronizer{
			l: logrus.WithField("module", "node-synchronizer"),
		}
	}),
	node.LocalNodeStoreCell,

	synced.Cell,

	cell.Provide(NewWatcher),

	cell.Provide(newAPIServerEventHandler),
	cell.Invoke(func(a *APIServerEventHandler) {
		ps := pubsub.New()
		fn := pubsub.CallBackFunc(a.handleAPIServerEvent)
		uuid := ps.Subscribe(common.PubSubAPIServer, &fn)
		a.l.WithFields(logrus.Fields{
			"uuid": uuid,
		}).Info("Subscribed to PubSub APIServer")
	}),
)

Functions

func NewWatcher

func NewWatcher(params watcherParams) (*watchers.K8sWatcher, error)

func Start

func Start(ctx context.Context, k *watchers.K8sWatcher)

Types

type APIServerEventHandler

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

Jump to

Keyboard shortcuts

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