github.com/cilium/cilium@v1.16.2/clustermesh-apiserver/clustermesh/k8s/resources.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package k8s
     5  
     6  import (
     7  	"github.com/cilium/hive/cell"
     8  
     9  	"github.com/cilium/cilium/pkg/k8s"
    10  	cilium_api_v2 "github.com/cilium/cilium/pkg/k8s/apis/cilium.io/v2"
    11  	"github.com/cilium/cilium/pkg/k8s/resource"
    12  	slim_corev1 "github.com/cilium/cilium/pkg/k8s/slim/k8s/api/core/v1"
    13  	"github.com/cilium/cilium/pkg/k8s/types"
    14  )
    15  
    16  var (
    17  	// ResourcesCell provides a set of handles to Kubernetes resources used throughout the
    18  	// clustermesh-apiserver. Each of the resources share a client-go informer and backing store so we only
    19  	// have one watch API call for each resource kind and that we maintain only one copy of each object.
    20  	//
    21  	// See pkg/k8s/resource/resource.go for documentation on the Resource[T] type.
    22  	ResourcesCell = cell.Module(
    23  		"k8s-resources",
    24  		"Clustermesh-apiserver Kubernetes resources",
    25  
    26  		cell.Config(k8s.DefaultConfig),
    27  		cell.Provide(
    28  			k8s.ServiceResource,
    29  			k8s.EndpointsResource,
    30  			CiliumNodeResource,
    31  			k8s.CiliumIdentityResource,
    32  			// The CiliumSlimEndpoint resource constructor in the agent depends on the
    33  			// LocalNodeStore to index its cache. In the clustermesh-apiserver, there is no
    34  			// cell providing LocalNodeStore, so we provide the resource with a separate
    35  			// constructor.
    36  			CiliumSlimEndpointResource,
    37  			k8s.CiliumExternalWorkloads,
    38  		),
    39  	)
    40  )
    41  
    42  // Resources is a convenience struct to group all the agent k8s resources as cell constructor parameters.
    43  type Resources struct {
    44  	cell.In
    45  
    46  	Services            resource.Resource[*slim_corev1.Service]
    47  	Endpoints           resource.Resource[*k8s.Endpoints]
    48  	CiliumNodes         resource.Resource[*cilium_api_v2.CiliumNode]
    49  	CiliumIdentities    resource.Resource[*cilium_api_v2.CiliumIdentity]
    50  	CiliumSlimEndpoints resource.Resource[*types.CiliumEndpoint]
    51  }