utils

package
v0.0.0-...-dcad6f6 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HEADERSERVICECA   = "Service-Root-Ca"
	HEADERSERVICECERT = "Service-Client-Cert"
	HEADERSERVICEKEY  = "Service-Client-Key"
)
View Source
const (
	ProxyTypeService = iota
	ProxyTypeKubeAPIServer
)

Variables

This section is empty.

Functions

func GetProxyType

func GetProxyType(reqURI string) int

GetProxyType determines whether a request meant to proxy to a regular service or the kube-apiserver of the managed cluster. An example of service: https://<route location cluster-proxy>/<managed_cluster_name>/api/v1/namespaces/<namespace_name>/services/<[https:]service_name[:port_name]>/proxy-service/<service_path> An example of kube-apiserver: https://<route location cluster-proxy>/<managed_cluster_name>/api/pods?timeout=32s

func GetServiceProxyURL

func GetServiceProxyURL(cluster, namespace, service string) string

func GetTargetServiceURLFromRequest

func GetTargetServiceURLFromRequest(req *http.Request) (*url.URL, error)

GetTargetServiceURLFromRequest is used on the agent side, the service-proxy agent recived a request from the proxy-agent, and need to know the target service URL to do further proxy.

func ServeHealthProbes

func ServeHealthProbes(healthProbeBindAddress string, customChecks ...healthz.Checker) error

ServeHealthProbes serves health probes and configchecker.

func UpdateRequest

func UpdateRequest(t TargetServiceConfig, req *http.Request) *http.Request

Types

type TargetServiceConfig

type TargetServiceConfig struct {
	Cluster   string
	Proto     string
	Service   string
	Namespace string
	Port      string
	Path      string
}

TargetServiceConfig is a collection of data extrict from the request URL description the target service we can to access on the managed cluster. There are 2 usages of it: 1. used in function `ServiceProxyURL` to construct the target service URL. 2. used in function `UpdateRequest` to update the request object.

func GetTargetServiceConfig

func GetTargetServiceConfig(requestURL string) (ts TargetServiceConfig, err error)

GetTargetServiceConfig extrict the target service config from requestURL input: https://<route location cluster-proxy>/cluster1/api/v1/namespaces/default/services/<https:helloworld:8080>/proxy-service/ping?time-out=32s output: TargetServiceConfig{Cluster: cluster1, Proto: https, Service: helloworld, Namespace: default, Port: 8080, Path: /ping}

func GetTargetServiceConfigForKubeAPIServer

func GetTargetServiceConfigForKubeAPIServer(requestURL string) (ts TargetServiceConfig, err error)

GetTargetServiceConfigForKubeAPIServer extrict the kube apiserver config from requestURL input: https://<route location cluster-proxy>/cluster1/api/pods?timeout=32s output: TargetServiceConfig{Cluster: cluster1, Proto: https, Service: kubernetes, Namespace: default, Port: 443, Path: api/pods}

Jump to

Keyboard shortcuts

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