caas

package
v0.0.0-...-8ff1004 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OperatorStoragePoolName is the storage pool used to define
	// storage for application operators.
	OperatorStoragePoolName = "operator-storage"

	// JujuExternalHostNameKey specifies the hostname of a CAAS application.
	JujuExternalHostNameKey = "juju-external-hostname"

	// JujuApplicationPath specifies the relative http path used to access a CAAS application.
	JujuApplicationPath = "juju-application-path"

	// JujuDefaultApplicationPath is the default value for juju-application-path.
	JujuDefaultApplicationPath = "/"
)

Variables

This section is empty.

Functions

func ConfigDefaults

func ConfigDefaults(providerDefaults schema.Defaults) schema.Defaults

ConfigDefaults returns the default values for a CAAS application config.

func ConfigSchema

func ConfigSchema(providerFields environschema.Fields) (environschema.Fields, error)

ConfigSchema returns the valid fields for a CAAS application config.

func OperatorStorageClassLabels

func OperatorStorageClassLabels(appName, model string) []string

OperatorStorageClassLabels returns possible labels used to search for a storage class used to provision operator storage.

func RegisterContainerProvider

func RegisterContainerProvider(name string, p ContainerEnvironProvider, alias ...string) (unregister func())

RegisterContainerProvider is used for providers that we want to use for managing 'instances', but are not possible sources for 'juju bootstrap'.

func UnitStorageClassLabels

func UnitStorageClassLabels(appName, model string) []string

UnitStorageClassLabels returns possible labels used to search for a storage class used to provision unit storage.

Types

type Broker

type Broker interface {
	// Provider returns the ContainerEnvironProvider that created this Broker.
	Provider() ContainerEnvironProvider

	// Destroy terminates all containers and other resources in this broker's namespace.
	Destroy(context.ProviderCallContext) error

	// Namespaces returns name names of the namespaces on the cluster.
	Namespaces() ([]string, error)

	// EnsureNamespace ensures this broker's namespace is created.
	EnsureNamespace() error

	// GetStorageClassName returns the name of a storage class with the specified
	// labels, or else the cluster default storage class, or else a NotFound error.
	GetStorageClassName(labels ...string) (string, error)

	// EnsureOperator creates or updates an operator pod for running
	// a charm for the specified application.
	EnsureOperator(appName, agentPath string, config *OperatorConfig) error

	// OperatorExists returns true if the operator for the specified
	// application exists.
	OperatorExists(appName string) (bool, error)

	// DeleteOperator deletes the specified operator.
	DeleteOperator(appName string) error

	// EnsureService creates or updates a service for pods with the given params.
	EnsureService(appName string, statusCallback StatusCallbackFunc, params *ServiceParams, numUnits int, config application.ConfigAttributes) error

	// EnsureCustomResourceDefinition creates or updates a custom resource definition resource.
	EnsureCustomResourceDefinition(appName string, podSpec *PodSpec) error

	// Service returns the service for the specified application.
	Service(appName string) (*Service, error)

	// DeleteService deletes the specified service.
	DeleteService(appName string) error

	// ExposeService sets up external access to the specified service.
	ExposeService(appName string, resourceTags map[string]string, config application.ConfigAttributes) error

	// UnexposeService removes external access to the specified service.
	UnexposeService(appName string) error

	// WatchUnits returns a watcher which notifies when there
	// are changes to units of the specified application.
	WatchUnits(appName string) (watcher.NotifyWatcher, error)

	// Units returns all units and any associated filesystems
	// of the specified application. Filesystems are mounted
	// via volumes bound to the unit.
	Units(appName string) ([]Unit, error)

	// WatchOperator returns a watcher which notifies when there
	// are changes to the operator of the specified application.
	WatchOperator(string) (watcher.NotifyWatcher, error)

	// GetNamespace returns the namespace for the specified name or current namespace.
	GetNamespace(name string) (*core.Namespace, error)

	// Operator returns an Operator with current status and life details.
	Operator(string) (*Operator, error)

	// ListHostCloudRegions lists all the cloud regions that this cluster has worker nodes/instances running in.
	ListHostCloudRegions() (set.Strings, error)

	// NamespaceWatcher provides the API to watch caas namespace.
	NamespaceWatcher

	// ProviderRegistry is an interface for obtaining storage providers.
	storage.ProviderRegistry

	// InstancePrechecker provides a means of "prechecking" placement
	// arguments before recording them in state.
	environs.InstancePrechecker

	// BootstrapEnviron defines methods for bootstraping a controller.
	environs.BootstrapEnviron

	// ResourceAdopter defines methods for adopting resources.
	environs.ResourceAdopter
}

Broker instances interact with the CAAS substrate.

func New

func New(args environs.OpenParams) (Broker, error)

New returns a new broker based on the provided configuration.

func Open

Open creates a Broker instance and errors if the provider is not for a container substrate.

type CharmStorageParams

type CharmStorageParams struct {
	// Size is the minimum size of the filesystem in MiB.
	Size uint64

	// The provider type for this filesystem.
	Provider storage.ProviderType

	// Attributes is a set of provider-specific options for storage creation,
	// as defined in a storage pool.
	Attributes map[string]interface{}

	// ResourceTags is a set of tags to set on the created filesystem, if the
	// storage provider supports tags.
	ResourceTags map[string]string
}

CharmStorageParams defines parameters used to create storage for operators to use for charm state.

type ContainerEnvironProvider

type ContainerEnvironProvider interface {
	environs.EnvironProvider

	// Open opens the broker and returns it. The configuration must
	// have passed through PrepareConfig at some point in its lifecycle.
	//
	// Open should not perform any expensive operations, such as querying
	// the cloud API, as it will be called frequently.
	Open(args environs.OpenParams) (Broker, error)

	// ParsePodSpec unmarshalls the given YAML pod spec.
	ParsePodSpec(in string) (*PodSpec, error)
}

ContainerEnvironProvider represents a computing and storage provider for a container runtime.

type ContainerPort

type ContainerPort struct {
	Name          string `yaml:"name,omitempty" json:"name,omitempty"`
	ContainerPort int32  `yaml:"containerPort" json:"containerPort"`
	Protocol      string `yaml:"protocol" json:"protocol"`
}

ContainerPort defines a port on a container.

type ContainerSpec

type ContainerSpec struct {
	Name string `yaml:"name"`
	// Image is deprecated in preference to using ImageDetails.
	Image        string          `yaml:"image,omitempty"`
	ImageDetails ImageDetails    `yaml:"imageDetails"`
	Ports        []ContainerPort `yaml:"ports,omitempty"`

	Command    []string `yaml:"command,omitempty"`
	Args       []string `yaml:"args,omitempty"`
	WorkingDir string   `yaml:"workingDir,omitempty"`

	Config map[string]interface{} `yaml:"config,omitempty"`
	Files  []FileSet              `yaml:"files,omitempty"`

	// ProviderContainer defines config which is specific to a substrate, eg k8s
	ProviderContainer `yaml:"-"`
}

ContainerSpec defines the data values used to configure a container on the CAAS substrate.

func (*ContainerSpec) Validate

func (spec *ContainerSpec) Validate() error

Validate is defined on ProviderContainer.

type CustomResourceDefinition

type CustomResourceDefinition struct {
	Kind       string                             `yaml:"kind"`
	Group      string                             `yaml:"group"`
	Version    string                             `yaml:"version"`
	Scope      string                             `yaml:"scope"`
	Validation CustomResourceDefinitionValidation `yaml:"validation,omitempty"`
}

CustomResourceDefinition defines the custom resource definition template and content format in podspec.

func (*CustomResourceDefinition) Validate

func (crd *CustomResourceDefinition) Validate() error

Validate returns an error if the crd is not valid.

type CustomResourceDefinitionValidation

type CustomResourceDefinitionValidation struct {
	Properties map[string]apiextensionsv1beta1.JSONSchemaProps `yaml:"properties"`
}

CustomResourceDefinitionValidation defines the custom resource definition validation schema.

type FileSet

type FileSet struct {
	Name      string            `yaml:"name" json:"name"`
	MountPath string            `yaml:"mountPath" json:"mountPath"`
	Files     map[string]string `yaml:"files" json:"files"`
}

FileSet defines a set of files to mount into the container.

type FilesystemInfo

type FilesystemInfo struct {
	StorageName  string
	FilesystemId string
	Size         uint64
	MountPoint   string
	ReadOnly     bool
	Status       status.StatusInfo
	Volume       VolumeInfo
}

FilesystemInfo represents information about a filesystem mounted by a unit.

type ImageDetails

type ImageDetails struct {
	ImagePath string `yaml:"imagePath" json:"imagePath"`
	Username  string `yaml:"username,omitempty" json:"username,omitempty"`
	Password  string `yaml:"password,omitempty" json:"password,omitempty"`
}

ImageDetails defines all details required to pull a docker image from any registry

type NamespaceWatcher

type NamespaceWatcher interface {
	// WatchNamespace returns a watcher which notifies when there
	// are changes to current namespace.
	WatchNamespace() (watcher.NotifyWatcher, error)
}

NamespaceWatcher provides the API to watch caas namespace.

type NewContainerBrokerFunc

type NewContainerBrokerFunc func(args environs.OpenParams) (Broker, error)

NewContainerBrokerFunc returns a Container Broker.

type Operator

type Operator struct {
	Id     string
	Dying  bool
	Status status.StatusInfo
}

Operator represents information about the status of an "operator pod".

type OperatorConfig

type OperatorConfig struct {
	// OperatorImagePath is the docker registry URL for the image.
	OperatorImagePath string

	// Version is the Juju version of the operator image.
	Version version.Number

	// CharmStorage defines parameters used to create storage
	// for operators to use for charm state.
	CharmStorage CharmStorageParams

	// AgentConf is the contents of the agent.conf file.
	AgentConf []byte

	// ResourceTags is a set of tags to set on the operator pod.
	ResourceTags map[string]string
}

OperatorConfig is the config to use when creating an operator.

type PodSpec

type PodSpec struct {
	Containers                []ContainerSpec            `yaml:"-"`
	OmitServiceFrontend       bool                       `yaml:"omitServiceFrontend"`
	CustomResourceDefinitions []CustomResourceDefinition `yaml:"customResourceDefinition,omitempty"`

	// ProviderPod defines config which is specific to a substrate, eg k8s
	ProviderPod `yaml:"-"`
}

PodSpec defines the data values used to configure a pod on the CAAS substrate.

func (*PodSpec) Validate

func (spec *PodSpec) Validate() error

Validate returns an error if the spec is not valid.

type ProviderContainer

type ProviderContainer interface {
	Validate() error
}

ProviderContainer defines a provider specific container.

type ProviderPod

type ProviderPod interface {
	Validate() error
}

ProviderPod defines a provider specific pod.

type Service

type Service struct {
	Id        string
	Addresses []network.Address
}

Service represents information about the status of a caas service entity.

type ServiceParams

type ServiceParams struct {
	// PodSpec is the spec used to configure a pod.
	PodSpec *PodSpec

	// ResourceTags is a set of tags to set on the created service.
	ResourceTags map[string]string

	// Placement defines node affinity rules.
	Placement string

	// Constraints is a set of constraints on
	// the pod to create.
	Constraints constraints.Value

	// Filesystems is a set of parameters for filesystems that should be created.
	Filesystems []storage.KubernetesFilesystemParams

	// Devices is a set of parameters for Devices that is required.
	Devices []devices.KubernetesDeviceParams
}

ServiceParams defines parameters used to create a service.

type StatusCallbackFunc

type StatusCallbackFunc func(appName string, settableStatus status.Status, info string, data map[string]interface{}) error

StatusCallbackFunc represents a function that can be called to report a status.

type Unit

type Unit struct {
	Id             string
	Address        string
	Ports          []string
	Dying          bool
	Status         status.StatusInfo
	FilesystemInfo []FilesystemInfo
}

Unit represents information about the status of a "pod".

type VolumeInfo

type VolumeInfo struct {
	VolumeId   string
	Size       uint64
	Persistent bool
	Status     status.StatusInfo
}

VolumeInfo represents information about a volume mounted by a unit.

Directories

Path Synopsis
kubernetes
provider/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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