Documentation ¶
Index ¶
- Constants
- Variables
- func ClientComponentFrom(ctx context.Context) (string, bool)
- func CreateKubeConfigFile(kubeClientConfig *rest.Config, kubeconfigPath string) error
- func Err(err error, w http.ResponseWriter, req *http.Request)
- func FileExists(filename string) (bool, error)
- func IsKubeletLeaseReq(req *http.Request) bool
- func IsSupportedCertMode(certMode string) bool
- func IsSupportedLBMode(lbMode string) bool
- func IsSupportedWorkingMode(workingMode WorkingMode) bool
- func KeyFunc(comp, resource, ns, name string) (string, error)
- func ListSelectorFrom(ctx context.Context) (string, bool)
- func LoadKubeConfig(kubeconfig string) (*clientcmdapi.Config, error)
- func LoadKubeletRestClientConfig(healthyServer *url.URL, kubeletRootCAFilePath, kubeletPairFilePath string) (*rest.Config, error)
- func LoadRESTClientConfig(kubeconfig string) (*rest.Config, error)
- func NewDualReadCloser(req *http.Request, rc io.ReadCloser, isRespBody bool) (io.ReadCloser, io.ReadCloser)
- func ReqCanCacheFrom(ctx context.Context) (bool, bool)
- func ReqContentTypeFrom(ctx context.Context) (string, bool)
- func ReqInfoString(info *apirequest.RequestInfo) string
- func ReqString(req *http.Request) string
- func RespContentTypeFrom(ctx context.Context) (string, bool)
- func SplitKey(key string) (comp, resource, ns, name string)
- func WithClientComponent(parent context.Context, component string) context.Context
- func WithListSelector(parent context.Context, selector string) context.Context
- func WithReqCanCache(parent context.Context, canCache bool) context.Context
- func WithReqContentType(parent context.Context, contentType string) context.Context
- func WithRespContentType(parent context.Context, contentType string) context.Context
- func WithValue(parent context.Context, key interface{}, val interface{}) context.Context
- func WriteObject(statusCode int, obj runtime.Object, w http.ResponseWriter, req *http.Request) error
- type DialFunc
- type Dialer
- type ProxyKeyType
- type WorkingMode
Constants ¶
const ( // YurtHubCertificateManagerName represents the certificateManager name in yurthub mode YurtHubCertificateManagerName = "hubself" // DefaultKubeletPairFilePath represents the default kubelet pair file path DefaultKubeletPairFilePath = "/var/lib/kubelet/pki/kubelet-client-current.pem" // DefaultKubeletRootCAFilePath represents the default kubelet ca file path DefaultKubeletRootCAFilePath = "/etc/kubernetes/pki/ca.crt" // ProxyReqContentType represents request content type context key ProxyReqContentType ProxyKeyType = iota // ProxyRespContentType represents response content type context key ProxyRespContentType // ProxyClientComponent represents client component context key ProxyClientComponent // ProxyReqCanCache represents request can cache context key ProxyReqCanCache // ProxyListSelector represents label selector and filed selector string for list request ProxyListSelector YurtHubNamespace = "kube-system" CacheUserAgentsKey = "cache_agents" YurtHubProxyPort = "10261" YurtHubPort = "10267" YurtHubProxySecurePort = "10268" )
Variables ¶
var ( DefaultCacheAgents = []string{"kubelet", "kube-proxy", "flanneld", "coredns", projectinfo.GetAgentName(), projectinfo.GetHubName()} YurthubConfigMapName = fmt.Sprintf("%s-hub-cfg", strings.TrimRightFunc(projectinfo.GetProjectPrefix(), func(c rune) bool { return c == '-' })) )
Functions ¶
func ClientComponentFrom ¶
ClientComponentFrom returns the value of the client component key on the ctx
func CreateKubeConfigFile ¶
func Err ¶
func Err(err error, w http.ResponseWriter, req *http.Request)
Err write err to response writer
func FileExists ¶
FileExists checks if specified file exists.
func IsKubeletLeaseReq ¶
IsKubeletLeaseReq judge whether the request is a lease request from kubelet
func IsSupportedCertMode ¶
IsSupportedCertMode check cert mode is supported or not
func IsSupportedLBMode ¶
IsSupportedLBMode check lb mode is supported or not
func IsSupportedWorkingMode ¶ added in v0.5.0
func IsSupportedWorkingMode(workingMode WorkingMode) bool
IsSupportedWorkingMode check working mode is supported or not
func ListSelectorFrom ¶
ListSelectorFrom returns the value of the list request selector string on the ctx
func LoadKubeConfig ¶
func LoadKubeConfig(kubeconfig string) (*clientcmdapi.Config, error)
func LoadKubeletRestClientConfig ¶
func LoadKubeletRestClientConfig(healthyServer *url.URL, kubeletRootCAFilePath, kubeletPairFilePath string) (*rest.Config, error)
LoadKubeletRestClientConfig load *rest.Config for accessing healthyServer
func NewDualReadCloser ¶
func NewDualReadCloser(req *http.Request, rc io.ReadCloser, isRespBody bool) (io.ReadCloser, io.ReadCloser)
NewDualReadCloser create an dualReadCloser object
func ReqCanCacheFrom ¶
ReqCanCacheFrom returns the value of the request can cache key on the ctx
func ReqContentTypeFrom ¶
ReqContentTypeFrom returns the value of the request content type key on the ctx
func ReqInfoString ¶
func ReqInfoString(info *apirequest.RequestInfo) string
ReqInfoString formats a string for request info
func RespContentTypeFrom ¶
RespContentTypeFrom returns the value of the response content type key on the ctx
func WithClientComponent ¶
WithClientComponent returns a copy of parent in which the client component value is set
func WithListSelector ¶
WithListSelector returns a copy of parent in which the list request selector string is set
func WithReqCanCache ¶
WithReqCanCache returns a copy of parent in which the request can cache value is set
func WithReqContentType ¶
WithReqContentType returns a copy of parent in which the response content type value is set
func WithRespContentType ¶
WithRespContentType returns a copy of parent in which the request content type value is set
func WriteObject ¶
func WriteObject(statusCode int, obj runtime.Object, w http.ResponseWriter, req *http.Request) error
WriteObject write object to response writer
Types ¶
type Dialer ¶
type Dialer struct {
// contains filtered or unexported fields
}
Dialer opens connections through Dial and tracks them.
func NewDialer ¶
NewDialer creates a new Dialer instance.
If dial is not nil, it will be used to create new underlying connections. Otherwise net.DialContext is used.
func (*Dialer) Close ¶
Close forcibly closes all tracked connections that specified by address.
Note: new connections may get created before Close returns.
func (*Dialer) CloseAll ¶
func (d *Dialer) CloseAll()
CloseAll forcibly closes all tracked connections.
Note: new connections may get created before CloseAll returns.
func (*Dialer) DialContext ¶
DialContext creates a new tracked connection.
type WorkingMode ¶ added in v0.5.0
type WorkingMode string
WorkingMode represents the working mode of yurthub.
const ( // WorkingModeCloud represents yurthub is working in cloud mode, which means yurthub is deployed on the cloud side. WorkingModeCloud WorkingMode = "cloud" // WorkingModeEdge represents yurthub is working in edge mode, which means yurthub is deployed on the edge side. WorkingModeEdge WorkingMode = "edge" )