Documentation ¶
Index ¶
- func CreateJobsCollection(deployment string) error
- func CreateSecretsCollection(deployment string) error
- func Delete(deployment string) error
- func DeleteConfig(deployment string) error
- func DeleteJobsCollection(deployment string) error
- func DeleteSecret(deployment, key string) error
- func DeleteSecretsCollection(deployment string) error
- func Exist(deployment string) bool
- func GetJobByID(deployment, id string, daysAgo uint) (job.Job, error)
- func GetJobs(daysAgo uint) ([]job.Job, error)
- func GetJobsByDeployment(deployment string, daysAgo uint) ([]job.Job, error)
- func RestartContainers(deployment string) error
- func RetriableContainersHealthCheck(containers []KraneContainer, retries int) error
- func Run(deployment string) error
- func SaveConfig(config Config) error
- func StartContainers(deployment string) error
- func StopContainers(deployment string) error
- func SubscribeToContainerLogs(client *websocket.Conn, containerID string)
- func SubscribeToDeploymentEvents(client *websocket.Conn, deployment string)
- func SubscribeToDeploymentLogs(client *websocket.Conn, deployment string)
- func UnSubscribeFromDeploymentEvents(client *websocket.Conn, deployment string)
- type Config
- func (config Config) ApplyProxyLabels()
- func (config Config) DockerConfig() docker.DockerConfig
- func (config Config) DockerEnvs() []string
- func (config Config) DockerLabels() map[string]string
- func (config Config) DockerPortSet() nat.PortSet
- func (config Config) DockerPorts() nat.PortMap
- func (config Config) DockerVolumeMount() []mount.Mount
- func (config Config) DockerVolumeSet() map[string]struct{}
- func (config Config) Empty() bool
- func (config *Config) ResolveRegistryCredentials() error
- func (config Config) Serialize() ([]byte, error)
- type ContainerState
- type ContainerStatus
- type Deployment
- type Event
- type EventEmitter
- type JobType
- type KraneContainer
- type Phase
- type Port
- type PortProtocol
- type Registry
- type Secret
- type Volume
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateJobsCollection ¶
CreateCollection create the job collection for a deployment
func CreateSecretsCollection ¶
CreateSecretsCollection creates secrets collection for a deployment
func Delete ¶
Delete removes a deployments container resources and configuration. Note: This will also remove any existing collections created for the deployment (Secrets, Jobs, Config etc...)
func DeleteConfig ¶
DeleteSecret removes a deployment configuration from the db
func DeleteJobsCollection ¶
DeleteCollection deletes the job collection for a deployment
func DeleteSecret ¶
DeleteSecret deletes a deployment secret
func DeleteSecretsCollection ¶
DeleteCollection deletes secrets collection for a deployment
func GetJobByID ¶
GetJobByID returns a job by id
func GetJobsByDeployment ¶
GetJobs returns all jobs for a deployment within a time range
func RestartContainers ¶
RestartContainers will re-create container resources for a deployment Note: this almost the same call as 'Run' since they both re-create container resources based on the current configuration
func RetriableContainersHealthCheck ¶
func RetriableContainersHealthCheck(containers []KraneContainer, retries int) error
RetriableContainersHealthCheck returns an error if a container is considered unhealthy
func Run ¶
Run a deployment runs the current configuration for a deployment creating or re-creating container resources
func SaveConfig ¶
SaveConfig a deployment configuration into the db
func StartContainers ¶
StartContainers starts current existing containers (if any) for a deployment Note: this does not re-create container resources, only start existing ones
func StopContainers ¶
StopContainers stops current existing containers (if any) for a deployment Note: this does not re-create container resources, only stop existing ones
func SubscribeToContainerLogs ¶
SubscribeToContainerLogs streams container logs to a websocket client
func SubscribeToDeploymentEvents ¶
SubscribeToDeploymentEvents allows clients to subscribes to a particular deployments events
func SubscribeToDeploymentLogs ¶
SubscribeToDeploymentLogs streams deployment logs to a websocket client
func UnSubscribeFromDeploymentEvents ¶
UnSubscribeFromDeploymentEvents unsubscribes a client from deployment events
Types ¶
type Config ¶
type Config struct { Name string `json:"name" binding:"required"` // deployment name Image string `json:"image" binding:"required"` // container image Registry Registry `json:"registry"` // container registry credentials / auth Tag string `json:"tag"` // container image tag Alias []string `json:"alias"` // custom domain aliases (my-app.example.com or my-app.localhost) Env map[string]string `json:"env"` // deployment environment variables Secrets map[string]string `json:"secrets"` // deployment secrets resolved as environment variables Labels map[string]string `json:"labels"` // container labels Ports map[string]string `json:"ports"` // container ports to expose from the container to the host TargetPort string `json:"target_port"` // the target port to load-balance request through Volumes map[string]string `json:"volumes"` // container volumes Command string `json:"command"` // container start command Entrypoint string `json:"entrypoint"` // container entrypoint Scale int `json:"scale"` // number of containers to create for the deployment Secure bool `json:"secure"` // enable/disable secure communication over HTTPS/TLS w/ auto generated certs Internal bool `json:"internal"` // whether a deployment is internal (ie. krane-proxy) RateLimit uint `json:"rate_limit"` // requests per second for a given deployment (default 0, which means no rate limit) }
Config represents a deployment configuration
func DeSerializeConfig ¶
DeSerialize returns a config from bytes
func GetAllDeploymentConfigs ¶
GetAllDeploymentConfigs returns a list of all deployment configurations
func GetDeploymentConfig ¶
GetDeploymentConfig returns a deployments configuration
func (Config) ApplyProxyLabels ¶
func (config Config) ApplyProxyLabels()
ApplyProxyLabels applies network labels to a deployment config
func (Config) DockerConfig ¶
func (config Config) DockerConfig() docker.DockerConfig
DockerConfig returns the docker configuration for creating a container
func (Config) DockerEnvs ¶
DockerEnvs returns a list of formatted Docker environment variables
func (Config) DockerLabels ¶
DockerLabels returns a map of Docker labels that are applied to Krane managed containers
func (Config) DockerPortSet ¶
DockerPortSet returns Docker formatted port set
func (Config) DockerPorts ¶
DockerPorts returns Docker formatted port map
func (Config) DockerVolumeMount ¶
DockerVolumeMount returns a list of formatted Docker volume mounts
func (Config) DockerVolumeSet ¶
DockerVolumeSet returns a set of Docker formatted volumes
func (*Config) ResolveRegistryCredentials ¶
type ContainerState ¶
type ContainerState struct { Status string `json:"status"` // created,started,running ... Running bool `json:"running"` Paused bool `json:"paused"` Restarting bool `json:"restarting"` OOMKilled bool `json:"oom_killed"` Dead bool `json:"dead"` Pid int `json:"pid"` ExitCode int `json:"exit_code"` Error string `json:"error"` StartedAt string `json:"started_at"` FinishedAt string `json:"finished_at"` Health *types.Health `json:",omitempty"` }
ContainerState represents the state of a Krane container
type ContainerStatus ¶
type ContainerStatus string
const ( ContainerRunning ContainerStatus = "running" ContainerStarted ContainerStatus = "started" ContainerCreated ContainerStatus = "created" )
type Deployment ¶
type Deployment struct { Config Config `json:"config"` Containers []KraneContainer `json:"containers"` Jobs []job.Job `json:"jobs"` }
Deployment represent a Krane deployment and its configuration, current container resources, and recent job history
func GetAllDeployments ¶
func GetAllDeployments() ([]Deployment, error)
GetAllDeployments returns a list of all deployments
func GetDeployment ¶
func GetDeployment(deployment string) (Deployment, error)
GetDeployment returns a single deployment
type EventEmitter ¶
type KraneContainer ¶
type KraneContainer struct { ID string `json:"id"` Deployment string `json:"deployment"` Name string `json:"name"` NetworkID string `json:"network_id"` Image string `json:"image"` ImageID string `json:"image_id"` CreatedAt int64 `json:"created_at"` Labels map[string]string `json:"labels"` State ContainerState `json:"state"` Ports []Port `json:"ports"` Volumes []Volume `json:"volumes"` Command []string `json:"command"` Entrypoint []string `json:"entrypoint"` }
KraneContainer represents a Krane managed container
func ContainerCreate ¶
func ContainerCreate(config Config) (KraneContainer, error)
ContainerCreate creates a docker container from a deployment config
func GetContainers ¶
func GetContainers() ([]KraneContainer, error)
GetContainers get all containers managed by Krane
func GetContainersByDeployment ¶
func GetContainersByDeployment(deployment string) ([]KraneContainer, error)
GetContainersByDeployment get containers filtered by deployment
func (KraneContainer) Remove ¶
func (c KraneContainer) Remove() error
Remove removes a Krane managed Docker container
func (KraneContainer) Running ¶
func (c KraneContainer) Running() (bool, error)
Running returns whether a container is in a running state
func (KraneContainer) Start ¶
func (c KraneContainer) Start() error
Start starts a Krane managed Docker Container
func (KraneContainer) Stop ¶
func (c KraneContainer) Stop() error
Stop stops a Krane managed Docker Container
type Phase ¶
type Phase string
Phases represents a particular step a deployment could be going through during its deployment cycle. They are attached to jobs allowing clients to react or filter for particular phases of the deployments cycle.
const ( SetupPhase Phase = "DEPLOYMENT_SETUP" HealthCheckPhase Phase = "DEPLOYMENT_HEALTHCHECK" TeardownPhase Phase = "DEPLOYMENT_TEARDOWN" DonePhase Phase = "DEPLOYMENT_DONE" PullImagePhase Phase = "PULL_IMAGE" CreateContainerPhase Phase = "CREATE_CONTAINER" StartContainerPhase Phase = "START_CONTAINER" )
type Secret ¶
type Secret struct { Deployment string `json:"deployment"` Key string `json:"key"` Value string `json:"value"` Alias string `json:"alias"` }
func AddSecret ¶
AddSecret adds a secret to a deployment. Secrets are injected to the container during the container 'run' step. When a secret is created, an alias is returned and can be used to reference the secret in the `deployment.json` ie. SECRET_TOKEN=@secret-token (@secret-token was returned and how you reference the value for SECRET_TOKEN)
func GetAllSecrets ¶
GetAllSecrets returns all secrets for a deployment
func GetAllSecretsRedacted ¶
GetAllSecretsRedacted returns all deployment secrets with <redacted> a their value