Skip to content

Commit

Permalink
Add Ciliumendpoint and Service resource to k8s watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
anubhabMajumdar committed Oct 27, 2024
1 parent 59acc85 commit aa16509
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
25 changes: 18 additions & 7 deletions pkg/k8s/cell_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,9 @@ var Cell = cell.Module(
func() resource.Resource[*cilium_api_v2alpha1.CiliumEndpointSlice] {
return &fakeresource[*cilium_api_v2alpha1.CiliumEndpointSlice]{}
},
func() resource.Resource[*types.CiliumEndpoint] {
return &fakeresource[*types.CiliumEndpoint]{}
},
func() resource.Resource[*cilium_api_v2.CiliumNode] {
return &fakeresource[*cilium_api_v2.CiliumNode]{}
},
func() daemonk8s.ServiceNonHeadless {
return &fakeresource[*slim_corev1.Service]{}
},
func() daemonk8s.EndpointsNonHeadless {
return &fakeresource[*ciliumk8s.Endpoints]{}
},
Expand All @@ -74,6 +68,12 @@ var Cell = cell.Module(
},
),

// Provide the resources needed by the watchers.

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) {
//nolint:wrapcheck // a wrapped error here is of dubious value
return ciliumk8s.EndpointsResource(lc, ciliumk8s.Config{
Expand All @@ -88,7 +88,18 @@ var Cell = cell.Module(
lc,
ciliumk8s.Config{
EnableK8sEndpointSlice: false,
K8sServiceProxyName: "",
},
cs,
func(*metav1.ListOptions) {},
)
}),

cell.Provide(func(lc cell.Lifecycle, cs client.Clientset) (daemonk8s.ServiceNonHeadless, error) {
//nolint:wrapcheck // a wrapped error here is of dubious value
return ciliumk8s.ServiceResource(
lc,
ciliumk8s.Config{
EnableK8sEndpointSlice: false,
},
cs,
func(*metav1.ListOptions) {},
Expand Down
10 changes: 5 additions & 5 deletions pkg/k8s/watcher_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import (

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

var (
once sync.Once
w *watchers.K8sWatcher
logger = logging.DefaultLogger.WithField(logfields.LogSubsys, "k8s-watcher")
// k8sResources = []string{K8sAPIGroupCiliumEndpointV2, resources.K8sAPIGroupServiceV1Core}
k8sResources = []string{}
once sync.Once
w *watchers.K8sWatcher
logger = logging.DefaultLogger.WithField(logfields.LogSubsys, "k8s-watcher")
k8sResources = []string{K8sAPIGroupCiliumEndpointV2, K8sAPIGroupServiceV1Core}
)

type watcherParams struct {
Expand Down

0 comments on commit aa16509

Please sign in to comment.