juju: github.com/juju/juju/caas Index | Files | Directories

package caas

import "github.com/juju/juju/caas"

Index

Package Files

broker.go config.go containers.go metadata.go scripts.go

Constants

const (
    // 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 = "/"
)
const (
    // K8sCloudMicrok8s is the name used for microk8s k8s clouds.
    K8sCloudMicrok8s = "microk8s"

    // K8sCloudGCE is the name used for GCE k8s clouds(GKE, CDK).
    K8sCloudGCE = "gce"

    // K8sCloudAzure is the name used for Azure k8s clouds(AKS, CDK).
    K8sCloudAzure = "azure"

    // K8sCloudEC2 is the name used for AWS k8s clouds(EKS, CDK).
    K8sCloudEC2 = "ec2"

    // K8sCloudOpenStack is the name used for openstack k8s clouds(CDK).
    K8sCloudOpenStack = "openstack"

    // K8sCloudMAAS is the name used for MAAS k8s clouds(CDK).
    K8sCloudMAAS = "maas"

    // K8sCloudLXD is the name used for LXD k8s clouds(Kubernetes Core).
    K8sCloudLXD = "lxd"

    // K8sCloudRackspace is the name used for Rackspace k8s clouds(CDK).
    K8sCloudRackspace = "rackspace"

    // K8sCloudOther is the name used for any other k8s cloud is not listed above.
    K8sCloudOther = "other"

    // Microk8sRegion is the single microk8s cloud region.
    Microk8sRegion = "localhost"

    // MicroK8sClusterName is the cluster named used by microk8s.
    MicroK8sClusterName = "microk8s-cluster"
)

Variables

var (
    // RoleTypes defines supported role types.
    RoleTypes = []RBACType{
        Role, ClusterRole,
    }
    // RoleBindingTypes defines supported role binding types.
    RoleBindingTypes = []RBACType{
        RoleBinding, ClusterRoleBinding,
    }
)
var (
    JujudStartUpSh = "" /* 141 byte string literal not displayed */[1:]
)

func ConfigDefaults Uses

func ConfigDefaults(providerDefaults schema.Defaults) schema.Defaults

ConfigDefaults returns the default values for a CAAS application config.

func ConfigSchema Uses

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

ConfigSchema returns the valid fields for a CAAS application config.

func IsNonPreferredStorageError Uses

func IsNonPreferredStorageError(err error) bool

IsNonPreferredStorageError returns true if err is a NonPreferredStorageError.

func RegisterContainerProvider Uses

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'.

type Broker Uses

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

    // APIVersion returns the master kubelet API version.
    APIVersion() (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 indicates if the operator for the specified
    // application exists, and whether the operator is terminating.
    OperatorExists(appName string) (OperatorState, error)

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

    // EnsureCustomResourceDefinition creates or updates a custom resource definition resource.
    EnsureCustomResourceDefinition(appName string, podSpec *PodSpec) 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)

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

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

    // ClusterMetadataChecker provides an API to query cluster metadata.
    ClusterMetadataChecker

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

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

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

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

    // NamespaceGetterSetter provides the API to get/set namespace.
    NamespaceGetterSetter

    // StorageValidator provides methods to validate storage.
    StorageValidator

    // ServiceGetterSetter provides the API to get/set service.
    ServiceGetterSetter

    // Upgrader provides the API to perform upgrades.
    Upgrader
}

Broker instances interact with the CAAS substrate.

func New Uses

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

New returns a new broker based on the provided configuration.

func Open Uses

func Open(p environs.EnvironProvider, args environs.OpenParams) (Broker, error)

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

type Capabilities Uses

type Capabilities struct {
    Role        *RoleSpec        `yaml:"role"`
    RoleBinding *RoleBindingSpec `yaml:"roleBinding"`
}

Capabilities defines RBAC related config.

func (Capabilities) Validate Uses

func (c Capabilities) Validate() error

Validate returns an error if the spec is not valid.

type CharmStorageParams Uses

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 ClusterMetadata Uses

type ClusterMetadata struct {
    NominatedStorageClass *StorageProvisioner
    OperatorStorageClass  *StorageProvisioner
    Cloud                 string
    Regions               set.Strings
}

ClusterMetadata defines metadata about a cluster.

type ClusterMetadataChecker Uses

type ClusterMetadataChecker interface {
    // GetClusterMetadata returns metadata about host cloud and storage for the cluster.
    GetClusterMetadata(storageClass string) (result *ClusterMetadata, err error)

    // CheckDefaultWorkloadStorage returns an error if the opinionated storage defined for
    // the cluster does not match the specified storage.
    CheckDefaultWorkloadStorage(cluster string, storageProvisioner *StorageProvisioner) error

    // EnsureStorageProvisioner creates a storage provisioner with the specified config, or returns an existing one.
    EnsureStorageProvisioner(cfg StorageProvisioner) (*StorageProvisioner, error)
}

ClusterMetadataChecker provides an API to query cluster metadata.

type ContainerEnvironProvider Uses

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)
}

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

type ContainerPort Uses

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 Uses

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 Uses

func (spec *ContainerSpec) Validate() error

Validate is defined on ProviderContainer.

type DeploymentParams Uses

type DeploymentParams struct {
    DeploymentType DeploymentType
    ServiceType    ServiceType
}

DeploymentParams defines parameters for specifying how a service is deployed.

type DeploymentType Uses

type DeploymentType string

DeploymentType defines a deployment type.

const (
    DeploymentStateless DeploymentType = "stateless"
    DeploymentStateful  DeploymentType = "stateful"
)

type FileSet Uses

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 Uses

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 Uses

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 NamespaceGetterSetter Uses

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

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

    // GetCurrentNamespace returns current namespace name.
    GetCurrentNamespace() string
}

NamespaceGetterSetter provides the API to get/set namespace.

type NamespaceWatcher Uses

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 Uses

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

NewContainerBrokerFunc returns a Container Broker.

type NonPreferredStorageError Uses

type NonPreferredStorageError struct {
    PreferredStorage
}

NonPreferredStorageError is raised when a cluster does not have the opinionated default storage Juju requires.

func (*NonPreferredStorageError) Error Uses

func (e *NonPreferredStorageError) Error() string

Error implements error.

type Operator Uses

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

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

type OperatorConfig Uses

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 OperatorState Uses

type OperatorState struct {
    // Exists is true if the operator exists in the cluster.
    Exists bool

    // Terminating is true if the operator is in Terminating state.
    Terminating bool
}

OperatorState is returned by the OperatorExists call.

type PodSpec Uses

type PodSpec struct {
    OmitServiceFrontend bool `yaml:"omitServiceFrontend"`

    Containers                []ContainerSpec                                              `yaml:"-"`
    InitContainers            []ContainerSpec                                              `yaml:"-"`
    CustomResourceDefinitions map[string]apiextensionsv1beta1.CustomResourceDefinitionSpec `yaml:"-"`
    ServiceAccount            *ServiceAccountSpec                                          `yaml:"-"`

    // 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 Uses

func (spec *PodSpec) Validate() error

Validate returns an error if the spec is not valid.

type PreferredStorage Uses

type PreferredStorage struct {
    Name        string
    Provisioner string
    Parameters  map[string]string
}

PreferredStorage defines preferred storage attributes on a given cluster.

type ProviderContainer Uses

type ProviderContainer interface {
    Validate() error
}

ProviderContainer defines a provider specific container.

type ProviderPod Uses

type ProviderPod interface {
    Validate() error
}

ProviderPod defines a provider specific pod.

type RBACType Uses

type RBACType string

RBACType describes Role/Binding type.

const (
    // Role is the single namespace based.
    Role RBACType = "Role"
    // ClusterRole is the all namespaces based.
    ClusterRole RBACType = "ClusterRole"

    // RoleBinding is the single namespace based.
    RoleBinding RBACType = "RoleBinding"
    // ClusterRoleBinding is the all namespaces based.
    ClusterRoleBinding RBACType = "ClusterRoleBinding"
)

type RoleBindingSpec Uses

type RoleBindingSpec struct {
    Name string   `yaml:"name"`
    Type RBACType `yaml:"type"`
}

RoleBindingSpec defines config for referencing to or creating a RoleBinding or ClusterRoleBinding resource.

func (RoleBindingSpec) Validate Uses

func (rb RoleBindingSpec) Validate() error

Validate returns an error if the spec is not valid.

type RoleSpec Uses

type RoleSpec struct {
    Name string   `yaml:"name"`
    Type RBACType `yaml:"type"`
    // We assume this is an existing Role/ClusterRole if Rules is empty.
    // Existing Role/ClusterRoles can be only referenced but will never be deleted or updated by Juju.
    // Role/ClusterRoles are created by Juju will be properly labeled.
    Rules []rbacv1.PolicyRule `yaml:"rules"`
}

RoleSpec defines config for referencing to or creating a Role or Cluster resource.

func (RoleSpec) Validate Uses

func (r RoleSpec) Validate() error

Validate returns an error if the spec is not valid.

type Service Uses

type Service struct {
    Id         string
    Addresses  []network.Address
    Scale      *int
    Generation *int64
    Status     status.StatusInfo
}

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

type ServiceAccountSpec Uses

type ServiceAccountSpec struct {
    Name                         string        `yaml:"name"`
    AutomountServiceAccountToken *bool         `yaml:"automountServiceAccountToken,omitempty"`
    Capabilities                 *Capabilities `yaml:"capabilities"`
}

ServiceAccountSpec defines spec for referencing to or creating a service account.

func (ServiceAccountSpec) Validate Uses

func (sa ServiceAccountSpec) Validate() error

Validate returns an error if the spec is not valid.

type ServiceGetterSetter Uses

type ServiceGetterSetter interface {
    // 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

    // DeleteService deletes the specified service with all related resources.
    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

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

ServiceGetterSetter provides the API to get/set service.

type ServiceParams Uses

type ServiceParams struct {
    // Deployment defines how a service is deployed.
    Deployment DeploymentParams

    // 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

    // 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 ServiceType Uses

type ServiceType string

ServiceType defines a service type.

const (
    ServiceCluster      ServiceType = "cluster"
    ServiceLoadBalancer ServiceType = "loadbalancer"
    ServiceExternal     ServiceType = "external"
)

type StatusCallbackFunc Uses

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 StorageProvisioner Uses

type StorageProvisioner struct {
    Name          string
    Provisioner   string
    Parameters    map[string]string
    Namespace     string
    ReclaimPolicy string
}

StorageProvisioner defines the a storage provisioner available on a cluster.

type StorageValidator Uses

type StorageValidator interface {
    // ValidateStorageClass returns an error if the storage config is not valid.
    ValidateStorageClass(config map[string]interface{}) error
}

StorageValidator provides methods to validate storage.

type Unit Uses

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

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

type Upgrader Uses

type Upgrader interface {
    // Upgrade sets the OCI image for the app to the specified version.
    Upgrade(appName string, vers version.Number) error
}

Upgrader provides the API to perform upgrades.

type VolumeInfo Uses

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

VolumeInfo represents information about a volume mounted by a unit.

Directories

PathSynopsis
kubernetes/clientconfig
kubernetes/provider
kubernetes/provider/mocksPackage mocks is a generated GoMock package.

Package caas imports 17 packages (graph) and is imported by 52 packages. Updated 2019-08-20. Refresh now. Tools for package owners.