Documentation ¶
Index ¶
- Constants
- Variables
- func CreateBaseImage(healthCheckerPath string) string
- func CreateCustomImage(imageName, baseImage, filename, cmd string) *string
- func CreateNamedVolume(ctx context.Context, conf ...*VolumeConfig) ([]*specgen.NamedVolume, error)
- func LimitResources(cores float64, mems float64) (*specs.LinuxCPU, *specs.LinuxResources)
- func NewConnection(ctx context.Context, ipcName string) (context.Context, error)
- func NewConnectionLinux(ctx context.Context) (context.Context, error)
- func Reset() error
- func Save() error
- func SetCpuSet() *specs.LinuxResources
- func SetHealthChecker(inCmd, interval string, retries uint, timeout, startPeriod string) (*manifest.Schema2HealthConfig, error)
- type ContainerSpec
- type ContainerStatus
- type CreateContainerResult
- func (Res *CreateContainerResult) HealthCheck(ctx context.Context, interval string)
- func (Res *CreateContainerResult) Kill(ctx context.Context, options ...any) error
- func (Res *CreateContainerResult) ReStart(ctx context.Context) error
- func (Res *CreateContainerResult) Run(ctx context.Context, interval string) ContainerStatus
- func (Res *CreateContainerResult) Start(ctx context.Context) error
- func (Res *CreateContainerResult) Stop(ctx context.Context, options ...any) error
- type CreatePodResult
- type HealthCheck
- type ListCreated
- func (lc *ListCreated) AddContainerId(containerId string) *ListCreated
- func (lc *ListCreated) AddContainerInPod(podId string, containerIds ...string) *ListCreated
- func (lc *ListCreated) AddImagesId(imgId string) *ListCreated
- func (lc *ListCreated) AddPodId(podId string) *ListCreated
- func (lc *ListCreated) AddVolumeName(volumeName string) *ListCreated
- func (lc *ListCreated) RemoveContainerId(containerId string)
- func (lc *ListCreated) Save()
- type PodInfo
- type PodSpec
- type PodSpecGen
- type SpecGen
- type VolumeConfig
Constants ¶
const ( Min int = 1 Max int = 100 )
channel buffer size
Variables ¶
var Log = logrus.New()
Functions ¶
func CreateBaseImage ¶
CreateBaseImage healthcheck 를 넣는다.
func CreateCustomImage ¶
CreateCustomImage alpine 으로 만들어주고 명령어를 넣어줘서 image 를 만들어 주는 function. 테스트는 별도의 프로젝트 열어서 해야함. 1. bash, nano 와 업데이트를 해줌. 2. /app 폴더를 WorkDir 로 만들어줌. 3. /app/healthcheck 폴더를 만들어줌. 4. /app/healthcheck 여기에 executor.sh 를 집어 넣어줌. TODO 데이터 넣는 것도 구현되어야 함. BaseImage 를 만들자.
func CreateNamedVolume ¶
func CreateNamedVolume(ctx context.Context, conf ...*VolumeConfig) ([]*specgen.NamedVolume, error)
func LimitResources ¶
func NewConnection ¶
func SetHealthChecker ¶
Types ¶
type ContainerSpec ¶
type ContainerSpec struct {
Spec *specgen.SpecGenerator
}
func (*ContainerSpec) SetHealthChecker ¶
func (c *ContainerSpec) SetHealthChecker(inCmd, interval string, retries uint, timeout, startPeriod string) *ContainerSpec
SetHealthChecker HealthChecker 를 등록한다.
func (*ContainerSpec) SetImage ¶
func (c *ContainerSpec) SetImage(imgName string) *ContainerSpec
SetImage 해당 이미지를 spec 에 등록한다.
func (*ContainerSpec) SetOther ¶
func (c *ContainerSpec) SetOther(f func(spec SpecGen) SpecGen) *ContainerSpec
SetOther Spec 옵션을 적용하도록 돕는다.
type ContainerStatus ¶
type ContainerStatus int
const ( Created ContainerStatus = iota //0 Running // 1 Exited // 2 ExitedErr // 3 Healthy // 4 Unhealthy // 5 Dead // 6 Paused // 7 UnKnown // 8 None // 9 )
type CreateContainerResult ¶
type CreateContainerResult struct { Name string ID string Warnings []string Status ContainerStatus // contains filtered or unexported fields }
func CreateContainer ¶
func CreateContainer(ctx context.Context, conSpec *ContainerSpec) *CreateContainerResult
CreateContainer
func (*CreateContainerResult) HealthCheck ¶
func (Res *CreateContainerResult) HealthCheck(ctx context.Context, interval string)
HealthCheck 테스트 필요
func (*CreateContainerResult) Kill ¶
func (Res *CreateContainerResult) Kill(ctx context.Context, options ...any) error
Kill
func (*CreateContainerResult) ReStart ¶
func (Res *CreateContainerResult) ReStart(ctx context.Context) error
ReStart 중복되는 것 같긴하다. TODO 수정해줘야 한다. ReStart
func (*CreateContainerResult) Run ¶
func (Res *CreateContainerResult) Run(ctx context.Context, interval string) ContainerStatus
Run container 의 Start 와 함께 HealthCheck 도 함께 하도록 한다.
func (*CreateContainerResult) Start ¶
func (Res *CreateContainerResult) Start(ctx context.Context) error
Start startOptions 는 default 값을 사용한다. https://docs.podman.io/en/latest/_static/api.html?version=v4.1#operation/ContainerStartLibpod
func (*CreateContainerResult) Stop ¶
func (Res *CreateContainerResult) Stop(ctx context.Context, options ...any) error
Stop https://docs.podman.io/en/latest/_static/api.html?version=v4.1#operation/ContainerStopLibpod default 값은 timeout 은 10 으로 세팅되어 있고, ignore 는 false 이다. ignore 는 만약 stop 된 컨테이너를 stop 되어 있을 때 stop 하는 경우 true 하면 에러 무시, false 로 하면 에러 리턴 timeout 은 몇 후에 컨테어너를 kill 할지 정한다.
type CreatePodResult ¶
type CreatePodResult struct { ErrorMessage error Name string Hostname string ID string Success bool }
func CreatePod ¶
func CreatePod(ctx context.Context, spec *entities.PodSpec) *CreatePodResult
CreatePod Pod 를 생성한다. 기존 Pod 가 존재하고 있으면 실패를 리턴한다.
func (*CreatePodResult) GetPodId ¶
func (podRes *CreatePodResult) GetPodId() string
type HealthCheck ¶
type HealthCheck struct { InCmd string Interval string Retries uint Timeout string StartPeriod string }
func CreateHealthCheck ¶
func CreateHealthCheck(inCmd, interval string, retries uint, timeout, startPeriod string) *HealthCheck
func (*HealthCheck) SetHealthChecker ¶
func (h *HealthCheck) SetHealthChecker() (*manifest.Schema2HealthConfig, error)
type ListCreated ¶
type ListCreated struct { ImageIds []string `yaml:"Images,flow"` ContainerIds []string `yaml:"Containers,flow"` Pods []*PodInfo `yaml:"Pods,flow"` VolumeNames []string `yaml:"Volumes,flow"` // contains filtered or unexported fields }
var (
Basket *ListCreated
)
func MustFirstCall ¶
func MustFirstCall() (*ListCreated, error)
func (*ListCreated) AddContainerId ¶
func (lc *ListCreated) AddContainerId(containerId string) *ListCreated
func (*ListCreated) AddContainerInPod ¶
func (lc *ListCreated) AddContainerInPod(podId string, containerIds ...string) *ListCreated
func (*ListCreated) AddImagesId ¶
func (lc *ListCreated) AddImagesId(imgId string) *ListCreated
func (*ListCreated) AddPodId ¶
func (lc *ListCreated) AddPodId(podId string) *ListCreated
func (*ListCreated) AddVolumeName ¶
func (lc *ListCreated) AddVolumeName(volumeName string) *ListCreated
func (*ListCreated) RemoveContainerId ¶
func (lc *ListCreated) RemoveContainerId(containerId string)
RemoveContainerId 테스트 해보자.
func (*ListCreated) Save ¶
func (lc *ListCreated) Save()
Save 호출 없이 사용할 수 있도록 추후 수정하자. 종료시 호출하도록 하면 될듯하다. 결국 안지구오 app 을 닫는 경우 데이터를 보호할 목적임으로
type PodSpec ¶
type PodSpec struct {
Spec *specgen.PodSpecGenerator
}
func (*PodSpec) SetOther ¶
func (c *PodSpec) SetOther(f func(spec PodSpecGen) PodSpecGen) *PodSpec
SetOther Spec 옵션을 적용하도록 돕는다.
type PodSpecGen ¶
type PodSpecGen *specgen.PodSpecGenerator
type SpecGen ¶
type SpecGen *specgen.SpecGenerator
type VolumeConfig ¶
type VolumeConfig struct { entities.VolumeCreateOptions Dest string }