Documentation
¶
Index ¶
- Constants
- Variables
- func ContainerCmd() []string
- type AppReplicaInstanceList
- type ContainerCreateOptions
- type ContainerInfo
- type ContainerPath
- func (p *ContainerPath) AppReplicaFile() string
- func (p *ContainerPath) ContainerBaseDir() string
- func (p *ContainerPath) HomeDir() string
- func (p *ContainerPath) InagentFile() string
- func (p *ContainerPath) IninitFile() string
- func (p *ContainerPath) InnerStackDir() string
- func (p *ContainerPath) OptDir() string
- type ContainerStats
- type Driver
- type DriverInfo
- type HostSourcePaths
- type ImageInfo
- type MountBind
- type PortBinding
Constants ¶
const ( // HomeDir is the home directory inside container HomeDir = "/home/action" // InnerStackDir is the innerstack config directory inside container InnerStackDir = "/home/action/.innerstack" // AppReplicaFile is the app replica config file path inside container AppReplicaFile = "/home/action/.innerstack/app_replica.json" // IninitFile is the ininit script path inside container IninitFile = "/home/action/.innerstack/ininit" // InagentFile is the inagent binary path inside container InagentFile = "/home/action/.innerstack/inagent" // InagentSock is the inagent unix socket path inside container InagentSock = "unix:/home/action/.innerstack/inagent.sock" // ContainerEntrypoint is the default container entrypoint command ContainerEntrypoint = "/bin/sh" )
Container internal paths (paths inside the container)
Variables ¶
var ( // ContainerNameValid validates container names generated by ContainerName(). // Format: i8k_{instanceName}_{replicaId} // Example: i8k_myapp_1 // - Prefix: "i8k_" // - InstanceName: DNS label (lowercase alphanumeric and hyphens) // - ReplicaId: decimal integer, 1-3 digits (range 0-127, ReplicaCap <= AppReplicaCapMax) ContainerNameValid = regexp.MustCompile(`^i8k_[a-z0-9]([-a-z0-9]*[a-z0-9])?_[0-9]{1,3}$`) )
var InitDirs = []string{
"/home/action/local/bin",
"/home/action/local/share",
"/home/action/local/profile.d",
"/home/action/var/tmp",
"/home/action/var/log",
"/home/action/.ssh",
}
InitDirs are directories to be created on container initialization
Functions ¶
func ContainerCmd ¶
func ContainerCmd() []string
ContainerCmd returns the container entrypoint command
Types ¶
type AppReplicaInstanceList ¶
type AppReplicaInstanceList struct {
// contains filtered or unexported fields
}
func (*AppReplicaInstanceList) TryStore ¶
func (it *AppReplicaInstanceList) TryStore(rep *inapi.AppReplicaInstance) bool
type ContainerCreateOptions ¶
type ContainerCreateOptions struct {
Name string // container name
Image string // image name
Cmd []string // entrypoint command
Env []string // environment variables
Labels map[string]string // metadata labels
Hostname string // container hostname
CpuLimit int64 // CPU limit (millicores, 1000 = 1 core)
MemoryLimit int64 // memory limit (bytes)
Ports []PortBinding // port mappings
Mounts []MountBind // volume mounts
RestartPolicy string // no, always, on-failure, unless-stopped
DnsServers []string // DNS servers for container
VpcIPv4 string // VPC IP to assign to container
VpcSubnet string // VPC subnet CIDR for Docker network creation
}
ContainerCreateOptions defines container creation parameters.
type ContainerInfo ¶
type ContainerInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Image string `json:"image"`
ImageID string `json:"image_id"`
State string `json:"state"` // running, exited, paused, etc.
Status string `json:"status"` // detailed status
Pid int `json:"pid"` // process ID
IP string `json:"ip"` // container IP
Ports map[int32]PortBinding `json:"ports"` // port mappings (key: container port)
Created int64 `json:"created"` // unix timestamp (seconds)
Started int64 `json:"started,omitempty"` // unix timestamp (seconds)
Labels map[string]string `json:"labels,omitempty"`
CpuLimit int64 `json:"cpu_limit,omitempty"` // CPU limit (millicores)
MemoryLimit int64 `json:"memory_limit,omitempty"` // memory limit (bytes)
Binds []string `json:"binds,omitempty"` // volume binds from HostConfig
LastInspectTime int64 `json:"-"`
}
ContainerInfo represents container instance details.
type ContainerPath ¶
type ContainerPath struct {
// BasePath is the base path for app instance data on host
BasePath string
// ContainerName is the container name
ContainerName string
}
ContainerPath contains paths for a specific app instance/container
func NewContainerPath ¶
func NewContainerPath(basePath, containerName string) *ContainerPath
NewContainerPath creates a ContainerPath instance
func (*ContainerPath) AppReplicaFile ¶
func (p *ContainerPath) AppReplicaFile() string
AppReplicaFile returns the app replica json file path on host
func (*ContainerPath) ContainerBaseDir ¶
func (p *ContainerPath) ContainerBaseDir() string
ContainerBaseDir returns the container-specific directory on host
func (*ContainerPath) HomeDir ¶
func (p *ContainerPath) HomeDir() string
HomeDir returns the /home mount directory on host
func (*ContainerPath) InagentFile ¶
func (p *ContainerPath) InagentFile() string
InagentFile returns the inagent binary path on host
func (*ContainerPath) IninitFile ¶
func (p *ContainerPath) IninitFile() string
IninitFile returns the ininit script path on host
func (*ContainerPath) InnerStackDir ¶
func (p *ContainerPath) InnerStackDir() string
InnerStackDir returns the innerstack directory on host
func (*ContainerPath) OptDir ¶
func (p *ContainerPath) OptDir() string
OptDir returns the /opt mount directory on host
type ContainerStats ¶
type ContainerStats struct {
Time int64 `json:"time"` // unix timestamp (seconds)
CpuTotalUsage int64 `json:"cpu_total_usage"` // CPU total usage (nanoseconds)
MemoryUsage int64 `json:"memory_usage"` // memory usage (bytes)
MemoryCache int64 `json:"memory_cache"` // memory cache (bytes)
NetRxBytes int64 `json:"net_rx_bytes"` // network received bytes
NetTxBytes int64 `json:"net_tx_bytes"` // network transmitted bytes
BlkReadBytes int64 `json:"blk_read_bytes"` // block device read bytes
BlkWriteBytes int64 `json:"blk_write_bytes"` // block device write bytes
BlkReadOps int64 `json:"blk_read_ops"` // block device read operations
BlkWriteOps int64 `json:"blk_write_ops"` // block device write operations
}
ContainerStats holds a snapshot of resource usage statistics for a container.
type Driver ¶
type Driver interface {
Name() string
Info(ctx context.Context) (*DriverInfo, error)
Ping(ctx context.Context) error
ContainerList(ctx context.Context) ([]*ContainerInfo, error)
ContainerInspect(ctx context.Context, nameOrId string) (*ContainerInfo, error)
ContainerCreate(ctx context.Context, opts *ContainerCreateOptions) (*ContainerInfo, error)
ContainerStart(ctx context.Context, nameOrId string) error
ContainerStop(ctx context.Context, nameOrId string) error
ContainerRemove(ctx context.Context, nameOrId string) error
ImageList(ctx context.Context) ([]*ImageInfo, error)
ImagePull(ctx context.Context, image string) error
}
Driver defines the container runtime driver interface.
type DriverInfo ¶
type DriverInfo struct {
Name string `json:"name"`
Version string `json:"version"`
APIVersion string `json:"api_version,omitempty"`
OS string `json:"os,omitempty"`
Arch string `json:"arch,omitempty"`
Kernel string `json:"kernel,omitempty"`
ContainerNum int `json:"container_num,omitempty"`
ImageNum int `json:"image_num,omitempty"`
}
DriverInfo represents container driver metadata.
type HostSourcePaths ¶
type HostSourcePaths struct {
// Prefix is the installation prefix directory
Prefix string
}
HostSourcePaths contains paths for source files on host
func NewHostSourcePaths ¶
func NewHostSourcePaths(prefix string) *HostSourcePaths
NewHostSourcePaths creates a HostSourcePaths instance
func (*HostSourcePaths) InagentSlimSrc ¶
func (h *HostSourcePaths) InagentSlimSrc(arch string) string
InagentSlimSrc returns the source path of inagent slim (C++) binary for given architecture
func (*HostSourcePaths) InagentSrc ¶
func (h *HostSourcePaths) InagentSrc(arch string) string
InagentSrc returns the source path of inagent binary for given architecture
func (*HostSourcePaths) IninitSrc ¶
func (h *HostSourcePaths) IninitSrc() string
IninitSrc returns the source path of ininit script
type ImageInfo ¶
type ImageInfo struct {
Name string `json:"name"`
ID string `json:"id"`
RepoTags []string `json:"repo_tags"`
RepoDigests []string `json:"repo_digests"`
Size int64 `json:"size"` // bytes
Created int64 `json:"created"` // unix timestamp (seconds)
Labels map[string]string `json:"labels,omitempty"`
}
ImageInfo represents container image metadata.
type MountBind ¶
type MountBind struct {
HostPath string `json:"host_path"` // host path
ContainerPath string `json:"container_path"` // container path
ReadOnly bool `json:"read_only"` // read-only flag
UID int `json:"uid,omitempty"` // user id for chown (0 means no change)
GID int `json:"gid,omitempty"` // group id for chown (0 means no change)
}
MountBind represents a directory mount configuration.