cluster

package
v0.0.0-...-d1b097e Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusUnknown  = "unknown"
	StatusError    = "error"
	StatusReady    = "ready"
	StatusUpdating = "updating"
	StatusStarted  = "started"
)

Constants for workload ready status. These are defined here so that no-one has to drag in Kubernetes dependencies to be able to use them.

Variables

View Source
var (
	ErrEmptySelector        = errors.New("empty selector")
	ErrWrongResourceKind    = errors.New("new definition does not match existing resource")
	ErrNoMatchingService    = errors.New("no matching service")
	ErrServiceHasNoSelector = errors.New("service has no selector")
	ErrNoMatching           = errors.New("no matching replication controllers or deployments")
	ErrMultipleMatching     = errors.New("multiple matching replication controllers or deployments")
	ErrNoMatchingImages     = errors.New("no matching images")
)

These errors all represent logical problems with cluster configuration, and may be recoverable; e.g., it might be fine if a service does not have a matching RC/deployment.

Functions

func ErrResourceNotFound

func ErrResourceNotFound(name string) error

func UpdateManifest

func UpdateManifest(m Manifests, root string, paths []string, id flux.ResourceID, f func(manifest []byte) ([]byte, error)) error

UpdateManifest looks for the manifest for the identified resource, reads its contents, applies f(contents), and writes the results back to the file.

Types

type Cluster

type Cluster interface {
	// Get all of the services (optionally, from a specific namespace), excluding those
	AllControllers(maybeNamespace string) ([]Controller, error)
	SomeControllers([]flux.ResourceID) ([]Controller, error)
	Ping() error
	Export() ([]byte, error)
	Sync(SyncDef) error
	PublicSSHKey(regenerate bool) (ssh.PublicKey, error)
}

The things we can get from the running cluster. These used to form the remote.Platform interface; but now we do more in the daemon so they are distinct interfaces.

type ContainersOrExcuse

type ContainersOrExcuse struct {
	Excuse     string
	Containers []resource.Container
}

Sometimes we care if we can't find the containers for a service, sometimes we just want the information we can get.

type Controller

type Controller struct {
	ID     flux.ResourceID
	Status string // A status summary for display
	// Is the controller considered read-only because it's under the
	// control of the platform. In the case of Kubernetes, we simply
	// omit these controllers; but this may not always be the case.
	IsSystem bool
	// If this workload was created _because_ of another, antecedent
	// resource through some mechanism (like an operator, or custom
	// resource controller), we try to record the ID of that resource
	// in this field.
	Antecedent flux.ResourceID
	Labels     map[string]string
	Policies   policy.Set
	Rollout    RolloutStatus
	// Errors during the recurring sync from the Git repository to the
	// cluster will surface here.
	SyncError error

	Containers ContainersOrExcuse
}

Controller describes a cluster resource that declares versioned images.

func (Controller) ContainersOrError

func (s Controller) ContainersOrError() ([]resource.Container, error)

func (Controller) ContainersOrNil

func (s Controller) ContainersOrNil() []resource.Container

type ManifestError

type ManifestError struct {
	// contains filtered or unexported fields
}

type Manifests

type Manifests interface {
	// Update the image in a manifest's bytes to that given
	UpdateImage(def []byte, resourceID flux.ResourceID, container string, newImageID image.Ref) ([]byte, error)
	// Load all the resource manifests under the paths
	// given. `baseDir` is used to relativise the paths, which are
	// supplied as absolute paths to directories or files; at least
	// one path should be supplied, even if it is the same as `baseDir`.
	LoadManifests(baseDir string, paths []string) (map[string]resource.Resource, error)
	// Parse the manifests given in an exported blob
	ParseManifests([]byte) (map[string]resource.Resource, error)
	// UpdatePolicies modifies a manifest to apply the policy update specified
	UpdatePolicies([]byte, flux.ResourceID, policy.Update) ([]byte, error)
}

Manifests represents how a set of files are used as definitions of resources, e.g., in Kubernetes, YAML files describing Kubernetes resources.

type Mock

type Mock struct {
	AllServicesFunc    func(maybeNamespace string) ([]Controller, error)
	SomeServicesFunc   func([]flux.ResourceID) ([]Controller, error)
	PingFunc           func() error
	ExportFunc         func() ([]byte, error)
	SyncFunc           func(SyncDef) error
	PublicSSHKeyFunc   func(regenerate bool) (ssh.PublicKey, error)
	UpdateImageFunc    func(def []byte, id flux.ResourceID, container string, newImageID image.Ref) ([]byte, error)
	LoadManifestsFunc  func(base string, paths []string) (map[string]resource.Resource, error)
	ParseManifestsFunc func([]byte) (map[string]resource.Resource, error)
	UpdateManifestFunc func(path, resourceID string, f func(def []byte) ([]byte, error)) error
	UpdatePoliciesFunc func([]byte, flux.ResourceID, policy.Update) ([]byte, error)
}

Doubles as a cluster.Cluster and cluster.Manifests implementation

func (*Mock) AllControllers

func (m *Mock) AllControllers(maybeNamespace string) ([]Controller, error)

func (*Mock) Export

func (m *Mock) Export() ([]byte, error)

func (*Mock) LoadManifests

func (m *Mock) LoadManifests(base string, paths []string) (map[string]resource.Resource, error)

func (*Mock) ParseManifests

func (m *Mock) ParseManifests(def []byte) (map[string]resource.Resource, error)

func (*Mock) Ping

func (m *Mock) Ping() error

func (*Mock) PublicSSHKey

func (m *Mock) PublicSSHKey(regenerate bool) (ssh.PublicKey, error)

func (*Mock) SomeControllers

func (m *Mock) SomeControllers(s []flux.ResourceID) ([]Controller, error)

func (*Mock) Sync

func (m *Mock) Sync(c SyncDef) error

func (*Mock) UpdateImage

func (m *Mock) UpdateImage(def []byte, id flux.ResourceID, container string, newImageID image.Ref) ([]byte, error)

func (*Mock) UpdateManifest

func (m *Mock) UpdateManifest(path string, resourceID string, f func(def []byte) ([]byte, error)) error

func (*Mock) UpdatePolicies

func (m *Mock) UpdatePolicies(def []byte, id flux.ResourceID, p policy.Update) ([]byte, error)

type ResourceError

type ResourceError struct {
	resource.Resource
	Error error
}

type RolloutStatus

type RolloutStatus struct {
	// Desired number of pods as defined in spec.
	Desired int32
	// Updated number of pods that are on the desired pod spec.
	Updated int32
	// Ready number of pods targeted by this deployment.
	Ready int32
	// Available number of available pods (ready for at least minReadySeconds) targeted by this deployment.
	Available int32
	// Outdated number of pods that are on a different pod spec.
	Outdated int32
	// Messages about unexpected rollout progress
	// if there's a message here, the rollout will not make progress without intervention
	Messages []string
}

RolloutStatus describes numbers of pods in different states and the messages about unexpected rollout progress a rollout status might be: - in progress: Updated, Ready or Available numbers are not equal to Desired, or Outdated not equal to 0 - stuck: Messages contains info if deployment unavailable or exceeded its progress deadline - complete: Updated, Ready and Available numbers are equal to Desired and Outdated equal to 0 See https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#deployment-status

type SyncAction

type SyncAction struct {
	Delete resource.Resource // ) one of these
	Apply  resource.Resource // )
}

SyncAction represents either the deletion or application (create or update) of a resource.

type SyncDef

type SyncDef struct {
	// The actions to undertake
	Actions []SyncAction
}

type SyncError

type SyncError []ResourceError

func (SyncError) Error

func (err SyncError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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