metadata

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package metadata contains the container metadata server.

Index

Constants

View Source
const SignerHeader = "cni"

SignerHeader is the header specifying which node signed the token.

Variables

View Source
var DefaultServerAddress = netip.MustParseAddrPort("169.254.169.254:80")

DefaultServerAddress is the default address for the metadata server.

View Source
var Now = time.Now

Now is a function that returns the current time. It is used to override the time used for token validation.

Functions

This section is empty.

Types

type Config added in v0.0.23

type Config struct {
	// Address is the address to bind the metadata server to.
	// Defaults to DefaultMetadataAddress.
	Address netip.AddrPort
	// Host is the host node to use for the metadata server.
	Host host.Node
	// Storage is the storage provider to use for the metadata server.
	Storage *provider.Provider
	// KeyResolver is the key resolver to use for the metadata server.
	KeyResolver NodeKeyResolver
	// EnableIDTokens is true if ID tokens should be enabled.
	EnableIDTokens bool
}

Config are the options for the container metadata server.

type IDClaims added in v0.0.23

type IDClaims struct {
	jwt.Claims `json:",inline"`
	Groups     []string `json:"groups"`
}

IDClaims are the claims for an ID token.

type IDTokenServer added in v0.0.23

type IDTokenServer struct{ *Server }

IDTokenServer is the server for ID tokens. It can create identification tokens for clients to use to access other services in the cluster.

func (*IDTokenServer) ServeHTTP added in v0.0.23

func (i *IDTokenServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler and will handle token issuance and validation.

type NodeKeyResolver

type NodeKeyResolver interface {
	LookupPrivateKey(nodeID types.NodeID) (crypto.PrivateKey, bool)
}

NodeKeyResolver is an interface that can retrieve the private key of a node hosted on this server.

type PeerRequestInfo added in v0.0.23

type PeerRequestInfo struct {
	// Peer is the peer that is requesting the metadata.
	Peer types.MeshNode
	// Local is true if the request is from the local host node.
	Local bool
}

PeerRequestInfo is the information about the peer that is requesting the metadata.

type Server

type Server struct {
	Config
	// contains filtered or unexported fields
}

Server is the container metadata server.

func NewServer

func NewServer(cfg Config) *Server

NewServer creates a new container metadata server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts the container metadata server. It blocks until the server is shutdown. If addr is empty, the default address of 169.254.169.254:80 is used.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface and serves the container metadata based on the source IP address.

func (*Server) Shutdown

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

Shutdown shuts down the container metadata server.

Jump to

Keyboard shortcuts

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