controller

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2015 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package controller contains all the controllers which taken together implement the deployment system's behavior.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeStrategy added in v0.2.1

type ChangeStrategy interface {
	GetDeployment(namespace, name string) (*kapi.ReplicationController, error)
	GenerateDeploymentConfig(namespace, name string) (*deployapi.DeploymentConfig, error)
	UpdateDeploymentConfig(namespace string, config *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error)
}

ChangeStrategy knows how to generate and update DeploymentConfigs.

type ChangeStrategyImpl added in v0.3.2

type ChangeStrategyImpl struct {
	GetDeploymentFunc            func(namespace, name string) (*kapi.ReplicationController, error)
	GenerateDeploymentConfigFunc func(namespace, name string) (*deployapi.DeploymentConfig, error)
	UpdateDeploymentConfigFunc   func(namespace string, config *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error)
}

ChangeStrategyImpl is a pluggable ChangeStrategy.

func (*ChangeStrategyImpl) GenerateDeploymentConfig added in v0.3.2

func (i *ChangeStrategyImpl) GenerateDeploymentConfig(namespace, name string) (*deployapi.DeploymentConfig, error)

func (*ChangeStrategyImpl) GetDeployment added in v0.3.2

func (i *ChangeStrategyImpl) GetDeployment(namespace, name string) (*kapi.ReplicationController, error)

func (*ChangeStrategyImpl) UpdateDeploymentConfig added in v0.3.2

func (i *ChangeStrategyImpl) UpdateDeploymentConfig(namespace string, config *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error)

type DeploymentConfigChangeController

type DeploymentConfigChangeController struct {
	ChangeStrategy       ChangeStrategy
	NextDeploymentConfig func() *deployapi.DeploymentConfig
	Codec                runtime.Codec
	// Stop is an optional channel that controls when the controller exits
	Stop <-chan struct{}
}

DeploymentConfigChangeController watches for changes to DeploymentConfigs and regenerates them only when detecting a change to the PodTemplate of a DeploymentConfig containing a ConfigChange trigger.

func (*DeploymentConfigChangeController) HandleDeploymentConfig

func (dc *DeploymentConfigChangeController) HandleDeploymentConfig(config *deployapi.DeploymentConfig) error

HandleDeploymentConfig handles the next DeploymentConfig change that happens.

func (*DeploymentConfigChangeController) Run

Run watches for config change events.

type DeploymentConfigController

type DeploymentConfigController struct {
	// DeploymentClient provides access to Deployments.
	DeploymentClient DeploymentConfigControllerDeploymentClient
	// NextDeploymentConfig blocks until the next DeploymentConfig is available.
	NextDeploymentConfig func() *deployapi.DeploymentConfig
	// Codec is used to encode DeploymentConfigs which are stored on deployments.
	Codec runtime.Codec
	// Stop is an optional channel that controls when the controller exits.
	Stop <-chan struct{}
}

DeploymentConfigController is responsible for creating a deployment when a DeploymentConfig is updated with a new LatestVersion. Any deployment created is correlated to a DeploymentConfig by setting the DeploymentConfigLabel on the deployment.

Deployments are represented by ReplicationControllers. The DeploymentConfig used to create the ReplicationController is encoded and stored in an annotation on the ReplicationController.

func (*DeploymentConfigController) HandleDeploymentConfig

func (c *DeploymentConfigController) HandleDeploymentConfig(config *deployapi.DeploymentConfig) error

HandleDeploymentConfig examines the current state of a DeploymentConfig, and creates a new deployment for the config if the following conditions are true:

  1. The config version is greater than 0
  2. No deployment exists corresponding to the config's version

If the config can't be processed, an error is returned.

func (*DeploymentConfigController) Run

func (c *DeploymentConfigController) Run()

Run processes DeploymentConfigs one at a time until the Stop channel unblocks.

type DeploymentConfigControllerDeploymentClient added in v0.3.2

type DeploymentConfigControllerDeploymentClient interface {
	GetDeployment(namespace, name string) (*kapi.ReplicationController, error)
	CreateDeployment(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error)
}

DeploymentConfigControllerDeploymentClient abstracts access to deployments.

type DeploymentConfigControllerDeploymentClientImpl added in v0.3.2

type DeploymentConfigControllerDeploymentClientImpl struct {
	GetDeploymentFunc    func(namespace, name string) (*kapi.ReplicationController, error)
	CreateDeploymentFunc func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error)
}

DeploymentConfigControllerDeploymentClientImpl is a pluggable deploymentConfigControllerDeploymentClient.

func (*DeploymentConfigControllerDeploymentClientImpl) CreateDeployment added in v0.3.2

func (*DeploymentConfigControllerDeploymentClientImpl) GetDeployment added in v0.3.2

type DeploymentContainerCreator added in v0.2.1

type DeploymentContainerCreator interface {
	CreateContainer(*deployapi.DeploymentStrategy) *kapi.Container
}

DeploymentContainerCreator knows how to create a deployment pod's container based on the deployment's strategy.

type DeploymentContainerCreatorImpl added in v0.3.2

type DeploymentContainerCreatorImpl struct {
	CreateContainerFunc func(*deployapi.DeploymentStrategy) *kapi.Container
}

DeploymentContainerCreatorImpl is a pluggable DeploymentContainerCreator.

func (*DeploymentContainerCreatorImpl) CreateContainer added in v0.3.2

type DeploymentController added in v0.2.1

type DeploymentController struct {
	// ContainerCreator makes the container for the deployment pod based on the strategy.
	ContainerCreator DeploymentContainerCreator
	// DeploymentClient provides access to deployments.
	DeploymentClient DeploymentControllerDeploymentClient
	// PodClient provides access to pods.
	PodClient DeploymentControllerPodClient
	// NextDeployment blocks until the next deployment is available.
	NextDeployment func() *kapi.ReplicationController
	// NextPod blocks until the next pod is available.
	NextPod func() *kapi.Pod
	// Environment is a set of environment which should be injected into all deployment pod
	// containers, in addition to whatever environment is specified by the ContainerCreator.
	Environment []kapi.EnvVar
	// Codec is used to decode DeploymentConfigs.
	Codec runtime.Codec
	// Stop is an optional channel that controls when the controller exits.
	Stop <-chan struct{}
}

DeploymentController performs a deployment by creating a pod which is defined by a strategy. The status of the resulting deployment will follow the status of the corresponding pod.

Deployments are represented by a ReplicationController.

func (*DeploymentController) HandleDeployment added in v0.2.1

func (dc *DeploymentController) HandleDeployment(deployment *kapi.ReplicationController) error

HandleDeployment processes a new deployment and creates a new Pod which implements the specific deployment behavior. The deployment and pod are correlated with annotations. If the pod was successfully created, the deployment's status is transitioned to pending.

func (*DeploymentController) HandlePod added in v0.2.1

func (dc *DeploymentController) HandlePod(pod *kapi.Pod) error

HandlePod reconciles a pod's current state with its associated deployment and updates the deployment appropriately.

func (*DeploymentController) Run added in v0.2.1

func (dc *DeploymentController) Run()

Run begins watching and synchronizing deployment states.

type DeploymentControllerDeploymentClient added in v0.3.2

type DeploymentControllerDeploymentClient interface {
	GetDeployment(namespace, name string) (*kapi.ReplicationController, error)
	UpdateDeployment(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error)
}

DeploymentControllerDeploymentClient abstracts access to deployments.

type DeploymentControllerDeploymentClientImpl added in v0.3.2

type DeploymentControllerDeploymentClientImpl struct {
	GetDeploymentFunc    func(namespace, name string) (*kapi.ReplicationController, error)
	UpdateDeploymentFunc func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error)
}

DeploymentControllerDeploymentClientImpl is a pluggable deploymentControllerDeploymentClient.

func (*DeploymentControllerDeploymentClientImpl) GetDeployment added in v0.3.2

func (i *DeploymentControllerDeploymentClientImpl) GetDeployment(namespace, name string) (*kapi.ReplicationController, error)

func (*DeploymentControllerDeploymentClientImpl) UpdateDeployment added in v0.3.2

type DeploymentControllerPodClient added in v0.3.2

type DeploymentControllerPodClient interface {
	CreatePod(namespace string, pod *kapi.Pod) (*kapi.Pod, error)
	DeletePod(namespace, name string) error
}

DeploymentControllerPodClient abstracts access to pods.

type DeploymentControllerPodClientImpl added in v0.3.2

type DeploymentControllerPodClientImpl struct {
	CreatePodFunc func(namespace string, pod *kapi.Pod) (*kapi.Pod, error)
	DeletePodFunc func(namespace, name string) error
}

deploymentControllerPodClientImpl is a pluggable deploymentControllerPodClient.

func (*DeploymentControllerPodClientImpl) CreatePod added in v0.3.2

func (i *DeploymentControllerPodClientImpl) CreatePod(namespace string, pod *kapi.Pod) (*kapi.Pod, error)

func (*DeploymentControllerPodClientImpl) DeletePod added in v0.3.2

func (i *DeploymentControllerPodClientImpl) DeletePod(namespace, name string) error

type ImageChangeController

type ImageChangeController struct {
	DeploymentConfigClient ImageChangeControllerDeploymentConfigClient
	NextImageRepository    func() *imageapi.ImageRepository
	// Stop is an optional channel that controls when the controller exits
	Stop <-chan struct{}
}

ImageChangeController watches for changes to ImageRepositories and regenerates DeploymentConfigs when a new version of a tag referenced by a DeploymentConfig is available.

func (*ImageChangeController) HandleImageRepo

func (c *ImageChangeController) HandleImageRepo(imageRepo *imageapi.ImageRepository) error

HandleImageRepo processes the next ImageRepository event.

func (*ImageChangeController) Run

func (c *ImageChangeController) Run()

Run processes ImageRepository events one by one.

type ImageChangeControllerDeploymentConfigClient added in v0.3.2

type ImageChangeControllerDeploymentConfigClient interface {
	ListDeploymentConfigs() ([]*deployapi.DeploymentConfig, error)
	UpdateDeploymentConfig(namespace string, config *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error)
	GenerateDeploymentConfig(namespace, name string) (*deployapi.DeploymentConfig, error)
}

ImageChangeControllerDeploymentConfigClient abstracts access to DeploymentConfigs.

type ImageChangeControllerDeploymentConfigClientImpl added in v0.3.2

type ImageChangeControllerDeploymentConfigClientImpl struct {
	ListDeploymentConfigsFunc    func() ([]*deployapi.DeploymentConfig, error)
	GenerateDeploymentConfigFunc func(namespace, name string) (*deployapi.DeploymentConfig, error)
	UpdateDeploymentConfigFunc   func(namespace string, config *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error)
}

ImageChangeControllerDeploymentConfigClientImpl is a pluggable ChangeStrategy.

func (*ImageChangeControllerDeploymentConfigClientImpl) GenerateDeploymentConfig added in v0.3.2

func (i *ImageChangeControllerDeploymentConfigClientImpl) GenerateDeploymentConfig(namespace, name string) (*deployapi.DeploymentConfig, error)

func (*ImageChangeControllerDeploymentConfigClientImpl) ListDeploymentConfigs added in v0.3.2

func (*ImageChangeControllerDeploymentConfigClientImpl) UpdateDeploymentConfig added in v0.3.2

Directories

Path Synopsis
Package factory contains code used to create deployment controllers.
Package factory contains code used to create deployment controllers.

Jump to

Keyboard shortcuts

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