Documentation
¶
Overview ¶
Package runtime provides Docker runtime implementation
Package runtime provides gVisor runtime implementation ¶
Package runtime provides Kubernetes runtime implementation ¶
Package runtime provides a lightweight OCI image puller using only standard library ¶
Package runtime provides interfaces and implementations for container runtimes
Index ¶
- type Config
- type DockerFactory
- type DockerManifestList
- type DockerRuntime
- func (r *DockerRuntime) CreateAgent(ctx context.Context, agent *arctypes.Agent) error
- func (r *DockerRuntime) DestroyAgent(ctx context.Context, agentID string) error
- func (r *DockerRuntime) ExecCommand(ctx context.Context, agentID string, cmd []string) (io.ReadCloser, error)
- func (r *DockerRuntime) GetAgentStatus(ctx context.Context, agentID string) (*arctypes.Agent, error)
- func (r *DockerRuntime) ListAgents(ctx context.Context) ([]*arctypes.Agent, error)
- func (r *DockerRuntime) StartAgent(ctx context.Context, agentID string) error
- func (r *DockerRuntime) StopAgent(ctx context.Context, agentID string) error
- func (r *DockerRuntime) StreamLogs(ctx context.Context, agentID string) (io.ReadCloser, error)
- type Factory
- type GVisorConfig
- type GVisorPlatform
- type GVisorRuntime
- func (r *GVisorRuntime) CreateAgent(ctx context.Context, agent *arctypes.Agent) error
- func (r *GVisorRuntime) DestroyAgent(ctx context.Context, agentID string) error
- func (r *GVisorRuntime) ExecCommand(ctx context.Context, agentID string, cmd []string) (io.ReadCloser, error)
- func (r *GVisorRuntime) GetAgentLogs(ctx context.Context, agentID string, follow bool) (io.ReadCloser, error)
- func (r *GVisorRuntime) GetAgentStatus(ctx context.Context, agentID string) (*arctypes.Agent, error)
- func (r *GVisorRuntime) GetRuntimeInfo(ctx context.Context) (map[string]interface{}, error)
- func (r *GVisorRuntime) ListAgents(ctx context.Context) ([]*arctypes.Agent, error)
- func (r *GVisorRuntime) Shutdown(ctx context.Context) error
- func (r *GVisorRuntime) StartAgent(ctx context.Context, agentID string) error
- func (r *GVisorRuntime) StopAgent(ctx context.Context, agentID string) error
- func (r *GVisorRuntime) StreamLogs(ctx context.Context, agentID string) (io.ReadCloser, error)
- type HealthStatus
- type ImageCacheEntry
- type KubernetesFactory
- type KubernetesRuntime
- func (r *KubernetesRuntime) CreateAgent(ctx context.Context, agent *arctypes.Agent) error
- func (r *KubernetesRuntime) DestroyAgent(ctx context.Context, agentID string) error
- func (r *KubernetesRuntime) ExecCommand(ctx context.Context, agentID string, cmd []string) (io.ReadCloser, error)
- func (r *KubernetesRuntime) GetAgentStatus(ctx context.Context, agentID string) (*arctypes.Agent, error)
- func (r *KubernetesRuntime) ListAgents(ctx context.Context) ([]*arctypes.Agent, error)
- func (r *KubernetesRuntime) StartAgent(ctx context.Context, agentID string) error
- func (r *KubernetesRuntime) StopAgent(ctx context.Context, agentID string) error
- func (r *KubernetesRuntime) StreamLogs(ctx context.Context, agentID string) (io.ReadCloser, error)
- type NetworkConfig
- type OCIManifest
- type OCIPuller
- type ResourceUsage
- type Runtime
- type TokenResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Type string // "docker" or "kubernetes"
Endpoint string // Docker socket or K8s API endpoint
Namespace string // K8s namespace
KubeConfig string // Path to kubeconfig file
Labels map[string]string // Default labels for agents
// Image validation and security settings
EnableImageValidation bool // Enable image validation
EnableSecurityScan bool // Enable vulnerability scanning
AllowedRegistries []string // List of allowed registries
BlockedRegistries []string // List of blocked registries
RequireImageDigest bool // Require images to have digest
MaxImageAgeDays int // Maximum age of images in days
EnforceTrustedImages bool // Require signed images
// CVE thresholds
AllowCriticalCVEs bool // Allow images with critical CVEs
MaxHighCVEs int // Maximum allowed high severity CVEs
MaxMediumCVEs int // Maximum allowed medium severity CVEs
}
Config holds runtime configuration
type DockerManifestList ¶
type DockerManifestList struct {
SchemaVersion int `json:"schemaVersion"`
MediaType string `json:"mediaType"`
Manifests []struct {
MediaType string `json:"mediaType"`
Size int64 `json:"size"`
Digest string `json:"digest"`
Platform struct {
Architecture string `json:"architecture"`
OS string `json:"os"`
} `json:"platform"`
} `json:"manifests"`
}
DockerManifestList for multi-arch images
type DockerRuntime ¶
type DockerRuntime struct {
// contains filtered or unexported fields
}
DockerRuntime implements Runtime interface for Docker
func NewDockerRuntime ¶
func NewDockerRuntime(config Config) (*DockerRuntime, error)
NewDockerRuntime creates a new Docker runtime
func (*DockerRuntime) CreateAgent ¶
CreateAgent creates a new agent container
func (*DockerRuntime) DestroyAgent ¶
func (r *DockerRuntime) DestroyAgent(ctx context.Context, agentID string) error
DestroyAgent removes an agent container
func (*DockerRuntime) ExecCommand ¶
func (r *DockerRuntime) ExecCommand(ctx context.Context, agentID string, cmd []string) (io.ReadCloser, error)
ExecCommand executes a command in an agent container
func (*DockerRuntime) GetAgentStatus ¶
func (r *DockerRuntime) GetAgentStatus(ctx context.Context, agentID string) (*arctypes.Agent, error)
GetAgentStatus returns the current status of an agent
func (*DockerRuntime) ListAgents ¶
ListAgents returns all agents managed by this runtime
func (*DockerRuntime) StartAgent ¶
func (r *DockerRuntime) StartAgent(ctx context.Context, agentID string) error
StartAgent starts an agent container
func (*DockerRuntime) StopAgent ¶
func (r *DockerRuntime) StopAgent(ctx context.Context, agentID string) error
StopAgent stops an agent container
func (*DockerRuntime) StreamLogs ¶
func (r *DockerRuntime) StreamLogs(ctx context.Context, agentID string) (io.ReadCloser, error)
StreamLogs streams logs from an agent container
type GVisorConfig ¶
type GVisorConfig struct {
Config // Embed base config
// gVisor specific settings
Platform GVisorPlatform `json:"platform,omitempty"`
Debug bool `json:"debug,omitempty"`
LogLevel string `json:"log_level,omitempty"`
EnableProfiling bool `json:"enable_profiling,omitempty"`
// Security settings
EnableSandbox bool `json:"enable_sandbox"`
AllowedSyscalls []string `json:"allowed_syscalls,omitempty"`
BlockedSyscalls []string `json:"blocked_syscalls,omitempty"`
EnableSeccomp bool `json:"enable_seccomp"`
EnableAppArmor bool `json:"enable_apparmor"`
// Network settings
NetworkMode string `json:"network_mode,omitempty"` // "none", "host", "bridge"
EnableIPv6 bool `json:"enable_ipv6,omitempty"`
DNSServers []string `json:"dns_servers,omitempty"`
// Resource settings
EnableCgroups bool `json:"enable_cgroups"`
CgroupsPath string `json:"cgroups_path,omitempty"`
// Image settings
ImageCacheSize int64 `json:"image_cache_size,omitempty"` // In bytes
ImageCacheTTL time.Duration `json:"image_cache_ttl,omitempty"`
// Monitoring
EnableHealthChecks bool `json:"enable_health_checks"`
HealthCheckInterval time.Duration `json:"health_check_interval,omitempty"`
}
GVisorConfig extends the base Config with gVisor-specific options
type GVisorPlatform ¶
type GVisorPlatform string
GVisorPlatform represents supported gVisor platforms
const ( PlatformPtrace GVisorPlatform = "ptrace" // Most compatible PlatformKVM GVisorPlatform = "kvm" // Hardware virtualization PlatformSystrap GVisorPlatform = "systrap" // Fastest, requires kernel 4.12+ )
type GVisorRuntime ¶
type GVisorRuntime struct {
// contains filtered or unexported fields
}
GVisorRuntime implements Runtime interface for gVisor with production features
func NewGVisorRuntime ¶
func NewGVisorRuntime(config Config) (*GVisorRuntime, error)
NewGVisorRuntime creates a new production-ready gVisor runtime
func NewGVisorRuntimeWithConfig ¶
func NewGVisorRuntimeWithConfig(config GVisorConfig) (*GVisorRuntime, error)
NewGVisorRuntimeWithConfig creates a new gVisor runtime with detailed configuration
func (*GVisorRuntime) CreateAgent ¶
CreateAgent creates a new agent container using gVisor
func (*GVisorRuntime) DestroyAgent ¶
func (r *GVisorRuntime) DestroyAgent(ctx context.Context, agentID string) error
DestroyAgent removes an agent container and cleans up resources
func (*GVisorRuntime) ExecCommand ¶
func (r *GVisorRuntime) ExecCommand(ctx context.Context, agentID string, cmd []string) (io.ReadCloser, error)
ExecCommand executes a command in an agent container
func (*GVisorRuntime) GetAgentLogs ¶
func (r *GVisorRuntime) GetAgentLogs(ctx context.Context, agentID string, follow bool) (io.ReadCloser, error)
GetAgentLogs returns logs from an agent container
func (*GVisorRuntime) GetAgentStatus ¶
func (r *GVisorRuntime) GetAgentStatus(ctx context.Context, agentID string) (*arctypes.Agent, error)
GetAgentStatus returns comprehensive status of an agent
func (*GVisorRuntime) GetRuntimeInfo ¶
func (r *GVisorRuntime) GetRuntimeInfo(ctx context.Context) (map[string]interface{}, error)
GetRuntimeInfo returns comprehensive runtime information
func (*GVisorRuntime) ListAgents ¶
ListAgents returns all agents with enhanced metadata
func (*GVisorRuntime) Shutdown ¶
func (r *GVisorRuntime) Shutdown(ctx context.Context) error
Cleanup function
func (*GVisorRuntime) StartAgent ¶
func (r *GVisorRuntime) StartAgent(ctx context.Context, agentID string) error
StartAgent starts the agent container with enhanced security and monitoring
func (*GVisorRuntime) StopAgent ¶
func (r *GVisorRuntime) StopAgent(ctx context.Context, agentID string) error
StopAgent stops the agent container gracefully
func (*GVisorRuntime) StreamLogs ¶
func (r *GVisorRuntime) StreamLogs(ctx context.Context, agentID string) (io.ReadCloser, error)
StreamLogs streams logs from an agent container
type HealthStatus ¶
type HealthStatus struct {
Status string `json:"status"` // healthy, unhealthy, starting
LastCheck time.Time `json:"last_check"`
FailureCount int `json:"failure_count"`
Output string `json:"output,omitempty"`
}
HealthStatus represents container health information
type ImageCacheEntry ¶
type ImageCacheEntry struct {
Digest string
Size int64
LastUsed time.Time
Path string
Layers []string
Config map[string]interface{} // Generic config, was *v1.Image
}
ImageCacheEntry represents a cached container image
type KubernetesFactory ¶
type KubernetesFactory struct{}
KubernetesFactory creates Kubernetes runtime instances
type KubernetesRuntime ¶
type KubernetesRuntime struct {
// contains filtered or unexported fields
}
KubernetesRuntime implements Runtime interface for Kubernetes
func NewKubernetesRuntime ¶
func NewKubernetesRuntime(config Config) (*KubernetesRuntime, error)
NewKubernetesRuntime creates a new Kubernetes runtime
func (*KubernetesRuntime) CreateAgent ¶
CreateAgent creates a new agent pod
func (*KubernetesRuntime) DestroyAgent ¶
func (r *KubernetesRuntime) DestroyAgent(ctx context.Context, agentID string) error
DestroyAgent removes an agent pod immediately
func (*KubernetesRuntime) ExecCommand ¶
func (r *KubernetesRuntime) ExecCommand(ctx context.Context, agentID string, cmd []string) (io.ReadCloser, error)
ExecCommand executes a command in an agent pod
func (*KubernetesRuntime) GetAgentStatus ¶
func (r *KubernetesRuntime) GetAgentStatus(ctx context.Context, agentID string) (*arctypes.Agent, error)
GetAgentStatus returns the current status of an agent
func (*KubernetesRuntime) ListAgents ¶
ListAgents returns all agents managed by this runtime
func (*KubernetesRuntime) StartAgent ¶
func (r *KubernetesRuntime) StartAgent(ctx context.Context, agentID string) error
StartAgent starts an agent pod (pods start automatically in K8s)
func (*KubernetesRuntime) StopAgent ¶
func (r *KubernetesRuntime) StopAgent(ctx context.Context, agentID string) error
StopAgent stops an agent pod
func (*KubernetesRuntime) StreamLogs ¶
func (r *KubernetesRuntime) StreamLogs(ctx context.Context, agentID string) (io.ReadCloser, error)
StreamLogs streams logs from an agent pod
type NetworkConfig ¶
type NetworkConfig struct {
Mode string `json:"mode"`
IPAddress string `json:"ip_address,omitempty"`
Gateway string `json:"gateway,omitempty"`
DNS []string `json:"dns,omitempty"`
Ports map[string]string `json:"ports,omitempty"`
}
NetworkConfig holds network configuration for a container
type OCIManifest ¶
type OCIManifest struct {
SchemaVersion int `json:"schemaVersion"`
MediaType string `json:"mediaType"`
Config struct {
MediaType string `json:"mediaType"`
Size int64 `json:"size"`
Digest string `json:"digest"`
} `json:"config"`
Layers []struct {
MediaType string `json:"mediaType"`
Size int64 `json:"size"`
Digest string `json:"digest"`
} `json:"layers"`
}
OCIManifest represents a minimal OCI image manifest
type OCIPuller ¶
type OCIPuller struct {
// contains filtered or unexported fields
}
OCIPuller handles OCI image downloading using only standard library
func NewOCIPuller ¶
NewOCIPuller creates a new OCI image puller
func (*OCIPuller) ExtractLocalImage ¶
ExtractLocalImage extracts a local tar archive (for pre-downloaded images)
type ResourceUsage ¶
type ResourceUsage struct {
CPUUsage float64 `json:"cpu_usage"`
MemoryUsage int64 `json:"memory_usage"`
DiskUsage int64 `json:"disk_usage"`
NetworkRx int64 `json:"network_rx"`
NetworkTx int64 `json:"network_tx"`
UpdatedAt time.Time `json:"updated_at"`
}
ResourceUsage tracks resource consumption
type Runtime ¶
type Runtime interface {
// CreateAgent creates a new agent container
CreateAgent(ctx context.Context, agent *types.Agent) error
// StartAgent starts an agent container
StartAgent(ctx context.Context, agentID string) error
// StopAgent stops an agent container
StopAgent(ctx context.Context, agentID string) error
// DestroyAgent removes an agent container
DestroyAgent(ctx context.Context, agentID string) error
// GetAgentStatus returns the current status of an agent
GetAgentStatus(ctx context.Context, agentID string) (*types.Agent, error)
// ListAgents returns all agents managed by this runtime
ListAgents(ctx context.Context) ([]*types.Agent, error)
// StreamLogs streams logs from an agent container
StreamLogs(ctx context.Context, agentID string) (io.ReadCloser, error)
// ExecCommand executes a command in an agent container
ExecCommand(ctx context.Context, agentID string, cmd []string) (io.ReadCloser, error)
}
Runtime defines the interface for container runtimes
type TokenResponse ¶
type TokenResponse struct {
Token string `json:"token"`
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
}
TokenResponse from Docker registry auth