filter

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MasterServiceFilterName filter is used to mutate the ClusterIP and https port of default/kubernetes service
	// in order to pods on edge nodes can access kube-apiserver directly by inClusterConfig.
	MasterServiceFilterName = "masterservice"

	// ServiceTopologyFilterName filter is used to reassemble endpointslice in order to make the service traffic
	// under the topology that defined by service.Annotation["openyurt.io/topologyKeys"]
	ServiceTopologyFilterName = "servicetopology"

	// DiscardCloudServiceFilterName filter is used to discard cloud service(like loadBalancer service)
	// on kube-proxy list/watch service request from edge nodes.
	DiscardCloudServiceFilterName = "discardcloudservice"

	// InClusterConfigFilterName filter is used to comment kubeconfig in kube-system/kube-proxy configmap
	// in order to make kube-proxy to use InClusterConfig to access kube-apiserver.
	InClusterConfigFilterName = "inclusterconfig"

	// NodePortIsolationName filter is used to discard or keep NodePort service in specified NodePool
	// in order to make NodePort will not be listened by kube-proxy component in specified NodePool.
	NodePortIsolationName = "nodeportisolation"

	// SkipDiscardServiceAnnotation is annotation used by LB service.
	// If end users want to use specified LB service at the edge side,
	// End users should add annotation["openyurt.io/skip-discard"]="true" for LB service.
	SkipDiscardServiceAnnotation = "openyurt.io/skip-discard"
)

Variables

View Source
var (
	// DisabledInCloudMode contains the filters that should be disabled when yurthub is working in cloud mode.
	DisabledInCloudMode = []string{DiscardCloudServiceFilterName}

	// SupportedComponentsForFilter is used for specifying which components are supported by filters as default setting.
	SupportedComponentsForFilter = map[string]string{
		MasterServiceFilterName:       "kubelet",
		DiscardCloudServiceFilterName: "kube-proxy",
		ServiceTopologyFilterName:     "kube-proxy, coredns, nginx-ingress-controller",
		InClusterConfigFilterName:     "kubelet",
		NodePortIsolationName:         "kube-proxy",
	}
)

Functions

func CreateSerializer added in v1.2.0

func CreateSerializer(respContentType string, info *apirequest.RequestInfo, sm *serializer.SerializerManager) *serializer.Serializer

Types

type Approver

type Approver interface {
	Approve(req *http.Request) (bool, []string)
}

Approver check the response of specified request need to go through filter or not. and get all filters' names for the specified request.

func NewApprover

func NewApprover(sharedFactory informers.SharedInformerFactory, filterSupportedResAndVerbs map[string]map[string]sets.String) Approver

type Factory

type Factory func() (ObjectFilter, error)

type Filters

type Filters struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewFilters

func NewFilters(disabledFilters []string) *Filters

func (*Filters) Enabled

func (fs *Filters) Enabled(name string) bool

func (*Filters) NewFromFilters

func (fs *Filters) NewFromFilters(initializer Initializer) ([]ObjectFilter, error)

func (*Filters) Register

func (fs *Filters) Register(name string, fn Factory)

type Initializer added in v1.3.0

type Initializer interface {
	Initialize(filter ObjectFilter) error
}

type Initializers added in v1.3.0

type Initializers []Initializer

func (Initializers) Initialize added in v1.3.0

func (fis Initializers) Initialize(ins ObjectFilter) error

type NodeGetter

type NodeGetter func(name string) (*v1.Node, error)

type ObjectFilter added in v1.3.0

type ObjectFilter interface {
	Name() string
	// SupportedResourceAndVerbs is used to specify which resource and request verb is supported by the filter.
	// Because each filter can make sure what requests with resource and verb can be handled.
	SupportedResourceAndVerbs() map[string]sets.String
	// Filter is used for filtering runtime object
	// all filter logic should be located in it.
	Filter(obj runtime.Object, stopCh <-chan struct{}) runtime.Object
}

ObjectFilter is used for filtering runtime object. runtime object includes List object(like ServiceList) that has multiple items and Standalone object(like Service). Every Filter need to implement ObjectFilter interface.

func CreateFilterChain added in v1.3.0

func CreateFilterChain(objFilters []ObjectFilter) ObjectFilter

type ResponseFilter added in v1.3.0

type ResponseFilter interface {
	Name() string
	// Filter is used to filter data returned from the cloud.
	Filter(req *http.Request, rc io.ReadCloser, stopCh <-chan struct{}) (int, io.ReadCloser, error)
}

ResponseFilter is used for filtering response for get/list/watch requests. it only prepares the common framework for ObjectFilter and don't cover the filter logic.

func CreateResponseFilter added in v1.3.0

func CreateResponseFilter(objectFilter ObjectFilter, serializerManager *serializer.SerializerManager) ResponseFilter

Jump to

Keyboard shortcuts

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