container

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AgentDNSEnvVar gates the in-container agent's resident resolver.
	AgentDNSEnvVar = "KNOT_AGENT_DNS"
	// AgentServerResolveEnv carries a curl "--resolve" value
	// ("<host>:<port>:<ip>") for the URL the entrypoint fetches the agent from.
	// The container's nameserver is 127.0.0.1 (not up until the agent starts),
	// so the fetch can't resolve KNOT_SERVER; curl --resolve connects straight
	// to the IP while keeping the hostname for SNI/Host.
	AgentServerResolveEnv = "KNOT_SERVER_RESOLVE"
	// AgentServerDNSEnv is the address ("<ip>:<port>") of the knot server's own
	// DNS server, which lives on the same host as the agent endpoint. The agent
	// forwards every query here; the server answers the wildcard zone from its
	// dns-records and forwards the rest upstream.
	AgentServerDNSEnv = "KNOT_SERVER_DNS"
	// AgentDNSListener is the address the agent resolver listens on; the
	// container's sole nameserver is pointed here.
	AgentDNSListener = "127.0.0.1"
)
View Source
const ManagedPathType = "path"

Variables

This section is empty.

Functions

func AgentRegistrationEnv added in v0.33.0

func AgentRegistrationEnv(cfg *config.ServerConfig, spaceId string) []string

AgentRegistrationEnv returns the environment entries provisioning an agent's registration credentials: the per-space registration key it must prove possession of, and the fingerprint (sha256 of the certificate public key) pinning the zone's agent TLS certificate. Every server in the zone derives both from the same encryption key, so the values hold for whichever server the agent connects to.

func BuildPortEnvVars added in v0.25.0

func BuildPortEnvVars(template *model.Template) []string

func CreateManagedPath added in v0.25.0

func CreateManagedPath(path string) (string, error)

func DeleteManagedPath added in v0.25.0

func DeleteManagedPath(path string) error

func FormatEnvStrings added in v0.32.0

func FormatEnvStrings(env []EnvVar) []string

FormatEnvStrings formats env vars back to "KEY=value" strings, preserving the order of the input slice.

func RemoveExistingPortEnvVars added in v0.25.0

func RemoveExistingPortEnvVars(env []string) []string

RemoveExistingPortEnvVars removes any existing KNOT_HTTP_PORT, KNOT_HTTPS_PORT, or KNOT_TCP_PORT entries from the given environment slice.

func ResolveManagedPath added in v0.25.0

func ResolveManagedPath(path string) (string, error)

func ResolveManagedPathBinds added in v0.25.0

func ResolveManagedPathBinds(binds []string, volumeData model.VolumeDataMap) []string

func ValidateManagedVolumeBinds added in v0.25.0

func ValidateManagedVolumeBinds(binds []string, volumeData model.VolumeDataMap) error

Types

type AgentDNSInjection added in v0.32.0

type AgentDNSInjection struct {
	Env []string
	DNS []string // 127.0.0.1 (the agent resolver) — single entry
}

AgentDNSInjection is the set of container-level additions applied to a space when the server's DNS server is enabled (the signal that knot manages DNS for the wildcard domain, both for external clients and inside spaces).

func BuildAgentDNSInjection added in v0.32.0

func BuildAgentDNSInjection() (AgentDNSInjection, error)

BuildAgentDNSInjection computes the injection for a space. It returns a zero value when the server's DNS server is disabled.

The container's only nameserver is 127.0.0.1 (the agent resolver), which forwards every query to the knot server's own DNS (KNOT_SERVER_DNS). That makes the server the single DNS point for the space: it serves the wildcard zone from its dns-records and forwards the rest upstream (using the server's configured nameservers, or the system default). The agent needs no upstream list of its own.

Two different server addresses are involved:

  • KNOT_SERVER_RESOLVE uses the URL host (the address the entrypoint fetches the agent from — typically the ingress).
  • KNOT_SERVER_DNS uses the agent-endpoint host (where the server process, and thus its DNS listener, actually runs) — often a different host.

If either host can't be resolved, an error is returned so the caller refuses to start the space.

type ContainerManager

type ContainerManager interface {
	// space management
	CreateSpaceJob(user *model.User, template *model.Template, space *model.Space, variables map[string]interface{}) error
	DeleteSpaceJob(space *model.Space, onStopped func()) error
	CreateSpaceVolumes(user *model.User, template *model.Template, space *model.Space, variables map[string]interface{}) error
	DeleteSpaceVolumes(space *model.Space) error
	CleanupSpaceArtifacts(space *model.Space) error
	StopSpaceRuntime(space *model.Space) error

	// volume management
	CreateVolume(vol *model.Volume, variables map[string]interface{}) error
	DeleteVolume(vol *model.Volume, variables map[string]interface{}) error
}

type EnvVar added in v0.32.0

type EnvVar struct {
	Key   string
	Value string
}

EnvVar is a single environment variable as an ordered key/value pair.

func ParseEnvStrings added in v0.32.0

func ParseEnvStrings(env []string) []EnvVar

ParseEnvStrings parses "KEY=value" entries into an ordered slice of EnvVar. Entries without "=" or with an empty key are skipped. Order is preserved so callers that care about insertion order (e.g. the spec wizard, which round-trips the user's ordering through HCL/YAML emission) don't lose it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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