github.com/cilium/cilium@v1.16.2/pkg/clustermesh/operator/cell.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package operator
     5  
     6  import (
     7  	"github.com/cilium/hive/cell"
     8  	"github.com/sirupsen/logrus"
     9  	"github.com/spf13/pflag"
    10  
    11  	"github.com/cilium/cilium/pkg/clustermesh/common"
    12  	"github.com/cilium/cilium/pkg/clustermesh/types"
    13  	"github.com/cilium/cilium/pkg/clustermesh/wait"
    14  	"github.com/cilium/cilium/pkg/dial"
    15  	"github.com/cilium/cilium/pkg/kvstore/store"
    16  	"github.com/cilium/cilium/pkg/metrics"
    17  )
    18  
    19  const subsystem = "clustermesh"
    20  
    21  // Cell is the cell for the Operator ClusterMesh
    22  var Cell = cell.Module(
    23  	"clustermesh",
    24  	"Cell providing clustermesh capabilities in the operator",
    25  	cell.Config(ClusterMeshConfig{}),
    26  	cell.Provide(
    27  		newClusterMesh,
    28  		newAPIClustersHandler,
    29  	),
    30  
    31  	cell.Config(common.Config{}),
    32  	cell.Config(wait.TimeoutConfigDefault),
    33  
    34  	metrics.Metric(NewMetrics),
    35  	metrics.Metric(common.MetricsProvider(subsystem)),
    36  )
    37  
    38  type clusterMeshParams struct {
    39  	cell.In
    40  
    41  	common.Config
    42  	wait.TimeoutConfig
    43  	Cfg    ClusterMeshConfig
    44  	Logger logrus.FieldLogger
    45  
    46  	// ClusterInfo is the id/name of the local cluster. This is used for logging and metrics
    47  	ClusterInfo types.ClusterInfo
    48  
    49  	Metrics       Metrics
    50  	CommonMetrics common.Metrics
    51  	StoreFactory  store.Factory
    52  
    53  	// ServiceResolver, if not nil, is used to create a custom dialer for service resolution.
    54  	ServiceResolver *dial.ServiceResolver
    55  }
    56  
    57  // ClusterMeshConfig contains the configuration for ClusterMesh inside the operator.
    58  type ClusterMeshConfig struct {
    59  	// ClusterMeshEnableEndpointSync enables the EndpointSlice Cluster Mesh synchronization
    60  	ClusterMeshEnableEndpointSync bool `mapstructure:"clustermesh-enable-endpoint-sync"`
    61  }
    62  
    63  // Flags adds the flags used by ClientConfig.
    64  func (cfg ClusterMeshConfig) Flags(flags *pflag.FlagSet) {
    65  	flags.BoolVar(&cfg.ClusterMeshEnableEndpointSync,
    66  		"clustermesh-enable-endpoint-sync",
    67  		false,
    68  		"Whether or not the endpoint slice cluster mesh synchronization is enabled.",
    69  	)
    70  }