header

package
v0.0.0-...-a282917 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 2 Imported by: 21

Documentation

Index

Constants

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

	// HashValueOverride is the value that must appear in the HashHeaderKey
	// header in order for our network hash to be injected.
	HashValueOverride = "override"
)

HashKey & Values

View Source
const (
	// ProbeKey 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.
	ProbeKey = "K-Network-Probe"

	// ProbeValue is the value used in 'K-Network-Probe'
	ProbeValue = "probe"
)

ProbeKey & Values

View Source
const (
	// ProxyKey is the name of an internal header that activator
	// uses to mark requests going through it.
	ProxyKey = "K-Proxy-Request"

	// OriginalHostKey is used to avoid Istio host based routing rules
	// in Activator.
	// The header contains the original Host value that can be rewritten
	// at the Queue proxy level back to be a host header.
	OriginalHostKey = "K-Original-Host"

	// KubeletProbeKey is the name of the header supplied by kubelet probes.
	// Prior to this deprecation, Istio with mTLS rewrote probes and their probes passed a
	// different user-agent.  Therefore, this header was added to augment the probes.
	//
	// Deprecated: this custom request header is no longer necessary since Istio now propagates the
	// original request header `User-Agent` sent by the kubelet (e.g., User-Agent: kube-probe/1.29).
	// For updated usage, please utilize knative.dev/networking/pkg/http/header.UserAgentKey and
	// knative.dev/networking/pkg/http/header.KubeProbeUAPrefix
	KubeletProbeKey = "K-Kubelet-Probe"

	// RouteTagKey is the name of the header entry which has a tag name as value.
	// The tag name specifies which route was expected to be chosen by Ingress.
	RouteTagKey = "Knative-Serving-Tag"

	// DefaultRouteKey is the name of the header entry
	// identifying whether a request is routed via the default route or not.
	// It has one of the string value "true" or "false".
	DefaultRouteKey = "Knative-Serving-Default-Route"

	// PassthroughLoadbalancingKey is the name of the header that directs
	// load balancers to not load balance the respective request but to
	// send it to the request's target directly.
	PassthroughLoadbalancingKey = "K-Passthrough-Lb"
)
View Source
const (
	// UserAgentKey is the constant for header "User-Agent".
	UserAgentKey = "User-Agent"

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

	// ActivatorUserAgent is the user-agent header value set in probe requests sent
	// from activator.
	ActivatorUserAgent = "Knative-Activator-Probe"

	// QueueProxyUserAgent is the user-agent header value set in probe requests sent
	// from queue-proxy.
	QueueProxyUserAgent = "Knative-Queue-Proxy-Probe"

	// IngressReadinessUserAgent is the user-agent header value
	// set in probe requests for Ingress status.
	IngressReadinessUserAgent = "Knative-Ingress-Probe"

	// AutoscalingUserAgent is the user-agent header value set in probe
	// requests sent by autoscaling implementations.
	AutoscalingUserAgent = "Knative-Autoscaling-Probe"
)

User Agent Key & Values

View Source
const (
	// ProtobufMIMEType is a content type to be used when autoscaler scrapes metrics from the QP
	ProtobufMIMEType = "application/protobuf"
)

Accept Content Values

Variables

This section is empty.

Functions

func GetKnativeProbeValue

func GetKnativeProbeValue(r *http.Request) string

KnativeProbeHeader returns the value for key ProbeHeaderName in request headers.

func GetKnativeProxyValue

func GetKnativeProxyValue(r *http.Request) string

KnativeProxyHeader returns the value for key ProxyHeaderName in request headers.

func IsKubeletProbe

func IsKubeletProbe(r *http.Request) bool

IsKubeletProbe returns true if the request is a Kubernetes probe.

func IsProbe

func IsProbe(r *http.Request) bool

IsProbe returns true if the request is a Kubernetes probe or a Knative probe, i.e. non-empty ProbeHeaderName header.

func RewriteHostIn

func RewriteHostIn(r *http.Request)

RewriteHostIn removes the `Host` header from the inbound (server) request and replaces it with our custom header. This is done to avoid Istio Host based routing, see #3870. Queue-Proxy will execute the reverse process.

func RewriteHostOut

func RewriteHostOut(r *http.Request)

RewriteHostOut undoes the `RewriteHostIn` action. RewriteHostOut checks if network.OriginalHostHeader was set and if it was, then uses that as the r.Host (which takes priority over Request.Header["Host"]). If the request did not have the OriginalHostHeader header set, the request is untouched.

Types

This section is empty.

Jump to

Keyboard shortcuts

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