containermanger

package
v0.0.0-...-ad0c36a Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigMount

type ConfigMount struct {
	ConfigID     string `json:"config_id"`
	Uid          uint   `json:"uid"`
	Gid          uint   `json:"gid"`
	FileMode     uint   `json:"file_mode"`
	MountingPath string `json:"mounting_path"`
}

type CustomHealthCheck

type CustomHealthCheck struct {
	Enabled              bool   `json:"enabled"`
	TestCommand          string `json:"test_command"`
	IntervalSeconds      uint64 `json:"interval_seconds"`       // Time between running the check in seconds
	TimeoutSeconds       uint64 `json:"timeout_seconds"`        // Maximum time to allow one check to run in seconds
	StartPeriodSeconds   uint64 `json:"start_period_seconds"`   // Start period for the container to initialize before counting retries towards unstable
	StartIntervalSeconds uint64 `json:"start_interval_seconds"` // Time between running the check during the start period
	Retries              uint64 `json:"retries"`                // Consecutive failures needed to report unhealthy
}

type DeploymentMode

type DeploymentMode string
const (
	DeploymentModeReplicated DeploymentMode = "replicated"
	DeploymentModeGlobal     DeploymentMode = "global"
)

type DockerProxyConfig

type DockerProxyConfig struct {
	Permission DockerProxyPermission `json:"permissions" gorm:"embedded;embeddedPrefix:permission_"`
}

type DockerProxyPermission

type DockerProxyPermission struct {
	Ping         DockerProxyPermissionType `json:"ping" gorm:"default:read"`
	Version      DockerProxyPermissionType `json:"version" gorm:"default:none"`
	Info         DockerProxyPermissionType `json:"info" gorm:"default:none"`
	Events       DockerProxyPermissionType `json:"events" gorm:"default:none"`
	Auth         DockerProxyPermissionType `json:"auth" gorm:"default:none"`
	Secrets      DockerProxyPermissionType `json:"secrets" gorm:"default:none"`
	Build        DockerProxyPermissionType `json:"build" gorm:"default:none"`
	Commit       DockerProxyPermissionType `json:"commit" gorm:"default:none"`
	Configs      DockerProxyPermissionType `json:"configs" gorm:"default:none"`
	Containers   DockerProxyPermissionType `json:"containers" gorm:"default:none"`
	Distribution DockerProxyPermissionType `json:"distribution" gorm:"default:none"`
	Exec         DockerProxyPermissionType `json:"exec" gorm:"default:none"`
	Grpc         DockerProxyPermissionType `json:"grpc" gorm:"default:none"`
	Images       DockerProxyPermissionType `json:"images" gorm:"default:none"`
	Networks     DockerProxyPermissionType `json:"networks" gorm:"default:none"`
	Nodes        DockerProxyPermissionType `json:"nodes" gorm:"default:none"`
	Plugins      DockerProxyPermissionType `json:"plugins" gorm:"default:none"`
	Services     DockerProxyPermissionType `json:"services" gorm:"default:none"`
	Session      DockerProxyPermissionType `json:"session" gorm:"default:none"`
	Swarm        DockerProxyPermissionType `json:"swarm" gorm:"default:none"`
	System       DockerProxyPermissionType `json:"system" gorm:"default:none"`
	Tasks        DockerProxyPermissionType `json:"tasks" gorm:"default:none"`
	Volumes      DockerProxyPermissionType `json:"volumes" gorm:"default:none"`
}

type DockerProxyPermissionType

type DockerProxyPermissionType string
const (
	// DockerProxyNoPermission no request will be allowed
	DockerProxyNoPermission DockerProxyPermissionType = "none"
	// DockerProxyReadPermission only [GET, HEAD] requests will be allowed
	DockerProxyReadPermission DockerProxyPermissionType = "read"
	// DockerProxyReadWritePermission all requests will be allowed [GET, HEAD, POST, PUT, DELETE, OPTIONS]
	DockerProxyReadWritePermission DockerProxyPermissionType = "read_write"
)

type Manager

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

func New

func New(ctx context.Context, conn net.Conn) (*Manager, error)

New creates a new container manager

func NewLocalClient

func NewLocalClient(ctx context.Context) (*Manager, error)

NewLocalClient creates a new container manager with a local client

func (Manager) BackupVolume

func (m Manager) BackupVolume(volumeName string, backupFilePath string, host string, port int, user string, privateKey string) error

BackupVolume : Backup a volume to a file

func (Manager) CIDRNetwork

func (m Manager) CIDRNetwork(name string) (string, error)

CIDRNetwork Fetch CIDR of a network

func (Manager) Close

func (m Manager) Close() error

Close closes the manager

func (Manager) CreateCIFSVolume

func (m Manager) CreateCIFSVolume(name string, cifsHost string, cifsShare string, username string, password string, fileMode string, dirMode string, uid int, gid int) error

CreateCIFSVolume : Create a new CIFS volume, return id of the volume

func (Manager) CreateConfig

func (m Manager) CreateConfig(content string, applicationId string) (string, error)

CreateConfig creates a new config and returns the config id

func (Manager) CreateDockerProxy

func (m Manager) CreateDockerProxy(serviceName string, placementConstraints []string, config DockerProxyConfig, networkName string) error

func (Manager) CreateImageWithContext

func (m Manager) CreateImageWithContext(ctx context.Context, dockerfile string, buildargs map[string]string, sourceCodeDirectory string, codePath string, imagename string) (*bufio.Scanner, error)

CreateImageWithContext builds a Docker image from a Dockerfile and returns a scanner to read the build logs. It takes the Dockerfile content as a string, a map of build arguments, the path to the code directory, and the name of the image to be built. It returns a scanner to read the build logs and an error if any. It takes a context.Context as an additional argument.

func (Manager) CreateLocalVolume

func (m Manager) CreateLocalVolume(name string) error

CreateLocalVolume : Create a new volume, return id of the volume

func (Manager) CreateNFSVolume

func (m Manager) CreateNFSVolume(name string, nfsServer string, nfsPath string, version int) error

CreateNFSVolume : Create a new NFS volume, return id of the volume

func (Manager) CreateNetwork

func (m Manager) CreateNetwork(name string) error

CreateNetwork Create a new network with the given name It will create an overlay network with the given name and allow to attach containers to it

func (Manager) CreateService

func (m Manager) CreateService(service Service, username string, password string, queryRegistry bool) error

func (Manager) DemoteToWorker

func (m Manager) DemoteToWorker(hostname string) error

DemoteToWorker demotes a node to worker

func (Manager) ExistsImage

func (m Manager) ExistsImage(image string) bool

ExistsImage checks if a Docker image exists locally.

func (Manager) ExistsNetwork

func (m Manager) ExistsNetwork(name string) bool

ExistsNetwork Check if a network exists

func (Manager) ExistsVolume

func (m Manager) ExistsVolume(id string) bool

ExistsVolume : Check if volume exists

func (Manager) FetchConfig

func (m Manager) FetchConfig(configId string) (string, error)

FetchConfig fetches the config with the given id

func (Manager) FetchDockerConfigId

func (m Manager) FetchDockerConfigId(configId string) (string, error)

FetchDockerConfigId fetches the docker config id of a config

func (Manager) FetchNodeStatus

func (m Manager) FetchNodeStatus(hostname string) (string, error)

FetchNodeStatus fetches the status of a node

func (Manager) FetchPublishedHostPorts

func (m Manager) FetchPublishedHostPorts(service_name string) ([]int, error)

Fetch published host ports of a service

func (Manager) FetchPublishedPortRules

func (m Manager) FetchPublishedPortRules(service_name string) ([]swarm.PortConfig, error)

FetchPublishedPortRules Fetch published port rules of a service

func (Manager) FetchVolumes

func (m Manager) FetchVolumes() ([]string, error)

FetchVolumes Fetch all volumes

func (Manager) GatewayNetwork

func (m Manager) GatewayNetwork(name string) (string, error)

GatewayNetwork Fetch gateway of a network

func (Manager) GenerateManagerJoinToken

func (m Manager) GenerateManagerJoinToken() (token string, err error)

GenerateManagerJoinToken generates a manager join token

func (Manager) GenerateWorkerJoinToken

func (m Manager) GenerateWorkerJoinToken() (token string, err error)

GenerateWorkerJoinToken generates a worker join token

func (Manager) GetService

func (m Manager) GetService(serviceName string) (Service, error)

func (Manager) InitializeAsManager

func (m Manager) InitializeAsManager(advertiseIP string) error

InitializeAsManager initializes the swarm as a manager

func (Manager) IsContainerRunning

func (m Manager) IsContainerRunning(containerName string) (bool, error)

IsContainerRunning checks if a container is running

func (Manager) JoinSwarm

func (m Manager) JoinSwarm(address string, token string, advertiseIP string) error

JoinSwarm joins the swarm

func (Manager) LeaveSwarm

func (m Manager) LeaveSwarm() error

LeaveSwarm leaves the swarm

func (Manager) ListNodes

func (m Manager) ListNodes() (*map[string]swarm.Node, error)

ListNodes lists all nodes

func (Manager) LogsService

func (m Manager) LogsService(serviceName string, sinceMinutes int) (io.ReadCloser, error)

LogsService Get service logs

func (Manager) MarkNodeAsActive

func (m Manager) MarkNodeAsActive(hostname string) error

MarkNodeAsActive marks a node as active

func (Manager) MarkNodeAsDrained

func (m Manager) MarkNodeAsDrained(hostname string) error

MarkNodeAsDrained marks a node as drained

func (Manager) NoOfRunningTasks

func (m Manager) NoOfRunningTasks(serviceName string) (int, error)

func (Manager) PromoteToManager

func (m Manager) PromoteToManager(hostname string) error

PromoteToManager promotes a node to manager

func (Manager) PruneConfig

func (m Manager) PruneConfig(applicationId string)

PruneConfig removes all the configs with the given applicationId. It will remove all the possible configs It will not raise any error if failed to remove a config

func (Manager) PruneContainers

func (m Manager) PruneContainers() error

PruneContainers prunes all containers

func (Manager) PruneImages

func (m Manager) PruneImages() error

PruneImages removes all unused Docker images from the local registry.

func (Manager) PullImage

func (m Manager) PullImage(imageTag string, username string, password string) (*bufio.Scanner, error)

PullImage pulls a Docker image from a remote registry and returns a scanner to read the pull logs.

func (Manager) PushImage

func (m Manager) PushImage(ctx context.Context, imageTag string, username string, password string) (*bufio.Scanner, error)

PushImage pushes a Docker image to a remote registry and returns a scanner to read the push logs.

func (Manager) RandomServiceContainerID

func (m Manager) RandomServiceContainerID(serviceName string) (string, error)

RandomServiceContainerID returns a random container id of a service

func (Manager) RemoveDockerProxy

func (m Manager) RemoveDockerProxy(serviceName string)

func (Manager) RemoveImage

func (m Manager) RemoveImage(imageTag string) error

RemoveImage removes a Docker image from the local registry.

func (Manager) RemoveNetwork

func (m Manager) RemoveNetwork(name string) error

RemoveNetwork Delete a network

func (Manager) RemoveNode

func (m Manager) RemoveNode(hostname string) error

RemoveNode removes a node from the swarm

func (Manager) RemoveService

func (m Manager) RemoveService(serviceName string) error

func (Manager) RemoveServiceContainers

func (m Manager) RemoveServiceContainers(serviceName string) error

RemoveServiceContainers removes all containers for a service in a node

func (Manager) RemoveVolume

func (m Manager) RemoveVolume(id string) error

RemoveVolume : Remove a volume by id

func (Manager) RestartService

func (m Manager) RestartService(serviceName string) error

func (Manager) RestoreVolume

func (m Manager) RestoreVolume(volumeName string, backupFilePath string, host string, port int, user string, privateKey string) error

RestoreVolume : Restore a volume from a backup file

func (Manager) RollbackService

func (m Manager) RollbackService(serviceName string) error

func (Manager) RunCommandInServiceContainers

func (m Manager) RunCommandInServiceContainers(serviceName string, command []string) error

RunCommandInServiceContainers runs a command in all containers for a service

func (Manager) ServiceRunningServers

func (m Manager) ServiceRunningServers(serviceName string) ([]string, error)

ServiceRunningServers Fetch the servers where a service is running

func (Manager) SetServiceReplicaCount

func (m Manager) SetServiceReplicaCount(serviceName string, replicas int) error

func (Manager) SizeVolume

func (m Manager) SizeVolume(volumeName string, host string, port int, user string, privateKey string) (sizeMB float64, err error)

SizeVolume : Return a file which will contain the size of the volume in bytes

func (Manager) UpdatePublishedHostPorts

func (m Manager) UpdatePublishedHostPorts(service_name string, ports []swarm.PortConfig) error

update published host ports of a service

func (Manager) UpdateService

func (m Manager) UpdateService(service Service, username string, password string, queryRegistry bool) error

type Resource

type Resource struct {
	MemoryMB int `json:"memory_mb,omitempty"`
}

type Service

type Service struct {
	Name                 string            `json:"name"`
	Image                string            `json:"image"`
	Command              []string          `json:"command,omitempty"`
	Env                  map[string]string `json:"env,omitempty"`
	Capabilities         []string          `json:"capabilities,omitempty"`
	Sysctls              map[string]string `json:"sysctl,omitempty"`
	ConfigMounts         []ConfigMount     `json:"configmounts,omitempty"`
	VolumeMounts         []VolumeMount     `json:"volumemounts,omitempty"`
	VolumeBinds          []VolumeBind      `json:"volumebinds,omitempty"`
	Networks             []string          `json:"networks,omitempty"`
	DeploymentMode       DeploymentMode    `json:"deploymentmode"`
	Replicas             uint64            `json:"replicas"`
	PlacementConstraints []string          `json:"placementconstraints,omitempty"`
	ReservedResource     Resource          `json:"reserved_resource,omitempty"`
	ResourceLimit        Resource          `json:"resource_limit,omitempty"`
	CustomHealthCheck    CustomHealthCheck `json:"custom_health_check,omitempty"`
}

type ServiceRealtimeInfo

type ServiceRealtimeInfo struct {
	Name              string `json:"name"`
	DesiredReplicas   int    `json:"desiredreplicas"`
	RunningReplicas   int    `json:"runningreplicas"`
	ReplicatedService bool   `json:"replicatedservice"`
}

type ServiceTaskPlacementInfo

type ServiceTaskPlacementInfo struct {
	NodeID          string `json:"nodeid"`
	NodeName        string `json:"nodename"`
	IsManagerNode   bool   `json:"ismanagernode"`
	RunningReplicas int    `json:"runningreplicas"`
}

type VolumeBind

type VolumeBind struct {
	Source string `json:"source"`
	Target string `json:"target"`
}

type VolumeMount

type VolumeMount struct {
	Source   string `json:"source"`
	Target   string `json:"target"`
	ReadOnly bool   `json:"readonly"`
}

Jump to

Keyboard shortcuts

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