Documentation
¶
Index ¶
- Constants
- Variables
- type Builder
- type Container
- func (c *Container) Attach(e Entity) error
- func (base Container) DefaultMeta() kube.ObjectMeta
- func (c *Container) Deployment() (*deploy.Deployment, error)
- func (c *Container) Images() []*image.Image
- func (base Container) Objects() []deploy.KubeObject
- func (base Container) Source() string
- func (base Container) Type() Type
- type Entity
- type Image
- type Pod
- func NewDefaultPod(meta kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*Pod, error)
- func NewPod(kubePod *kube.Pod, defaults kube.ObjectMeta, source string, ...) (*Pod, error)
- func NewPodFromPodSpec(meta kube.ObjectMeta, podSpec kube.PodSpec, defaults kube.ObjectMeta, ...) (*Pod, error)
- type ReplicationController
- func (c *ReplicationController) Attach(e Entity) error
- func (base ReplicationController) DefaultMeta() kube.ObjectMeta
- func (c *ReplicationController) Deployment() (*deploy.Deployment, error)
- func (c *ReplicationController) Images() (images []*image.Image)
- func (base ReplicationController) Objects() []deploy.KubeObject
- func (base ReplicationController) Source() string
- func (base ReplicationController) Type() Type
- type Type
Constants ¶
const NoImageErrStr = "spec.containers[0].image: Required value"
NoImageErrStr is the error message returned by k8s when the image field has been left blank.
Variables ¶
var ( // ErrorNilObject is when a deploy.KubeObject is null. ErrorNilObject = errors.New("an object was nil, this is not allowed") // ErrorInvalidAttachType is when the Type of the attached object in invalid. ErrorInvalidAttachType = errors.New("the entity to be attached is of an unknown type") // ErrorBadAttachOrder is when an attachment is attempted in an improper order ErrorBadAttachOrder = errors.New("entities cannot attach to entities of a lower type") // ErrorMaxAttached is when an Entity cannot support more Entities attaching ErrorMaxAttached = errors.New("no more entities can be attached") // ErrorNilEntity is when an entity is nil ErrorNilEntity = errors.New("entities cannot be nil") )
var ( // ErrorEmptyImageString is when an Image is created with an empty name ErrorEmptyImageString = errors.New("image.Image's String was empty") // ErrorNilImage is when an Image is created with a nil *image.Image. ErrorNilImage = errors.New("*image.Image cannot be nil") )
var DefaultContainer = kube.Container{ ImagePullPolicy: kube.PullAlways, }
DefaultContainer is the default for all new Containers
var DefaultPodSpec = kube.PodSpec{ RestartPolicy: kube.RestartPolicyAlways, DNSPolicy: kube.DNSDefault, }
DefaultPodSpec is the default for newly created Pods
var ( // ErrMissingContainer is where the Pod is being used in a context where it must be valid and doesn't have a Container. ErrMissingContainer = errors.New("pod must have containers to be deployed") )
var ( // ErrMissingImage is where the Container is being used in a context where it must be valid and doesn't have an Image. ErrMissingImage = errors.New("container must have an image to be deployed") )
var ( // ErrMissingPod is when the RC is being used in a context where it must be valid and doesn't have a Pod. ErrMissingPod = errors.New("replication controller must have pod to be deployed") )
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder interface { // Build returns an Entity based on the implementations internal logic, Errors are returned if state is invalid. Build() (Entity, error) }
Builder is used by input sources that create Entities.
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container represents kube.Container in the Redspread hierarchy.
func NewContainer ¶
func NewContainer(container kube.Container, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*Container, error)
NewContainer creates a new Entity for the provided kube.Container. Container must be valid.
func (Container) DefaultMeta ¶
func (base Container) DefaultMeta() kube.ObjectMeta
DefaultMeta returns the ObjectMeta that the Entity was created with
func (*Container) Deployment ¶
func (c *Container) Deployment() (*deploy.Deployment, error)
Deployment is created with Container attached to Pod. The pod is named after the kube.Container.
func (Container) Objects ¶
func (base Container) Objects() []deploy.KubeObject
Objects returns slice of objects attached to Entity
type Entity ¶
type Entity interface { deploy.Deployable Type() Type Objects() []deploy.KubeObject Source() string Attach(Entity) error DefaultMeta() kube.ObjectMeta // contains filtered or unexported methods }
Entity is the fundamental building block of `spread`'s internal representation of state. Entities exist for both constructs that already exist in Kubernetes (RC, Pod, Container) as well as ones that have been added (image).
An entity must at all times be capable of producing a Deployment.
Entities are attached in the order: Image -> Container -> Pod -> RC. Attachments out of order are not allowed.
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image represents a Docker image in the Redspread hierarchy. It wraps image.Image.
func NewImage ¶
func NewImage(image *image.Image, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*Image, error)
NewImage creates a new Entity for the image.Image it's provided with.
func (Image) DefaultMeta ¶
func (base Image) DefaultMeta() kube.ObjectMeta
DefaultMeta returns the ObjectMeta that the Entity was created with
func (*Image) Deployment ¶
func (c *Image) Deployment() (*deploy.Deployment, error)
Deployment is created with image attached to default pod. The GenerateName of the Pod is the name of the image.
func (Image) Objects ¶
func (base Image) Objects() []deploy.KubeObject
Objects returns slice of objects attached to Entity
type Pod ¶
type Pod struct {
// contains filtered or unexported fields
}
Pod represents kube.Pod in the Redspread hierarchy.
func NewDefaultPod ¶
func NewDefaultPod(meta kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*Pod, error)
NewDefaultPod creates a Pod using spreads defaults without any containers attached. Containers must be attached before this Pod can be deployed.
func NewPod ¶
func NewPod(kubePod *kube.Pod, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*Pod, error)
NewPod creates a Entity for a corresponding *kube.Pod. Pod must be valid.
func NewPodFromPodSpec ¶
func NewPodFromPodSpec(meta kube.ObjectMeta, podSpec kube.PodSpec, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*Pod, error)
NewPodFromPodSpec creates a new Pod using ObjectMeta and a PodSpec.
func (Pod) DefaultMeta ¶
func (base Pod) DefaultMeta() kube.ObjectMeta
DefaultMeta returns the ObjectMeta that the Entity was created with
func (*Pod) Deployment ¶
func (c *Pod) Deployment() (*deploy.Deployment, error)
Deployment is created containing Pod with attached Containers.
func (Pod) Objects ¶
func (base Pod) Objects() []deploy.KubeObject
Objects returns slice of objects attached to Entity
type ReplicationController ¶
type ReplicationController struct {
// contains filtered or unexported fields
}
ReplicationController represents kube.ReplicationController in the Redspread hierarchy.
func NewReplicationController ¶
func NewReplicationController(kubeRC *kube.ReplicationController, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*ReplicationController, error)
NewReplicationController creates a new Entity for the provided kube.ReplicationController. Must be valid.
func (*ReplicationController) Attach ¶
func (c *ReplicationController) Attach(e Entity) error
Attach allows Pods, Containers, and Images to be attached.
func (ReplicationController) DefaultMeta ¶
func (base ReplicationController) DefaultMeta() kube.ObjectMeta
DefaultMeta returns the ObjectMeta that the Entity was created with
func (*ReplicationController) Deployment ¶
func (c *ReplicationController) Deployment() (*deploy.Deployment, error)
Deployment is created for RC attached with it's Pod.
func (*ReplicationController) Images ¶
func (c *ReplicationController) Images() (images []*image.Image)
Images contained by ReplicationController's Pods.
func (ReplicationController) Objects ¶
func (base ReplicationController) Objects() []deploy.KubeObject
Objects returns slice of objects attached to Entity
type Type ¶
type Type int
Type identifies the entity's type.
const ( // EntityApplication is for Application (top of tree) EntityApplication Type = iota // EntityReplicationController is for ReplicationController EntityReplicationController // EntityPod is for Pod EntityPod // EntityContainer is for Container EntityContainer // EntityImage is for Image EntityImage )