network

package
v0.0.0-...-2cb4bbe Latest Latest
Warning

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

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

Documentation

Overview

Package network holds the typed objects that define the schemas for configuring the knative networking layer.

Index

Constants

View Source
const (
	// DefaultDrainTimeout is the time that Knative components on the data
	// path will wait before shutting down server, but after starting to fail
	// readiness probes to ensure network layer propagation and so that no requests
	// are routed to this pod.
	// Note that this was bumped from 30s due to intermittent issues where
	// the webhook would get a bad request from the API Server when running
	// under chaos.
	DefaultDrainTimeout = 45 * time.Second

	// UserAgentKey is the constant for header "User-Agent".
	UserAgentKey = "User-Agent"

	// ProbeHeaderName is the name of a header that can be added to
	// requests to probe the knative networking layer.  Requests
	// with this header will not be passed to the user container or
	// included in request metrics.
	ProbeHeaderName = "K-Network-Probe"

	// ProbeHeaderValue is the value of a header that can be added to
	// requests to probe the knative networking layer.  Requests
	// with `K-Network-Probe` this value will not be passed to the user
	// container or included in request metrics.
	ProbeHeaderValue = "probe"

	// HashHeaderName is the name of an internal header that Ingress controller
	// uses to find out which version of the networking config is deployed.
	HashHeaderName = "K-Network-Hash"

	// KubeProbeUAPrefix is the prefix for the User-Agent header.
	// Since K8s 1.8, prober requests have
	//   User-Agent = "kube-probe/{major-version}.{minor-version}".
	KubeProbeUAPrefix = "kube-probe/"

	// KubeletProbeHeaderName is the header name to augment the probes, because
	// Istio with mTLS rewrites probes, but their probes pass a different
	// user-agent.
	KubeletProbeHeaderName = "K-Kubelet-Probe"
)

Variables

View Source
var AutoTransport = NewAutoTransport(1000, 100)

AutoTransport uses h2c for HTTP2 requests and falls back to `http.DefaultTransport` for all others

View Source
var DialTLSWithBackOff = NewTLSBackoffDialer(backOffTemplate)

DialTLSWithBackOff is same with DialWithBackOff but takes tls config.

View Source
var DialWithBackOff = NewBackoffDialer(backOffTemplate)

DialWithBackOff executes `net.Dialer.DialContext()` with exponentially increasing dial timeouts. In addition it sleeps with random jitter between tries.

View Source
var ErrTimeoutDialing = errors.New("timed out dialing")

ErrTimeoutDialing when the timeout is reached after set amount of time.

Functions

func ErrorHandler deprecated

func ErrorHandler(logger *zap.SugaredLogger) func(http.ResponseWriter, *http.Request, error)

ErrorHandler sets up a handler suitable for use with the ErrorHandler field on httputil's reverse proxy.

Deprecated: Use handler.Error instead.

func GetClusterDomainName

func GetClusterDomainName() string

GetClusterDomainName returns cluster's domain name or an error Closes issue: https://github.com/knative/eventing/issues/714

func GetServiceHostname

func GetServiceHostname(name, namespace string) string

GetServiceHostname returns the fully qualified service hostname

func IsKubeletProbe

func IsKubeletProbe(r *http.Request) bool

IsKubeletProbe returns true if the request is a Kubernetes probe.

func NewAutoTransport

func NewAutoTransport(maxIdle, maxIdlePerHost int) http.RoundTripper

NewAutoTransport creates a RoundTripper that can use appropriate transport based on the request's HTTP version.

func NewBackoffDialer

func NewBackoffDialer(backoffConfig wait.Backoff) func(context.Context, string, string) (net.Conn, error)

NewBackoffDialer returns a dialer that executes `net.Dialer.DialContext()` with exponentially increasing dial timeouts. In addition it sleeps with random jitter between tries.

func NewH2CTransport

func NewH2CTransport() http.RoundTripper

NewH2CTransport constructs a new H2C transport. That transport will reroute all HTTPS traffic to HTTP. This is to explicitly allow h2c (http2 without TLS) transport. See https://github.com/golang/go/issues/14141 for more details.

func NewProberTransport

func NewProberTransport() http.RoundTripper

NewProberTransport creates a RoundTripper that is useful for probing, since it will not cache connections.

func NewProxyAutoTLSTransport

func NewProxyAutoTLSTransport(maxIdle, maxIdlePerHost int, tlsConf *tls.Config) http.RoundTripper

NewProxyAutoTLSTransport is same with NewProxyAutoTransport but it has tls.Config to create HTTPS request.

func NewProxyAutoTransport

func NewProxyAutoTransport(maxIdle, maxIdlePerHost int) http.RoundTripper

NewProxyAutoTransport creates a RoundTripper suitable for use by a reverse proxy. The returned transport uses HTTP or H2C based on the request's HTTP version. The transport has DisableCompression set to true.

func NewServer

func NewServer(addr string, h http.Handler) *http.Server

NewServer returns a new HTTP Server with HTTP2 handler.

func NewTLSBackoffDialer

func NewTLSBackoffDialer(backoffConfig wait.Backoff) func(context.Context, string, string, *tls.Config) (net.Conn, error)

NewTLSBackoffDialer is same with NewBackoffDialer but takes tls config.

Types

type RoundTripperFunc

type RoundTripperFunc func(*http.Request) (*http.Response, error)

RoundTripperFunc implementation roundtrips a request.

func (RoundTripperFunc) RoundTrip

func (rt RoundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper.

Directories

Path Synopsis
Package handlers holds useful HTTP handler implementations.
Package handlers holds useful HTTP handler implementations.

Jump to

Keyboard shortcuts

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