k8s

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package k8s resolves the k8s:// addresses of mediactl and the stunnerd tunnel from a Kubernetes cluster, through the kubeconfig of the caller:

k8s://<namespace>/<gateway>[/<listener>]  the public address of a listener of a STUNner
                                           Gateway, read from its served dataplane config
k8s://<namespace>/<service>:<port>        the first ready pod of a Service, at the target
                                           port of the Service port of that number or name

The argument an address is given for decides which form it takes. The listener may be left out when the Gateway has a single one, and an empty namespace (k8s:///...) is the namespace of the kubeconfig context. A TURN listener resolves to its TURN URI too, with the credentials of its auth policy.

Index

Constants

View Source
const Scheme = "k8s://"

Scheme is the prefix of the addresses this package resolves.

Variables

This section is empty.

Functions

func IsAddress

func IsAddress(addr string) bool

IsAddress tells whether an address is a k8s:// address.

Types

type Listener

type Listener struct {
	// Addr is the public host:port of the listener.
	Addr string
	// TURN is the TURN URI of a TURN listener, with credentials; nil for other listeners.
	TURN *stnrv2.URI
	// Config is the listener's config.
	Config stnrv2.ListenerConfig
}

Listener is a resolved Gateway listener.

type Resolver

type Resolver struct {
	K8s *cliopt.ConfigFlags
	CDS *discovery.CDSConfigFlags
	Log logging.LeveledLogger
}

Resolver resolves k8s:// addresses.

func (Resolver) Address

func (r Resolver) Address(ctx context.Context, addr string) (string, error)

Address resolves a k8s:// Gateway address to the listener's public host:port; any other address is returned as it is.

func (Resolver) Listener

func (r Resolver) Listener(ctx context.Context, addr string) (Listener, error)

Listener resolves k8s://<namespace>/<gateway>[/<listener>].

func (Resolver) Peer

func (r Resolver) Peer(ctx context.Context, addr string) (stnrv2.Protocol, string, error)

Peer resolves k8s://<namespace>/<service>:<port> to the protocol of the Service port of that number or name and the address of the first ready pod of the Service at the target port.

func (Resolver) TURNDialer

func (r Resolver) TURNDialer(ctx context.Context, addr string) (turn.Dialer, error)

TURNDialer resolves a k8s:// Gateway TURN listener to a dialer through it, with the listener's credentials.

Jump to

Keyboard shortcuts

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