server

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 16 Imported by: 7

Documentation

Overview

Package server contains the implementation of a RuntimeSDK webhook server.

Index

Constants

This section is empty.

Variables

View Source
var DefaultPort = 9443

DefaultPort is the default port that the webhook server serves.

Functions

This section is empty.

Types

type ExtensionHandler

type ExtensionHandler struct {

	// Hook is the corresponding hook of the handler.
	Hook runtimecatalog.Hook

	// Name is the name of the extension handler.
	// An extension handler name must be valid in line RFC 1123 Label Names.
	Name string

	// HandlerFunc is the handler function.
	HandlerFunc runtimecatalog.Hook

	// TimeoutSeconds is the timeout of the extension handler.
	// If left undefined, this will be defaulted to 10s when processing the answer to the discovery
	// call for this server.
	TimeoutSeconds *int32

	// FailurePolicy is the failure policy of the extension handler.
	// If left undefined, this will be defaulted to FailurePolicyFail when processing the answer to the discovery
	// call for this server.
	FailurePolicy *runtimehooksv1.FailurePolicy
	// contains filtered or unexported fields
}

ExtensionHandler represents an extension handler.

type Options

type Options struct {
	// Catalog is the catalog used to handle requests.
	Catalog *runtimecatalog.Catalog

	// Host is the address that the server will listen on.
	// Defaults to "" - all addresses.
	// It is used to set webhook.Server.Host.
	Host string

	// Port is the port number that the server will serve.
	// It will be defaulted to 9443 if unspecified.
	// It is used to set webhook.Server.Port.
	Port int

	// CertDir is the directory that contains the server key and certificate.
	// If not set, webhook server would look up the server key and certificate in
	// {TempDir}/k8s-webhook-server/serving-certs. The server key and certificate
	// must be named tls.key and tls.crt, respectively.
	// It is used to set webhook.Server.CertDir.
	CertDir string

	// CertName is the server certificate name. Defaults to tls.crt.
	//
	// Note: This option is only used when TLSOpts does not set GetCertificate.
	CertName string

	// KeyName is the server key name. Defaults to tls.key.
	//
	// Note: This option is only used when TLSOpts does not set GetCertificate.
	KeyName string

	// TLSOpts is used to allow configuring the TLS config used for the server.
	// This also allows providing a certificate via GetCertificate.
	TLSOpts []func(*tls.Config)
}

Options are the options for the Server.

type Server

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

Server is a runtime webhook server.

func New added in v1.3.0

func New(options Options) (*Server, error)

New creates a new runtime webhook server based on the given Options.

func (*Server) AddExtensionHandler

func (s *Server) AddExtensionHandler(handler ExtensionHandler) error

AddExtensionHandler adds an extension handler to the server.

func (*Server) Start

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

Start starts the server.

Jump to

Keyboard shortcuts

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