config

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuntimeModeTakod = "takod"

	RuntimeProxyTako = "tako-proxy"

	ProxyVisibilityPublic   = "public"
	ProxyVisibilityInternal = "internal"
	ProxyCDNCloudflare      = "cloudflare"
	ProxyCDNGeneric         = "generic"

	ProxyTLSModeAuto            = "auto"
	ProxyTLSModeOff             = "off"
	ProxyTLSChallengeAuto       = "auto"
	ProxyTLSChallengeDNS        = "dns"
	ACMEDNSProviderCloudflare   = "cloudflare"
	ACMEDNSProviderHetzner      = "hetzner"
	ACMEDNSProviderDigitalOcean = "digitalocean"

	StateBackendReplicated = "replicated"

	StateDeployConsistencyLease = "lease"

	StateUnreachableBlock = "block"

	DeployStrategyRecreate  = "recreate"
	DeployStrategyRolling   = "rolling"
	DeployStrategyBlueGreen = "blue_green"

	DeployPromotionAutomatic = "automatic"
	DeployPromotionManual    = "manual"

	BuildStrategyRemote = "remote"
	BuildStrategyLocal  = "local"
	BuildStrategyAuto   = "auto"

	BackupStorageProviderS3           = "s3"
	BackupStorageProviderR2           = "r2"
	BackupStorageProviderS3Compatible = "s3-compatible"
)
View Source
const (
	ServiceKindService = "service"
	ServiceKindJob     = "job"
	ServiceKindRun     = "run"
)

Service kinds.

Variables

This section is empty.

Functions

func IsNFSVolume added in v0.1.2

func IsNFSVolume(volumeSpec string) bool

IsNFSVolume checks if a volume spec uses the removed nfs: prefix.

func LoadEnvFile

func LoadEnvFile(path string) (map[string]string, error)

LoadEnvFile reads a .env file and returns a map of environment variables Supports: - KEY=value format - Comments (lines starting with #) - Empty lines - Single and double quoted values - Variable expansion ${VAR} syntax

func MaterializePlatformInventory added in v0.10.0

func MaterializePlatformInventory(cfg *Config, inventory *nodeidentity.ClusterInventory, localNodeID string, localWorkerUID int, sshKey, password string) error

MaterializePlatformInventory replaces application-supplied infrastructure details with the controller-published node set. Applications retain only workload selection by immutable node name or node ID.

func MergeEnvVars

func MergeEnvVars(explicitEnv map[string]string, envFileVars map[string]string) map[string]string

MergeEnvVars merges environment variables from multiple sources Priority (highest to lowest): 1. Explicit env vars from config (service.Env) 2. Variables from envFile (service.EnvFile) 3. System environment variables (already expanded via ${VAR} syntax)

func NormalizeBuildStrategy added in v0.6.0

func NormalizeBuildStrategy(strategy string) (string, error)

NormalizeBuildStrategy validates and canonicalizes a build strategy value.

func NormalizeProxyDomain added in v0.3.0

func NormalizeProxyDomain(domain string) (string, error)

NormalizeProxyDomain trims and validates a domain before it is used in proxy routing configuration.

func ParseDynamicDomainAsk added in v0.5.0

func ParseDynamicDomainAsk(value string) (string, string, error)

ParseDynamicDomainAsk parses "<service>:<path>" ask endpoint references.

func ParseServiceFileOwner added in v0.9.0

func ParseServiceFileOwner(value string) (uid int, gid int, configured bool, err error)

ParseServiceFileOwner parses a numeric uid or uid:gid ownership value. Named users are intentionally unsupported because takod cannot resolve container image passwd databases on the host.

func ResolveEnvironmentProxyTargets added in v0.4.24

func ResolveEnvironmentProxyTargets(proxy *EnvironmentProxyConfig, servers map[string]ServerConfig, environmentServers []string, environment string) ([]string, error)

ResolveEnvironmentProxyTargets applies environment proxy placement to the selected environment node set.

func ResolvePlacementTargets added in v0.3.0

func ResolvePlacementTargets(placement *PlacementConfig, servers map[string]ServerConfig, environmentServers []string, environment string) ([]string, error)

ResolvePlacementTargets returns the ordered node set a service may use after applying placement strategy and supported node label constraints.

func ResolveSchedulableEnvironmentTargets added in v0.10.0

func ResolveSchedulableEnvironmentTargets(servers map[string]ServerConfig, environmentServers []string, environment string) ([]string, error)

ResolveSchedulableEnvironmentTargets returns the environment members that may receive application-owned mutations. The full environment membership is still retained separately for read-only status and lifecycle operations.

func ResolveSchedulableMutationTargets added in v0.10.0

func ResolveSchedulableMutationTargets(servers map[string]ServerConfig, targets []string, environment string, explicit bool) ([]string, error)

ResolveSchedulableMutationTargets filters application-owned mutation fanout. An explicit operator selection fails instead of silently dropping an unschedulable target.

func ResolveSchedulablePlacementTargets added in v0.10.0

func ResolveSchedulablePlacementTargets(placement *PlacementConfig, servers map[string]ServerConfig, environmentServers []string, environment string) ([]string, error)

ResolveSchedulablePlacementTargets applies the placement contract and then filters controller-owned lifecycle state for new assignments. Connectivity callers continue to use ResolvePlacementTargets so cordoned/draining nodes remain reachable for status, logs, cleanup, and recovery.

func SaveConfig added in v0.2.0

func SaveConfig(configPath string, cfg *Config) error

SaveConfig writes the configuration to a YAML or JSON file based on extension

func ValidateConfig

func ValidateConfig(cfg *Config) error

ValidateConfig validates the configuration

func ValidatePlacementConfig added in v0.3.0

func ValidatePlacementConfig(placement *PlacementConfig) error

Types

type AgentConfig added in v0.3.0

type AgentConfig struct {
	Enabled *bool  `yaml:"enabled,omitempty" json:"enabled,omitempty"`
	Socket  string `yaml:"socket,omitempty" json:"socket,omitempty"`
	DataDir string `yaml:"dataDir,omitempty" json:"dataDir,omitempty"`
}

AgentConfig describes the takod node-local reconciler.

type BackupConfig

type BackupConfig struct {
	Schedule string               `yaml:"schedule" json:"schedule"`                   // cron format (e.g., "0 2 * * *")
	Retain   int                  `yaml:"retain" json:"retain"`                       // days to retain backups
	Volumes  []string             `yaml:"volumes,omitempty" json:"volumes,omitempty"` // optional logical service volumes to back up
	Storage  *BackupStorageConfig `yaml:"storage,omitempty" json:"storage,omitempty"` // optional object storage target
}

BackupConfig defines per-service backup settings.

type BackupStorageConfig added in v0.5.4

type BackupStorageConfig struct {
	Provider        string `yaml:"provider,omitempty" json:"provider,omitempty"`               // s3, r2, s3-compatible
	Bucket          string `yaml:"bucket,omitempty" json:"bucket,omitempty"`                   // Object storage bucket
	Region          string `yaml:"region,omitempty" json:"region,omitempty"`                   // AWS region or "auto" for R2
	Endpoint        string `yaml:"endpoint,omitempty" json:"endpoint,omitempty"`               // Required for r2/s3-compatible
	Prefix          string `yaml:"prefix,omitempty" json:"prefix,omitempty"`                   // Optional object key prefix
	AccessKeyID     string `yaml:"accessKeyId,omitempty" json:"accessKeyId,omitempty"`         // Use ${ENV_VAR}
	SecretAccessKey string `yaml:"secretAccessKey,omitempty" json:"secretAccessKey,omitempty"` // Use ${ENV_VAR}
	SessionToken    string `yaml:"sessionToken,omitempty" json:"sessionToken,omitempty"`       // Optional temporary credential token
	ForcePathStyle  bool   `yaml:"forcePathStyle,omitempty" json:"forcePathStyle,omitempty"`   // Needed by some S3-compatible stores
}

BackupStorageConfig defines an S3-compatible object storage target for off-node backup copies. R2, MinIO, B2, and Spaces use the s3-compatible API.

type BuildConfig added in v0.6.0

type BuildConfig struct {
	Strategy string `yaml:"strategy,omitempty" json:"strategy,omitempty"` // remote, local, auto
}

BuildConfig selects where build-backed service images are produced.

type CacheConfig

type CacheConfig struct {
	Enabled   bool   `yaml:"enabled,omitempty" json:"enabled,omitempty"`     // Enable build caching (default: true)
	Type      string `yaml:"type,omitempty" json:"type,omitempty"`           // "local" (default), "registry"
	Retention string `yaml:"retention,omitempty" json:"retention,omitempty"` // Cache retention period (e.g., "7d")
}

CacheConfig defines build caching settings

type Config

type Config struct {
	Schema        string                       `yaml:"$schema,omitempty" json:"$schema,omitempty"` // JSON Schema reference
	Project       ProjectConfig                `yaml:"project" json:"project"`
	Runtime       *RuntimeConfig               `yaml:"runtime,omitempty" json:"runtime,omitempty"`
	Mesh          *MeshConfig                  `yaml:"mesh,omitempty" json:"mesh,omitempty"`
	State         *StateConfig                 `yaml:"state,omitempty" json:"state,omitempty"`
	Deployment    *DeploymentConfig            `yaml:"deployment,omitempty" json:"deployment,omitempty"`
	Notifications *NotificationsConfig         `yaml:"notifications,omitempty" json:"notifications,omitempty"`
	Volumes       map[string]VolumeConfig      `yaml:"volumes,omitempty" json:"volumes,omitempty"` // Top-level volume definitions
	Builds        map[string]SharedBuildConfig `yaml:"builds,omitempty" json:"builds,omitempty"`
	// Registries holds private image registry credentials keyed by host
	// (e.g. ghcr.io). Values must be ${ENV_VAR} references — literal
	// passwords in the config file are rejected at load time. Credentials
	// are request-scoped: they ride individual pull/build requests and are
	// never persisted on nodes.
	Registries map[string]RegistryConfig `yaml:"registries,omitempty" json:"registries,omitempty"`

	Servers      map[string]ServerConfig      `yaml:"servers" json:"servers"`
	Environments map[string]EnvironmentConfig `yaml:"environments" json:"environments"`
}

Config represents the main configuration structure

func LoadConfig

func LoadConfig(configPath string) (*Config, error)

LoadConfig loads the configuration from a YAML or JSON file

func (*Config) EnvironmentACME added in v0.9.3

func (c *Config) EnvironmentACME(envName string) *EnvironmentACMEConfig

EnvironmentACME returns the normalized ACME config for an environment.

func (*Config) GetAllDefinedVolumes added in v0.1.3

func (c *Config) GetAllDefinedVolumes() map[string]VolumeConfig

GetAllDefinedVolumes returns all top-level volume definitions

func (*Config) GetBuildStrategy added in v0.6.0

func (c *Config) GetBuildStrategy() string

GetBuildStrategy returns where build-backed service images should be built.

func (*Config) GetDefaultEnvironment

func (c *Config) GetDefaultEnvironment() string

GetDefaultEnvironment returns the default environment name Returns "production" if it exists, otherwise the first environment

func (*Config) GetDefaultServer added in v0.3.0

func (c *Config) GetDefaultServer(envName string) (string, error)

GetDefaultServer returns the deterministic default node for an environment.

func (*Config) GetDeployConsistency added in v0.3.0

func (c *Config) GetDeployConsistency() string

GetDeployConsistency returns the deployment consistency policy.

func (*Config) GetDeploymentStrategy

func (c *Config) GetDeploymentStrategy() string

GetDeploymentStrategy returns the deployment strategy (parallel or sequential)

func (*Config) GetEnvironment

func (c *Config) GetEnvironment(name string) (*EnvironmentConfig, error)

GetEnvironment retrieves a specific environment configuration If name is empty, returns the default environment

func (*Config) GetEnvironmentProxyServers added in v0.4.24

func (c *Config) GetEnvironmentProxyServers(envName string) ([]string, error)

GetEnvironmentProxyServers returns the nodes that should reconcile public proxy routes for an environment. Without an explicit environment proxy placement, every selected environment server remains a proxy node.

func (*Config) GetEnvironmentServers

func (c *Config) GetEnvironmentServers(envName string) ([]string, error)

GetEnvironmentServers returns the list of servers for an environment

func (*Config) GetFullImageName

func (c *Config) GetFullImageName(serviceName string, envName string) string

GetFullImageName returns the legacy config-version image name.

func (*Config) GetFullImageNameWithTag added in v0.4.45

func (c *Config) GetFullImageNameWithTag(serviceName string, tag string) string

GetFullImageNameWithTag returns the full image name for an explicit tag.

func (*Config) GetMaxConcurrentBuilds

func (c *Config) GetMaxConcurrentBuilds() int

GetMaxConcurrentBuilds returns the max concurrent builds configuration

func (*Config) GetMaxConcurrentDeploys

func (c *Config) GetMaxConcurrentDeploys() int

GetMaxConcurrentDeploys returns the max concurrent deploys configuration

func (*Config) GetOnUnreachableNode added in v0.3.0

func (c *Config) GetOnUnreachableNode() string

GetOnUnreachableNode returns the policy used when a node cannot be reached.

func (*Config) GetRegistryURL

func (c *Config) GetRegistryURL() string

GetRegistryURL returns the auto-configured local registry URL Returns empty string for single-server deployments (no registry needed)

func (*Config) GetRuntimeMode added in v0.3.0

func (c *Config) GetRuntimeMode() string

GetRuntimeMode returns the configured orchestration runtime.

func (*Config) GetRuntimeProxy added in v0.3.0

func (c *Config) GetRuntimeProxy() string

GetRuntimeProxy returns the internal ingress proxy implementation.

func (*Config) GetService

func (c *Config) GetService(envName string, serviceName string) (*ServiceConfig, error)

GetService returns a specific service from an environment

func (*Config) GetServices

func (c *Config) GetServices(envName string) (map[string]ServiceConfig, error)

GetServices returns services for a specific environment

func (*Config) GetStateBackend added in v0.3.0

func (c *Config) GetStateBackend() string

GetStateBackend returns the configured state backend.

func (*Config) GetVolume added in v0.1.3

func (c *Config) GetVolume(name string) (*VolumeConfig, bool)

GetVolume returns a volume configuration by name

func (*Config) GetVolumeName added in v0.1.3

func (c *Config) GetVolumeName(volumeKey, envName string) string

GetVolumeName returns the actual Docker volume name for a defined volume If the volume has a custom name, use it; otherwise, apply project/env prefix

func (*Config) IsCacheEnabled

func (c *Config) IsCacheEnabled() bool

IsCacheEnabled returns true if build caching is enabled

func (*Config) IsMeshEnabled added in v0.3.0

func (c *Config) IsMeshEnabled() bool

IsMeshEnabled returns true when the private node mesh is enabled.

func (*Config) IsMultiServer

func (c *Config) IsMultiServer() bool

IsMultiServer returns true if more than one server is configured

func (*Config) IsParallelDeployment

func (c *Config) IsParallelDeployment() bool

IsParallelDeployment returns true if parallel deployment is enabled

func (*Config) IsRemoteCacheEnabled added in v0.4.17

func (c *Config) IsRemoteCacheEnabled() bool

IsRemoteCacheEnabled returns whether deployment history is replicated to takod.

func (*Config) IsTakodRuntime added in v0.3.0

func (c *Config) IsTakodRuntime() bool

IsTakodRuntime returns true when the current runtime is the takod mesh runtime.

func (*Config) IsVolumeExternal added in v0.1.3

func (c *Config) IsVolumeExternal(name string) bool

IsVolumeExternal checks if a volume is marked as external

func (*Config) SetBuildStrategy added in v0.6.0

func (c *Config) SetBuildStrategy(strategy string) error

SetBuildStrategy overrides the configured image build strategy.

type DeployConfig

type DeployConfig struct {
	Strategy          string                `yaml:"strategy,omitempty" json:"strategy,omitempty"` // recreate, rolling, blue_green
	MaxUnavailable    int                   `yaml:"maxUnavailable,omitempty" json:"maxUnavailable,omitempty"`
	MaxSurge          int                   `yaml:"maxSurge,omitempty" json:"maxSurge,omitempty"`
	RollbackOnFailure bool                  `yaml:"rollbackOnFailure,omitempty" json:"rollbackOnFailure,omitempty"`
	Readiness         DeployReadinessConfig `yaml:"readiness,omitempty" json:"readiness,omitempty"`
	SmokeTest         DeploySmokeTestConfig `yaml:"smokeTest,omitempty" json:"smokeTest,omitempty"`
	Promotion         string                `yaml:"promotion,omitempty" json:"promotion,omitempty"` // automatic, manual
	GracePeriod       string                `yaml:"gracePeriod,omitempty" json:"gracePeriod,omitempty"`
	Release           *ReleaseConfig        `yaml:"release,omitempty" json:"release,omitempty"`
}

DeployConfig defines deployment strategy

type DeployReadinessConfig added in v0.5.4

type DeployReadinessConfig struct {
	Path     string `yaml:"path,omitempty" json:"path,omitempty"`
	TCPPort  int    `yaml:"tcpPort,omitempty" json:"tcpPort,omitempty"`
	Timeout  string `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	Interval string `yaml:"interval,omitempty" json:"interval,omitempty"`
	Retries  int    `yaml:"retries,omitempty" json:"retries,omitempty"`
}

DeployReadinessConfig defines service readiness checks for rollout strategies.

type DeploySmokeTestConfig added in v0.5.4

type DeploySmokeTestConfig struct {
	Path           string `yaml:"path,omitempty" json:"path,omitempty"`
	ExpectedStatus int    `yaml:"expectedStatus,omitempty" json:"expectedStatus,omitempty"`
}

DeploySmokeTestConfig defines post-readiness checks for blue-green promotion.

type DeploymentConfig

type DeploymentConfig struct {
	Strategy string          `yaml:"strategy,omitempty" json:"strategy,omitempty"` // "parallel" or "sequential" (default: sequential)
	Parallel *ParallelConfig `yaml:"parallel,omitempty" json:"parallel,omitempty"`
	Cache    *CacheConfig    `yaml:"cache,omitempty" json:"cache,omitempty"`
	Build    *BuildConfig    `yaml:"build,omitempty" json:"build,omitempty"`
}

DeploymentConfig defines deployment optimization settings

type DynamicDomainsConfig added in v0.5.0

type DynamicDomainsConfig struct {
	Enabled *bool  `yaml:"enabled,omitempty" json:"enabled,omitempty"`
	Ask     string `yaml:"ask,omitempty" json:"ask,omitempty"` // "<service>:<path>"
}

DynamicDomainsConfig describes Caddy on-demand TLS for customer domains.

func (*DynamicDomainsConfig) IsEnabled added in v0.5.0

func (d *DynamicDomainsConfig) IsEnabled() bool

IsEnabled returns true when dynamic domain handling is active.

type EnvironmentACMEConfig added in v0.9.3

type EnvironmentACMEConfig struct {
	DNSProvider string            `yaml:"dnsProvider" json:"dnsProvider"`
	Credentials map[string]string `yaml:"credentials" json:"credentials"`
}

EnvironmentACMEConfig configures takod-managed DNS-01 issuance.

type EnvironmentConfig

type EnvironmentConfig struct {
	Servers        []string                 `yaml:"servers" json:"servers"`                                   // List of server names to use
	ServerSelector *ServerSelector          `yaml:"serverSelector,omitempty" json:"serverSelector,omitempty"` // Label-based server selection
	Proxy          *EnvironmentProxyConfig  `yaml:"proxy,omitempty" json:"proxy,omitempty"`                   // Environment-level proxy placement
	Labels         map[string]string        `yaml:"labels,omitempty" json:"labels,omitempty"`                 // Environment labels for nodes
	Services       map[string]ServiceConfig `yaml:"services" json:"services"`                                 // Services to deploy in this environment
}

EnvironmentConfig defines an environment (production, staging, etc.)

type EnvironmentProxyConfig added in v0.4.24

type EnvironmentProxyConfig struct {
	Placement *PlacementConfig `yaml:"placement,omitempty" json:"placement,omitempty"`
	// ACME is the environment-scoped DNS-01 provider used by routes that
	// explicitly opt in. Raw credential values must be whole ${ENV_VAR}
	// references and never enter route manifests or replicated state.
	ACME *EnvironmentACMEConfig `yaml:"acme,omitempty" json:"acme,omitempty"`
}

EnvironmentProxyConfig controls where environment-level proxy routes are reconciled. Services still use their own placement for containers.

type HealthCheckConfig

type HealthCheckConfig struct {
	Command     string `yaml:"command,omitempty" json:"command,omitempty"`
	Path        string `yaml:"path" json:"path"`
	TCPPort     int    `yaml:"tcpPort,omitempty" json:"tcpPort,omitempty"`
	Interval    string `yaml:"interval" json:"interval"`
	Timeout     string `yaml:"timeout" json:"timeout"`
	Retries     int    `yaml:"retries" json:"retries"`
	StartPeriod string `yaml:"startPeriod,omitempty" json:"startPeriod,omitempty"` // Grace period before starting checks
}

HealthCheckConfig defines health check settings

type LoadBalancerConfig

type LoadBalancerConfig struct {
	Strategy    string                  `yaml:"strategy" json:"strategy"` // round_robin, sticky
	HealthCheck LoadBalancerHealthCheck `yaml:"healthCheck,omitempty" json:"healthCheck,omitempty"`
}

LoadBalancerConfig defines load balancing settings

type LoadBalancerHealthCheck

type LoadBalancerHealthCheck struct {
	Enabled  bool   `yaml:"enabled" json:"enabled"`
	Path     string `yaml:"path" json:"path"`
	Interval string `yaml:"interval" json:"interval"`
}

LoadBalancerHealthCheck defines load balancer health check settings

type MeshConfig added in v0.3.0

type MeshConfig struct {
	Enabled      *bool  `yaml:"enabled,omitempty" json:"enabled,omitempty"`
	NetworkCIDR  string `yaml:"networkCIDR,omitempty" json:"networkCIDR,omitempty"`
	Interface    string `yaml:"interface,omitempty" json:"interface,omitempty"`
	ListenPort   int    `yaml:"listenPort,omitempty" json:"listenPort,omitempty"`
	SubnetBits   int    `yaml:"subnetBits,omitempty" json:"subnetBits,omitempty"`
	NATTraversal bool   `yaml:"natTraversal,omitempty" json:"natTraversal,omitempty"`
}

MeshConfig describes the private node mesh. A single node still uses the same model, with no remote peers.

type MonitoringConfig

type MonitoringConfig struct {
	Enabled   bool   `yaml:"enabled" json:"enabled"`                         // Enable monitoring for this service
	Interval  string `yaml:"interval,omitempty" json:"interval,omitempty"`   // Check interval (e.g., "60s")
	Webhook   string `yaml:"webhook,omitempty" json:"webhook,omitempty"`     // Webhook URL for alerts
	CheckType string `yaml:"checkType,omitempty" json:"checkType,omitempty"` // "http" or "container" (default: auto-detect)
}

MonitoringConfig defines per-service monitoring settings

type NotificationsConfig added in v0.0.3

type NotificationsConfig struct {
	Slack   string `yaml:"slack,omitempty" json:"slack,omitempty"`     // Slack webhook URL
	Discord string `yaml:"discord,omitempty" json:"discord,omitempty"` // Discord webhook URL
	Webhook string `yaml:"webhook,omitempty" json:"webhook,omitempty"` // Generic webhook URL
}

NotificationsConfig defines notification settings

type ParallelConfig

type ParallelConfig struct {
	MaxConcurrentBuilds  int    `yaml:"maxConcurrentBuilds,omitempty" json:"maxConcurrentBuilds,omitempty"`   // Default: 4
	MaxConcurrentDeploys int    `yaml:"maxConcurrentDeploys,omitempty" json:"maxConcurrentDeploys,omitempty"` // Default: 4
	Strategy             string `yaml:"strategy,omitempty" json:"strategy,omitempty"`                         // "dependency-aware" (default), "resource-aware", "round-robin"
}

ParallelConfig defines parallel deployment settings

type PlacementConfig

type PlacementConfig struct {
	Strategy    string   `yaml:"strategy,omitempty" json:"strategy,omitempty"`       // "spread", "pinned", "any", "global"
	Servers     []string `yaml:"servers,omitempty" json:"servers,omitempty"`         // Pin to specific servers (for "pinned" strategy)
	Constraints []string `yaml:"constraints,omitempty" json:"constraints,omitempty"` // Node label constraints (e.g., "node.labels.type==high-memory")
	Preferences []string `yaml:"preferences,omitempty" json:"preferences,omitempty"` // Placement preferences (e.g., "spread=node.labels.region")
}

PlacementConfig defines where service replicas should run

type PortPublish added in v0.8.2

type PortPublish struct {
	// HostIP restricts the bind address; empty binds all interfaces.
	HostIP        string
	HostPort      int
	ContainerPort int
	// Protocol is "tcp" or "udp".
	Protocol string
}

PortPublish is a parsed service ports entry: a host port bound directly on the node (docker --publish), bypassing tako-proxy for raw TCP/UDP traffic.

func ParsePortPublish added in v0.8.2

func ParsePortPublish(entry string) (PortPublish, error)

ParsePortPublish parses a ports entry in docker-compose publish syntax: "PORT", "HOST:CONTAINER", "IP:HOST:CONTAINER" (IPv6 in brackets), each with an optional "/tcp" or "/udp" suffix.

func (PortPublish) String added in v0.8.2

func (p PortPublish) String() string

String renders the entry in canonical docker --publish syntax.

type ProjectConfig

type ProjectConfig struct {
	Name    string `yaml:"name" json:"name"`
	Version string `yaml:"version" json:"version"`
}

type ProxyBasicAuthConfig added in v0.8.1

type ProxyBasicAuthConfig struct {
	Username string `yaml:"username" json:"username"`
	// PasswordBcrypt is the pre-computed bcrypt hash of the password —
	// never the plaintext. Mint one with `tako proxy hash-password`.
	// A pre-computed hash keeps redeploys idempotent (hashing at deploy
	// time would salt fresh every run and churn the proxy config).
	PasswordBcrypt string `yaml:"passwordBcrypt" json:"passwordBcrypt"`
}

ProxyBasicAuthConfig protects a proxy route with HTTP basic auth.

type ProxyConfig

type ProxyConfig struct {
	// Domain is where public traffic is served.
	Domain string `yaml:"domain,omitempty" json:"domain,omitempty"`

	// Domains adds co-equal serving hostnames beside Domain. Each serves
	// the same upstreams with its own ACME certificate; Domain stays the
	// primary for URL display and as the redirect target.
	Domains []string `yaml:"domains,omitempty" json:"domains,omitempty"`

	// Host is where internal traffic is served when visibility is internal.
	Host string `yaml:"host,omitempty" json:"host,omitempty"`

	// Visibility controls whether the route is public ACME-backed ingress or
	// private HTTP-only ingress intended for LAN/VPN/hosts-file resolution.
	Visibility string `yaml:"visibility,omitempty" json:"visibility,omitempty"`

	// CDN declares that public DNS intentionally terminates at an external
	// CDN. Domain readiness heuristics never substitute for this declaration.
	CDN string `yaml:"cdn,omitempty" json:"cdn,omitempty"`

	// RedirectFrom specifies domains that should redirect to the primary Domain
	// These domains will get their own TLS certificates and 301 redirect to Domain
	// Example: ["www.example.com", "old.example.com"] -> redirects to "example.com"
	RedirectFrom []string `yaml:"redirectFrom,omitempty" json:"redirectFrom,omitempty"`

	Email string    `yaml:"email,omitempty" json:"email,omitempty"` // Email for Let's Encrypt
	TLS   TLSConfig `yaml:"tls,omitempty" json:"tls,omitempty"`

	// DynamicDomains enables ask-gated on-demand TLS for customer domains.
	DynamicDomains *DynamicDomainsConfig `yaml:"dynamicDomains,omitempty" json:"dynamicDomains,omitempty"`

	// BasicAuth protects every serving domain of this route with HTTP
	// basic authentication before requests reach the service.
	BasicAuth *ProxyBasicAuthConfig `yaml:"basicAuth,omitempty" json:"basicAuth,omitempty"`

	// AllowIps restricts the route to the listed client IPs/CIDRs; other
	// addresses receive 403. It matches the TCP peer unless TrustedProxies
	// is configured, in which case it matches Caddy's parsed client IP.
	AllowIps []string `yaml:"allowIps,omitempty" json:"allowIps,omitempty"`

	// TrustedProxies declares the explicit proxy/CDN CIDRs whose forwarded
	// client IP headers Caddy may trust for this route. CIDRs only.
	TrustedProxies []string `yaml:"trustedProxies,omitempty" json:"trustedProxies,omitempty"`
}

ProxyConfig defines per-service proxy settings.

func (*ProxyConfig) EffectiveVisibility added in v0.6.1

func (p *ProxyConfig) EffectiveVisibility() string

func (*ProxyConfig) GetAllDomains added in v0.0.3

func (p *ProxyConfig) GetAllDomains() []string

GetAllDomains returns all serving domains — the primary first, then the additional `domains` entries — excluding redirect domains.

func (*ProxyConfig) GetAllHosts added in v0.6.1

func (p *ProxyConfig) GetAllHosts() []string

func (*ProxyConfig) GetPrimaryDomain added in v0.0.3

func (p *ProxyConfig) GetPrimaryDomain() string

GetPrimaryDomain returns the primary domain for this service

func (*ProxyConfig) GetPrimaryHost added in v0.6.1

func (p *ProxyConfig) GetPrimaryHost() string

func (*ProxyConfig) GetRedirectDomains added in v0.0.3

func (p *ProxyConfig) GetRedirectDomains() []string

GetRedirectDomains returns all domains that should redirect to the primary domain

func (*ProxyConfig) HasRedirects added in v0.0.3

func (p *ProxyConfig) HasRedirects() bool

HasRedirects returns true if there are redirect domains configured

func (*ProxyConfig) IsInternal added in v0.6.1

func (p *ProxyConfig) IsInternal() bool

func (*ProxyConfig) IsPublic added in v0.6.1

func (p *ProxyConfig) IsPublic() bool

type RegistryConfig added in v0.3.0

type RegistryConfig struct {
	Username string `yaml:"username,omitempty" json:"username,omitempty"` // Use ${ENV_VAR}
	Password string `yaml:"password,omitempty" json:"password,omitempty"` // Use ${ENV_VAR}
}

ProjectConfig defines project metadata RegistryConfig holds credentials for one private image registry.

type ReleaseConfig added in v0.8.0

type ReleaseConfig struct {
	Command []string `yaml:"command,omitempty" json:"command,omitempty"`
	Timeout string   `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	// Volumes opts the release container into the service's volume mounts.
	Volumes bool `yaml:"volumes,omitempty" json:"volumes,omitempty"`
}

ReleaseConfig runs a command from the new revision's image exactly once per applied deploy, before traffic cutover; a non-zero exit aborts the rollout. Making the command itself re-runnable (e.g. migrations) is the application's responsibility.

type ResourceLimitsConfig added in v0.6.0

type ResourceLimitsConfig struct {
	Memory string `yaml:"memory,omitempty" json:"memory,omitempty"` // Docker memory limit, for example 512m or 1g
	CPUs   string `yaml:"cpus,omitempty" json:"cpus,omitempty"`     // Docker --cpus limit, for example 0.5 or 2
}

ResourceLimitsConfig defines container runtime resource limits.

type RuntimeConfig added in v0.3.0

type RuntimeConfig struct {
	Mode  string       `yaml:"mode,omitempty" json:"mode,omitempty"` // takod
	Proxy string       `yaml:"proxy,omitempty" json:"proxy,omitempty"`
	Agent *AgentConfig `yaml:"agent,omitempty" json:"agent,omitempty"`
}

RuntimeConfig selects the orchestration runtime. Tako has one public runtime: takod. Single-node deployments are just one-node meshes.

type ServerConfig

type ServerConfig struct {
	Host        string            `yaml:"host" json:"host"`
	PrivateHost string            `yaml:"privateHost,omitempty" json:"privateHost,omitempty"`
	User        string            `yaml:"user" json:"user"`
	Port        int               `yaml:"port,omitempty" json:"port,omitempty"`
	SSHKey      string            `yaml:"sshKey,omitempty" json:"sshKey,omitempty"`     // Path to SSH private key (mutually exclusive with password)
	Password    string            `yaml:"password,omitempty" json:"password,omitempty"` // SSH password (mutually exclusive with sshKey, use env var for security)
	Labels      map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`     // Custom labels for server selection
	// Transport controls routine takod traffic only. The empty value preserves
	// the historical SSH-first behavior. auto/local require the immutable IDs
	// below; privileged setup, join, repair, and upgrade remain SSH operations.
	Transport string `yaml:"transport,omitempty" json:"transport,omitempty"`
	ClusterID string `yaml:"clusterId,omitempty" json:"clusterId,omitempty"`
	NodeID    string `yaml:"nodeId,omitempty" json:"nodeId,omitempty"`
	WorkerUID int    `yaml:"workerUid,omitempty" json:"workerUid,omitempty"`
	// Platform-owned fields are materialized from the protected cluster
	// inventory and can never be supplied by application YAML/JSON.
	MeshIP                string   `yaml:"-" json:"-"`
	Lifecycle             string   `yaml:"-" json:"-"`
	Roles                 []string `yaml:"-" json:"-"`
	SSHHostKeyType        string   `yaml:"-" json:"-"`
	SSHHostKey            string   `yaml:"-" json:"-"`
	SSHHostKeyFingerprint string   `yaml:"-" json:"-"`
}

ServerConfig defines server connection details

func (ServerConfig) HasPlatformRole added in v0.10.0

func (s ServerConfig) HasPlatformRole(role string) bool

HasPlatformRole preserves legacy configs (which have no controller-owned roles) while enforcing roles on enrolled inventory members.

func (ServerConfig) Schedulable added in v0.10.0

func (s ServerConfig) Schedulable() bool

type ServerSelector

type ServerSelector struct {
	Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"` // Match servers with these labels
	Any    bool              `yaml:"any,omitempty" json:"any,omitempty"`       // Select any available server
}

ServerSelector defines label-based server selection

type ServiceConfig

type ServiceConfig struct {

	// Kind selects the workload type: "service" (default, long-running
	// containers) or "job" (a command run on a cron schedule by takod).
	Kind string `yaml:"kind,omitempty" json:"kind,omitempty"`
	// Schedule is the cron expression for kind: job (five-field cron or
	// descriptors like @hourly). Evaluated in UTC unless timezone is set.
	Schedule string `yaml:"schedule,omitempty" json:"schedule,omitempty"`
	// Timezone is the IANA zone the schedule is evaluated in (kind: job).
	Timezone string `yaml:"timezone,omitempty" json:"timezone,omitempty"`
	// Timeout kills a job run after this duration (kind: job, default 1h).
	Timeout string `yaml:"timeout,omitempty" json:"timeout,omitempty"`

	// Build or Image (mutually exclusive)
	Build       string            `yaml:"build,omitempty" json:"build,omitempty"` // Path to build context (auto-detects Dockerfile)
	BuildArgs   map[string]string `yaml:"-" json:"-"`
	BuildTarget string            `yaml:"-" json:"-"`
	Dockerfile  string            `yaml:"dockerfile,omitempty" json:"dockerfile,omitempty"` // Dockerfile path relative to build context
	Image       string            `yaml:"image,omitempty" json:"image,omitempty"`           // Pre-built image (for postgres, redis, etc)
	ImageFrom   string            `yaml:"imageFrom,omitempty" json:"imageFrom,omitempty"`   // shared build, or source service for kind: run
	// SharedBuildHash fingerprints the resolved top-level build definition
	// without duplicating it into each service's public config shape.
	SharedBuildHash string `yaml:"-" json:"-"`

	// Basic settings
	Port int `yaml:"port,omitempty" json:"port,omitempty"`
	// Ports publishes raw TCP/UDP host ports directly on the node, bypassing
	// tako-proxy (docker-compose syntax: "PORT", "HOST:CONTAINER",
	// "IP:HOST:CONTAINER", optional "/tcp" or "/udp"). Requires the recreate
	// deploy strategy and at most one replica.
	Ports      []string          `yaml:"ports,omitempty" json:"ports,omitempty"`
	Command    StringOrList      `yaml:"command,omitempty" json:"command,omitempty,omitzero"`
	Entrypoint StringOrList      `yaml:"entrypoint,omitempty" json:"entrypoint,omitempty,omitzero"`
	Labels     map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
	Replicas   int               `yaml:"replicas,omitempty" json:"replicas,omitempty"` // Default: 1
	Restart    string            `yaml:"restart,omitempty" json:"restart,omitempty"`   // Docker restart policy (always, unless-stopped, on-failure, no)
	Env        map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
	EnvFile    string            `yaml:"envFile,omitempty" json:"envFile,omitempty"` // Legacy single .env file path
	EnvFiles   []string          `yaml:"envFiles,omitempty" json:"envFiles,omitempty"`
	// RunInputHash is an internal digest of the fully resolved env/secret file
	// used to fingerprint kind:run executions without persisting secret values.
	RunInputHash    string                  `yaml:"-" json:"-"`
	User            string                  `yaml:"user,omitempty" json:"user,omitempty"`
	WorkingDir      string                  `yaml:"workingDir,omitempty" json:"workingDir,omitempty"`
	StopGracePeriod string                  `yaml:"stopGracePeriod,omitempty" json:"stopGracePeriod,omitempty"`
	Init            bool                    `yaml:"init,omitempty" json:"init,omitempty"`
	ExtraHosts      []string                `yaml:"extraHosts,omitempty" json:"extraHosts,omitempty"`
	Ulimits         map[string]UlimitConfig `yaml:"ulimits,omitempty" json:"ulimits,omitempty"`
	ShmSize         string                  `yaml:"shmSize,omitempty" json:"shmSize,omitempty"`

	// Secrets: ["DATABASE_URL", "JWT_SECRET"] or ["VAR_NAME:SECRET_KEY"].
	Secrets []string            `yaml:"secrets,omitempty" json:"secrets,omitempty"` // Tako secrets from .tako/secrets files
	Volumes []string            `yaml:"volumes,omitempty" json:"volumes,omitempty"`
	Files   []ServiceFileConfig `yaml:"files,omitempty" json:"files,omitempty"`
	// FilesContentHash is an internal digest of fully resolved operator file
	// metadata and bytes; file contents never enter desired state or labels.
	FilesContentHash string `yaml:"-" json:"-"`

	// Service type flags
	Persistent bool `yaml:"persistent,omitempty" json:"persistent,omitempty"` // Don't remove on redeploy (databases, caches)

	// Per-service proxy settings (if present, service is exposed publicly)
	Proxy *ProxyConfig `yaml:"proxy,omitempty" json:"proxy,omitempty"`

	// Load balancing (for multi-replica services)
	LoadBalancer LoadBalancerConfig `yaml:"loadBalancer,omitempty" json:"loadBalancer,omitempty"`

	// Health checks
	HealthCheck HealthCheckConfig `yaml:"healthCheck,omitempty" json:"healthCheck,omitempty"`

	// Deployment strategy
	Deploy DeployConfig `yaml:"deploy,omitempty" json:"deploy,omitempty"`

	// Per-service backup
	Backup *BackupConfig `yaml:"backup,omitempty" json:"backup,omitempty"`

	// Per-service monitoring
	Monitoring *MonitoringConfig `yaml:"monitoring,omitempty" json:"monitoring,omitempty"`

	// Container resource limits.
	Resources *ResourceLimitsConfig `yaml:"resources,omitempty" json:"resources,omitempty"`

	// Cross-project networking
	Export  bool     `yaml:"export,omitempty" json:"export,omitempty"`   // Attach this service to a service-scoped export network
	Imports []string `yaml:"imports,omitempty" json:"imports,omitempty"` // Import same-environment services from other projects (format: "project.service")

	// Placement configuration for takod scheduling.
	Placement *PlacementConfig `yaml:"placement,omitempty" json:"placement,omitempty"` // Where to run service replicas

	// Service dependencies (controls deployment order)
	DependsOn []string `yaml:"dependsOn,omitempty" json:"dependsOn,omitempty"` // List of service names this service depends on

	// ReuseFiles tells rollback paths to mount an already-published immutable
	// FilesContentHash instead of reading today's local sources.
	ReuseFiles bool `yaml:"-" json:"-"`
	// contains filtered or unexported fields
}

ServiceConfig defines service deployment settings

func (*ServiceConfig) ClearBuild added in v0.9.0

func (s *ServiceConfig) ClearBuild()

ClearBuild removes the complete build definition when an image override changes the service to a prebuilt image.

func (*ServiceConfig) GetServiceType

func (s *ServiceConfig) GetServiceType() string

GetServiceType returns the auto-detected service type

func (*ServiceConfig) IsInternal

func (s *ServiceConfig) IsInternal() bool

IsInternal returns true if service is internal-only

func (*ServiceConfig) IsJob added in v0.8.0

func (s *ServiceConfig) IsJob() bool

IsJob reports whether the service is a scheduled job workload.

func (*ServiceConfig) IsProxied added in v0.6.1

func (s *ServiceConfig) IsProxied() bool

IsProxied returns true when the service should be routed through tako-proxy.

func (*ServiceConfig) IsPublic

func (s *ServiceConfig) IsPublic() bool

IsPublic returns true if service should be exposed publicly

func (*ServiceConfig) IsRun added in v0.9.0

func (s *ServiceConfig) IsRun() bool

IsRun reports whether the service is a deploy-time run-to-completion step.

func (*ServiceConfig) IsWorker

func (s *ServiceConfig) IsWorker() bool

IsWorker returns true if service is a background worker

func (ServiceConfig) MarshalJSON added in v0.9.0

func (s ServiceConfig) MarshalJSON() ([]byte, error)

MarshalJSON mirrors MarshalYAML so API/config JSON preserves structured build options without exposing internal helper fields.

func (ServiceConfig) MarshalYAML added in v0.9.0

func (s ServiceConfig) MarshalYAML() (any, error)

MarshalYAML preserves structured build form when it was configured or when build options are present. Simple build contexts remain scalar.

func (*ServiceConfig) UnmarshalJSON added in v0.9.0

func (s *ServiceConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON provides the same scalar/object build union for strict JSON config files. The inner alias decoder preserves unknown-field rejection.

func (*ServiceConfig) UnmarshalYAML added in v0.9.0

func (s *ServiceConfig) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML accepts the legacy scalar build context and the structured context/args/target form while keeping ServiceConfig.Build source-compatible.

type ServiceFileConfig added in v0.9.0

type ServiceFileConfig struct {
	Source string `yaml:"source" json:"source"`
	Target string `yaml:"target" json:"target"`
	Secret bool   `yaml:"secret,omitempty" json:"secret,omitempty"`
	Owner  string `yaml:"owner,omitempty" json:"owner,omitempty"`
}

ServiceFileConfig distributes one local regular file or directory into a service container as a read-only bind mount. Secret forces private modes.

type SharedBuildConfig added in v0.9.0

type SharedBuildConfig struct {
	Context    string            `yaml:"context" json:"context"`
	Args       map[string]string `yaml:"args,omitempty" json:"args,omitempty"`
	Target     string            `yaml:"target,omitempty" json:"target,omitempty"`
	Dockerfile string            `yaml:"dockerfile,omitempty" json:"dockerfile,omitempty"`
	// contains filtered or unexported fields
}

SharedBuildConfig declares one image build consumed by any number of services through imageFrom.

func (SharedBuildConfig) DeclaredContext added in v0.9.0

func (b SharedBuildConfig) DeclaredContext() string

func (SharedBuildConfig) Fingerprint added in v0.9.0

func (b SharedBuildConfig) Fingerprint() string

type StateConfig added in v0.3.0

type StateConfig struct {
	Backend            string `yaml:"backend,omitempty" json:"backend,omitempty"`                       // replicated
	DeployConsistency  string `yaml:"deployConsistency,omitempty" json:"deployConsistency,omitempty"`   // lease
	OnUnreachableNode  string `yaml:"onUnreachableNode,omitempty" json:"onUnreachableNode,omitempty"`   // block
	RemoteCacheEnabled *bool  `yaml:"remoteCacheEnabled,omitempty" json:"remoteCacheEnabled,omitempty"` // must be true
}

StateConfig controls how Tako treats local cache, remote runtime truth, and deployment consistency.

type StringOrList added in v0.9.0

type StringOrList struct {
	// contains filtered or unexported fields
}

StringOrList preserves whether a config value used scalar (shell/shorthand) or list (exec/argv) form while supporting both YAML and JSON.

func ListValue added in v0.9.0

func ListValue(values ...string) StringOrList

ListValue constructs list/argv form.

func StringValue added in v0.9.0

func StringValue(value string) StringOrList

StringValue constructs scalar form.

func (StringOrList) Arguments added in v0.9.0

func (v StringOrList) Arguments() []string

Arguments returns a defensive copy of list form, or a one-element list for scalar form. Unset values return nil.

func (StringOrList) ContainerCommand added in v0.9.0

func (v StringOrList) ContainerCommand() []string

ContainerCommand converts legacy scalar command form to its existing shell behavior and passes list form through as raw argv.

func (StringOrList) IsList added in v0.9.0

func (v StringOrList) IsList() bool

IsList reports whether list form was supplied.

func (StringOrList) IsSet added in v0.9.0

func (v StringOrList) IsSet() bool

IsSet reports whether the field was supplied, including an explicitly empty scalar or list (which validation can reject).

func (StringOrList) IsZero added in v0.9.0

func (v StringOrList) IsZero() bool

IsZero supports omitempty for unset values.

func (StringOrList) MarshalJSON added in v0.9.0

func (v StringOrList) MarshalJSON() ([]byte, error)

func (StringOrList) MarshalYAML added in v0.9.0

func (v StringOrList) MarshalYAML() (any, error)

func (StringOrList) Scalar added in v0.9.0

func (v StringOrList) Scalar() (string, bool)

Scalar returns scalar form and whether the value used that form.

func (*StringOrList) UnmarshalJSON added in v0.9.0

func (v *StringOrList) UnmarshalJSON(data []byte) error

func (*StringOrList) UnmarshalYAML added in v0.9.0

func (v *StringOrList) UnmarshalYAML(node *yaml.Node) error

type TLSConfig

type TLSConfig struct {
	Mode      string `yaml:"mode,omitempty" json:"mode,omitempty"`         // auto, off
	Provider  string `yaml:"provider,omitempty" json:"provider,omitempty"` // letsencrypt, zerossl (default: letsencrypt)
	Staging   bool   `yaml:"staging,omitempty" json:"staging,omitempty"`
	Challenge string `yaml:"challenge,omitempty" json:"challenge,omitempty"` // auto, dns
}

TLSConfig defines TLS settings

type UlimitConfig added in v0.9.0

type UlimitConfig struct {
	Soft int64 `yaml:"soft" json:"soft"`
	Hard int64 `yaml:"hard" json:"hard"`
}

UlimitConfig supports Compose's scalar limit shorthand and soft/hard form.

func (*UlimitConfig) UnmarshalJSON added in v0.9.0

func (u *UlimitConfig) UnmarshalJSON(data []byte) error

func (*UlimitConfig) UnmarshalYAML added in v0.9.0

func (u *UlimitConfig) UnmarshalYAML(node *yaml.Node) error

type ValidationWarning added in v0.9.3

type ValidationWarning struct {
	Environment string
	Service     string
	Field       string
	Message     string
}

ValidationWarning is a non-fatal, structured config diagnostic.

func ValidationWarnings added in v0.9.3

func ValidationWarnings(cfg *Config) []ValidationWarning

ValidationWarnings returns deterministic diagnostics after ValidateConfig.

type VolumeConfig added in v0.1.3

type VolumeConfig struct {
	Driver     string            `yaml:"driver,omitempty" json:"driver,omitempty"`           // Volume driver (default: "local")
	DriverOpts map[string]string `yaml:"driver_opts,omitempty" json:"driver_opts,omitempty"` // Driver-specific options
	Labels     map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`           // Volume labels
	External   bool              `yaml:"external,omitempty" json:"external,omitempty"`       // If true, volume must already exist
	Name       string            `yaml:"name,omitempty" json:"name,omitempty"`               // Override the auto-generated name (opt-out of prefix)
}

VolumeConfig defines a named service volume configuration.

Jump to

Keyboard shortcuts

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