proxy

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: Apache-2.0 Imports: 85 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddKubernetesTypesToScheme

func AddKubernetesTypesToScheme(scheme *runtime.Scheme)

AddKubernetesTypesToScheme 添加 Kubernetes 资源到 scheme

func ConvertToTable

func ConvertToTable(
	ctx context.Context,
	tableConvertor registryrest.TableConvertor,
	obj runtime.Object,
) (*metav1.Table, error)

ConvertToTable 将 obj 转换为表格形式

func IndexFieldsForAppsV1ReplicaSet added in v0.1.1

func IndexFieldsForAppsV1ReplicaSet(ctx context.Context, c cache.Cache) error

IndexFieldsForAppsV1ReplicaSet 为 appsv1.ReplicaSet 设置字段索引

func IndexFieldsForCoreV1Event added in v0.1.1

func IndexFieldsForCoreV1Event(ctx context.Context, c cache.Cache) error

IndexFieldsForCoreV1Event 为 corev1.Event 设置字段索引

func IndexFieldsForCoreV1Pod

func IndexFieldsForCoreV1Pod(ctx context.Context, c cache.Cache) error

IndexFieldsForCoreV1Pod 为 corev1.Pod 设置字段索引

func IndexFieldsForObject added in v0.1.1

func IndexFieldsForObject(ctx context.Context, c cache.Cache, obj client.Object) error

IndexFieldsForObject 为对象设置字段索引

func IndexFieldsForObjectMeta added in v0.1.1

func IndexFieldsForObjectMeta(ctx context.Context, c cache.Cache, obj client.Object) error

IndexFieldsForObjectMeta 为任意资源添加 metadata 字段索引

func NewDefaultTableConvertor added in v0.1.2

func NewDefaultTableConvertor(config *rest.Config, scheme *runtime.Scheme) (registryrest.TableConvertor, error)

NewDefaultTableConvertor 创建一个默认的 TableConvertor

func NewProxyHandler

func NewProxyHandler(
	ctx context.Context,
	apiProxyPrefix string,
	filter *proxy.FilterServer,
	cfg *rest.Config,
	mapper meta.RESTMapper,
	keepalive time.Duration,
	appendLocationPath bool,
	notify func(*http.Request),
) (http.Handler, error)

NewProxyHandler 创建一个代理 HTTP 处理器

func ParseGetOptions

func ParseGetOptions(req *http.Request) (metav1.GetOptions, error)

ParseGetOptions 解析请求 Get 选项

func ParseListOptions

func ParseListOptions(req *http.Request) (metav1.ListOptions, error)

ParseListOptions 解析请求 List 选项

func ToPartial

func ToPartial(obj runtime.Object) (runtime.Object, bool)

ToPartial 从对象提取仅包含 metadata 的部分

func WriteResponse

func WriteResponse(w http.ResponseWriter, code int, obj interface{})

WriteResponse 写响应

Types

type APIProxyServerOptions

type APIProxyServerOptions struct {
	URIPrefix          string
	Filter             *proxy.FilterServer
	Keepalive          time.Duration
	AppendLocationPath bool
}

APIProxyServerOptions API 代理服务选项

type AggregateTableConvertor added in v0.1.2

type AggregateTableConvertor struct {
	TableConvertorGetter TableConvertorGetter
}

AggregateTableConvertor 聚合的 TableConvertor

func (AggregateTableConvertor) ConvertToTable added in v0.1.2

func (tc AggregateTableConvertor) ConvertToTable(
	ctx context.Context,
	obj runtime.Object,
	opts runtime.Object,
) (*metav1.Table, error)

ConvertToTable 转换为表格

type CacheProxyHandler

type CacheProxyHandler struct {
	// contains filtered or unexported fields
}

CacheProxyHandler 缓存代理 HTTP 处理器

func NewCacheProxyHandler

func NewCacheProxyHandler(
	ctx context.Context,
	config *rest.Config,
	mapper meta.RESTMapper,
	apiProxyPrefix string,
) (*CacheProxyHandler, error)

NewCacheProxyHandler 创建一个缓存代理 HTTP 处理器

func (*CacheProxyHandler) Handle

func (h *CacheProxyHandler) Handle(req *http.Request) (runtime.Object, error)

Handle 处理请求

func (*CacheProxyHandler) HandleGet

func (h *CacheProxyHandler) HandleGet(
	ctx context.Context,
	obj client.Object,
	namespace, name string,
	opts metav1.GetOptions,
) error

HandleGet 处理获取对象

func (*CacheProxyHandler) HandleList

func (h *CacheProxyHandler) HandleList(
	ctx context.Context,
	obj client.ObjectList,
	namespace string,
	opts metav1.ListOptions,
) error

HandleList 处理列出对象

func (*CacheProxyHandler) IsCached

func (h *CacheProxyHandler) IsCached(req *http.Request) bool

IsCached 判断该请求是否有缓存

func (*CacheProxyHandler) ServeHTTP

func (h *CacheProxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP 处理 HTTP 请求

type ListenFunc

type ListenFunc func() (net.Listener, error)

ListenFunc 开始监听方法

type ListenerOptions

type ListenerOptions struct {
	TCP        *TCPListenerOptions
	UNIXSocket *UNIXSocketListenerOptions
}

ListenerOptions 监听器选项

type MultiVersionTableConvertor added in v0.1.2

type MultiVersionTableConvertor struct {
	IntervalVersion registryrest.TableConvertor
	Scheme          *runtime.Scheme
}

MultiVersionTableConvertor 基于 __internal 版本资源的 TableConvertor 的可转换多版本资源的 TableConvertor

func (MultiVersionTableConvertor) ConvertToTable added in v0.1.2

func (tc MultiVersionTableConvertor) ConvertToTable(
	ctx context.Context,
	obj runtime.Object,
	opts runtime.Object,
) (*metav1.Table, error)

ConvertToTable 转换为表格

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server 代理服务

func NewServer

func NewServer(ctx context.Context, opts ServerOptions) (*Server, error)

NewServer 创建一个代理服务

func (*Server) Addr

func (s *Server) Addr() net.Addr

Addr 返回监听地址

func (*Server) Notify

func (s *Server) Notify(_ *http.Request)

Notify 通知收到了一个请求

func (*Server) Ready

func (s *Server) Ready() <-chan struct{}

Ready 返回一个通道,该通道在服务端就绪时会被关闭

func (*Server) Serve

func (s *Server) Serve(ctx context.Context) error

Serve 开始提供 HTTP 服务

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop 停止服务

type ServerOptions

type ServerOptions struct {
	// Kubernetes 客户端配置
	ClientConfig *rest.Config
	// Kubernetes API 映射器
	RESTMapper meta.RESTMapper

	// 监听选项
	Listener ListenerOptions

	// Kubernetes API 代理
	APIProxy APIProxyServerOptions
	// 静态文件服务
	Static StaticServerOptions

	// 最大空闲时间(超过后代理服务自行关闭)
	MaxIdleTime time.Duration
}

ServerOptions 代理服务选项

type StaticServerOptions

type StaticServerOptions struct {
	URIPrefix string
	FileBase  string
}

StaticServerOptions 静态服务选项

type TCPListenerOptions

type TCPListenerOptions struct {
	Address string
	Port    int
}

TCPListenerOptions 监听 TCP 选项

type TableConvertorGetter added in v0.1.2

type TableConvertorGetter interface {
	// TableConvertorForObject 获取指定对象的表格转换器
	TableConvertorForObject(obj runtime.Object) (registryrest.TableConvertor, error)
}

TableConvertorGetter TableConvertor 获取器

func BuiltinTableConvertorGetter added in v0.1.2

func BuiltinTableConvertorGetter(scheme *runtime.Scheme) TableConvertorGetter

BuiltinTableConvertorGetter 内置对象 TableConvertor 的 TableConvertorGetter

func NewCRDTableConvertorGetter added in v0.1.2

func NewCRDTableConvertorGetter(
	crdGetter listersapiextensionsv1.CustomResourceDefinitionLister,
) TableConvertorGetter

NewCRDTableConvertorGetter 创建一个 CRD TableConvertorGetter

func NewCRDTableConvertorGetterForConfig added in v0.1.2

func NewCRDTableConvertorGetterForConfig(config *rest.Config) (TableConvertorGetter, error)

NewCRDTableConvertorGetterForConfig 基于客户端配置创建一个 CRD TableConvertorGetter

func NewCachedTableConvertorGetter added in v0.1.2

func NewCachedTableConvertorGetter(getter TableConvertorGetter) TableConvertorGetter

NewCachedTableConvertorGetter 创建一个带缓存的 TableConvertorGetter

type TableConvertorGetterFunc added in v0.1.2

type TableConvertorGetterFunc func(obj runtime.Object) (registryrest.TableConvertor, error)

TableConvertorGetterFunc 获取指定对象的表格转换器方法

func (TableConvertorGetterFunc) TableConvertorForObject added in v0.1.2

func (getterFunc TableConvertorGetterFunc) TableConvertorForObject(
	obj runtime.Object,
) (registryrest.TableConvertor, error)

TableConvertorForObject 获取指定对象的表格转换器

type TableConvertorGetters added in v0.1.2

type TableConvertorGetters []TableConvertorGetter

TableConvertorGetters 是 TableConvertorGetter 的列表

func (TableConvertorGetters) TableConvertorForObject added in v0.1.2

func (getters TableConvertorGetters) TableConvertorForObject(
	obj runtime.Object,
) (registryrest.TableConvertor, error)

TableConvertorForObject 获取指定对象的表格转换器

type UNIXSocketListenerOptions

type UNIXSocketListenerOptions struct {
	Path string
}

UNIXSocketListenerOptions 监听 UNIX Socket 选项

Jump to

Keyboard shortcuts

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