filter

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: Apache-2.0 Imports: 20 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"

	// 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",
	}
)

Functions

func CreateSerializer added in v1.2.0

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

func NewFilterReadCloser

func NewFilterReadCloser(
	req *http.Request,
	sm *serializer.SerializerManager,
	rc io.ReadCloser,
	handler ObjectHandler,
	ownerName string,
	stopCh <-chan struct{}) (int, io.ReadCloser, error)

NewFilterReadCloser create an filterReadCloser object

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 the filter name for the specified request.

func NewApprover

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

type Factory

type Factory func() (Runner, error)

type FilterInitializer

type FilterInitializer interface {
	Initialize(filter Runner) error
}

type FilterInitializers

type FilterInitializers []FilterInitializer

func (FilterInitializers) Initialize

func (fis FilterInitializers) Initialize(ins Runner) 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 FilterInitializer) ([]Runner, error)

func (*Filters) Register

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

type NodeGetter

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

type ObjectHandler added in v1.2.0

type ObjectHandler interface {
	RuntimeObjectFilter(obj runtime.Object) (runtime.Object, bool)
}

ObjectHandler is used for filtering runtime object. runtime object includes List object(like ServiceList) that has multiple items and Standalone object(like Service). the second return value(bool): is used to specify the returned object is nil or not.

type Runner added in v0.7.0

type Runner 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 to filter data returned from the cloud.
	Filter(req *http.Request, rc io.ReadCloser, stopCh <-chan struct{}) (int, io.ReadCloser, error)
}

Runner is the actor for response filter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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