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

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package endpointcleanup
     5  
     6  import (
     7  	"github.com/cilium/hive/cell"
     8  	"github.com/spf13/pflag"
     9  
    10  	"github.com/cilium/cilium/pkg/endpointmanager"
    11  )
    12  
    13  var Cell = cell.Module(
    14  	"stale-endpoint-cleanup",
    15  	"Cleanup stale cilium endpoints from unmanaged pods at startup",
    16  
    17  	cell.Invoke(registerCleanup),
    18  	cell.ProvidePrivate(func(epMgr endpointmanager.EndpointManager) localEndpointCache {
    19  		return epMgr
    20  	}),
    21  	cell.Config(Config{}),
    22  )
    23  
    24  type Config struct {
    25  	// EnableStaleCiliumEndpointCleanup enables cleanup routine during Cilium init.
    26  	// This will attempt to remove local CiliumEndpoints that are not managed by Cilium
    27  	// following Endpoint restoration.
    28  	EnableStaleCiliumEndpointCleanup bool
    29  }
    30  
    31  func (def Config) Flags(flags *pflag.FlagSet) {
    32  	flags.Bool("enable-stale-cilium-endpoint-cleanup", true, "Enable running cleanup init procedure of local CiliumEndpoints which are not being managed.")
    33  	flags.MarkHidden("enable-stale-cilium-endpoint-cleanup")
    34  }