storageos

package
v1.1.3-alpha3 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPort is the default api port.
	DefaultPort = 5705

	// DefaultScheme is used for api endpoint.
	DefaultScheme = "http"

	// TLSScheme scheme can be used if the api endpoint has TLS enabled.
	TLSScheme = "https"
)
View Source
const (
	// ReservedLabelPrefix is the string prefix used to identify StorageOS
	// reserved labels.  Most reserved labels will require specific API calls to
	// apply to the StorageOS object.
	ReservedLabelPrefix = "storageos.com/"

	// ReservedLabelComputeOnly is the node label used to indicate that a node
	// should not store data and should instead access it remotely.
	ReservedLabelComputeOnly = ReservedLabelPrefix + "computeonly"

	// ReservedLabelReplicas is the PVC label used to indicate the desired
	// number of volume replicas.
	ReservedLabelReplicas = ReservedLabelPrefix + "replicas"

	// ReservedLabelNoCache is the PVC label used to disable the per-volume
	// cache.  It can only be set when the volume is created.
	ReservedLabelNoCache = ReservedLabelPrefix + "nocache"

	// ReservedLabelNoCompress is the PVC label used to disable compression on a
	// volume. It can only be set when the volume is created.
	ReservedLabelNoCompress = ReservedLabelPrefix + "nocompress"

	// ReservedLabelFailureMode is the PVC label used to set the behaviour when
	// there are fewer copies of the data available than what was requested.
	ReservedLabelFailureMode = ReservedLabelPrefix + "failure-mode"

	// ReservedLabelEncryption is the PVC label used to indicate that the volume
	// should be encrypted.
	ReservedLabelEncryption = ReservedLabelPrefix + "encryption"

	// ReservedLabelTopologyAware is the PVC label used to indicate whether the
	// scheduler should make placement decisions based on the cluster's node
	// topology.
	ReservedLabelTopologyAware = ReservedLabelPrefix + "topology-aware"

	// ReservedLabelTopologyKey can be set on the PVC to indicate which node
	// label describes the topology used for volume placement decisions.
	ReservedLabelTopologyKey = ReservedLabelPrefix + "topology-key"

	// ReservedLabelFencing can be set on Pods to indicate that the Pod should
	// be deleted if it is running on a node that StorageOS believes no longer
	// has access to its storage.
	ReservedLabelFencing = ReservedLabelPrefix + "fenced"

	// ReservedLabelK8sPVCNamespace is set by the csi-provisioner at create
	// time.  It's treated as a reserved label by StorageOS and can't be modified.
	ReservedLabelK8sPVCNamespace = "csi.storage.k8s.io/pvc/namespace"

	// ReservedLabelK8sPVCName is set by the csi-provisioner at create time.
	// It's treated as a reserved label by StorageOS and can't be modified.
	ReservedLabelK8sPVCName = "csi.storage.k8s.io/pvc/name"

	// ReservedLabelK8sPVName is set by the csi-provisioner at create time. It's
	// treated as a reserved label by StorageOS and can't be modified.
	ReservedLabelK8sPVName = "csi.storage.k8s.io/pv/name"
)
View Source
const (
	// NFSPort is the port exposed by the service.  Each service will have a
	// unique ip, so it can be fixed to the default NFS port.
	NFSPort int32 = 2049
	// NFSPortName is used as the name of the NFS port in the service definition.
	NFSPortName = "nfs"
	// NFSProtocol is the prtocol to be used for NFS.
	NFSProtocol = "TCP"

	// VolumeIDLabelName is the label to set on created resources that refers
	// back to the StorageOS volume by its ID.  This label is intended for
	// assisting with debugging and the api-manager should not rely on it being
	// set.
	VolumeIDLabelName = "storageos.com/volume-id"

	// LabelNFSMountEndpoint is the nfs attachment's mount endpoint, if any.
	LabelNFSMountEndpoint = "storageos.com/nfs/mount-endpoint"

	// LabelPVName holds the name of the corresponding PV.
	LabelPVName = "csi.storage.k8s.io/pv/name"

	// LabelPVCName holds the name of the corresponding PVC.
	LabelPVCName = "csi.storage.k8s.io/pvc/name"

	// LabelPVCNamespace holds the namespace of the corresponding PVC.  It
	// should always be the same as the volume namespace.
	LabelPVCNamespace = "csi.storage.k8s.io/pvc/namespace"
)
View Source
const (
	FailureModeSoft     = "soft"
	FailureModeHard     = "hard"
	FailureModeAlwaysOn = "alwayson"

	// PlacementStrategyDefault can be set to use the control plane's default
	// placement strategy.
	PlacementStrategyDefault = ""

	// PlacementStrategyTopologyAware sets the control plane's placement
	// scheduler to be topology-aware.
	PlacementStrategyTopologyAware = "topology-aware"
)

Variables

View Source
var (
	// ErrNotInitialized is returned if the API client was accessed before it
	// was initialised.
	ErrNotInitialized = errors.New("api client not initialized")
	// ErrNoAuthToken is returned when the API client did not get an error
	// during authentication but no valid auth token was returned.
	ErrNoAuthToken = errors.New("no token found in auth response")

	// HTTPTimeout is the time limit for requests made by the API Client. The
	// timeout includes connection time, any redirects, and reading the response
	// body. The timer remains running after Get, Head, Post, or Do return and
	// will interrupt reading of the Response.Body.
	HTTPTimeout = 10 * time.Second

	// AuthenticationTimeout is the time limit for authentication requests to
	// complete.  It should be longer than the HTTPTimeout.
	AuthenticationTimeout = 20 * time.Second

	// DefaultRequestTimeout is the default time limit for api requests to
	// complete.  It should be longer than the HTTPTimeout.
	DefaultRequestTimeout = 20 * time.Second
)
View Source
var (
	// ErrReservedLabelUnknown indicates that a label with the reserved prefix
	// was provided, but not recognized.
	ErrReservedLabelUnknown = errors.New("unrecognized reserved label")

	// ErrReservedLabelInvalid indicates that a label with the reserved prefix
	// was recognized, but not supported for the obejct type.
	ErrReservedLabelInvalid = errors.New("invalid reserved label for this object type")

	// ErrReservedLabelFixed can be used to indicate that a label can't be
	// modified once set during object creation.
	ErrReservedLabelFixed = errors.New("behaviour can't be changed after creation")
)
View Source
var (
	// ErrNamespaceNotFound is returned if a namespace was provided but it was
	// not found.
	ErrNamespaceNotFound = errors.New("namespace not found")

	// ErrNamespaceInUse is returned when an operation can't be completed because
	// StorageOS detects that the namespace is still in use.
	ErrNamespaceInUse = errors.New("namespace still in use")
)
View Source
var (
	// ErrNodeNotFound is returned if a node was provided but it was not found.
	ErrNodeNotFound = errors.New("node not found")

	// ErrNodeInUse is returned when an operation can't be completed because
	// StorageOS detects that the node is still in use.
	ErrNodeInUse = errors.New("node still in use")

	// ErrNodeHasLock is returned when the node lock has not yet expired.
	ErrNodeHasLock = errors.New("node lock has not yet expired")
)
View Source
var (
	// ErrNotFound is returned if a volume was provided but it was not found.
	ErrNotFound = errors.New("volume not found")

	// ErrNotShared is returned if a volume was found but it is not shared.
	ErrNotShared = errors.New("volume not shared")

	// ErrNotKubernetes is returned if a volume was not created by the
	// Kubernetes volume provisioner.  This is required as the provisioner adds
	// labels to the volume that allows it to be traced back to the PVC.
	// Without the link to the PVC, we can't tell if the volume was created as
	// RWX and we can set the PVC as the OwnerReference, allowing cleanup on
	// PVC delete.
	ErrNotKubernetes = errors.New("volume not created by kubernetes")

	// ErrVolumeShared can be returned when the volume is expected not to be shared.
	ErrVolumeShared = errors.New("volume is shared")

	// ErrListingVolumes can be returned if there was an error listing volumes.
	ErrListingVolumes = errors.New("failed to list volumes")
)
View Source
var (
	// ErrBadFailureMode is returned if the failure-mode label value was
	// invalid.
	ErrBadFailureMode = errors.New("failed to parse failure-mode label, must be hard, soft, alwayson or an integer toleration")
)
View Source
var (
	// ErrVolumeNotFound is returned if a volume was provided but it was not found.
	ErrVolumeNotFound = errors.New("volume not found")
)

Functions

func Authenticate

func Authenticate(client *api.APIClient, username, password string) (context.Context, error)

Authenticate against the API and set the authentication token in the client to be used for subsequent API requests. The token must be refreshed periodically using AuthenticateRefresh().

func IsReservedLabel added in v1.1.0

func IsReservedLabel(key string) bool

IsReservedLabel returns true if the key is a StorageOS reserved label name. It does not validate whether the key is valid.

func ListErrors added in v1.1.0

func ListErrors(es []error) string

ListErrors is a basic formatter that outputs the number of errors that occurred along with a list of the errors.

func ParseFailureMode added in v1.1.0

func ParseFailureMode(s string) (api.FailureModeIntent, uint64, error)

ParseFailureMode parses a string and returns either a failure mode intent or a threshold, if set. Only one of the intent or threshold should be set.

func ReadCredsFromMountedSecret

func ReadCredsFromMountedSecret(path string) (string, string, error)

ReadCredsFromMountedSecret reads the api username and password from a Kubernetes secret mounted at the given path. If the username or password in the secret changes, the data in the mounted file will also change.

Types

type Client

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

Client provides access to the StorageOS API.

func New

func New(username, password, endpoint string) (*Client, error)

New returns a pre-authenticated client for the StorageOS API. The authentication token must be refreshed periodically using AuthenticateRefresh().

func NewTestAPIClient added in v1.1.0

func NewTestAPIClient(api ControlPlane) *Client

NewTestAPIClient returns a client that uses the provided ControlPlane api client. Intended for tests that use a mocked StorageOS api. This avoids having to publically expose the api on the Client struct.

func NewTracedClient

func NewTracedClient(username, password, endpoint string) (*Client, error)

NewTracedClient returns a pre-authenticated client for the StorageOS API that has tracing enabled. The authentication token must be refreshed periodically using AuthenticateRefresh().

func (*Client) AddToken added in v1.0.2

func (c *Client) AddToken(ctx context.Context) context.Context

AddToken adds the current authentication token to a given context.

func (*Client) DeleteNamespace added in v1.1.0

func (c *Client) DeleteNamespace(ctx context.Context, key client.ObjectKey) error

DeleteNamespace removes a namespace from the StorageOS cluster. Delete will fail if pre-requisites are not met (i.e. namespace has volumes).

func (*Client) DeleteNode added in v1.1.0

func (c *Client) DeleteNode(ctx context.Context, key client.ObjectKey) error

DeleteNode removes a node from the StorageOS cluster. Delete will fail if pre-requisites are not met:

		(1) The node appears offline
		(2) No node lock is held
     (3) No master deployments live on the node (i.e. node must be detected as no active volumes).

func (*Client) EnsureComputeOnly added in v1.1.0

func (c *Client) EnsureComputeOnly(ctx context.Context, key client.ObjectKey, enabled bool) error

EnsureComputeOnly ensures that the compute-only behaviour has been applied to the StorageOS node.

func (*Client) EnsureFailureMode added in v1.1.0

func (c *Client) EnsureFailureMode(ctx context.Context, key client.ObjectKey, desired string) error

EnsureFailureMode ensures that the desired failure mode has been applied to the StorageOS volume.

func (*Client) EnsureNodeLabels added in v1.1.0

func (c *Client) EnsureNodeLabels(ctx context.Context, key client.ObjectKey, labels map[string]string) error

EnsureNodeLabels applies a set of labels to a StorageOS node.

Labels prefixed with the StorageOS reserved label indicator ("storageos.com/") will need to be processed separately as most have individual API endpoints to ensure that they are applied atomically.

Unreserved labels are copied as a blob and are not evaluated.

func (*Client) EnsureReplicas added in v1.1.0

func (c *Client) EnsureReplicas(ctx context.Context, key client.ObjectKey, desired uint64) error

EnsureReplicas ensures that the desired number of replicas has been applied to the StorageOS volume.

func (*Client) EnsureTopologyAware added in v1.2.0

func (c *Client) EnsureTopologyAware(ctx context.Context, key client.ObjectKey, desired bool, topologyKey string) error

EnsureTopologyAware ensures that the desired topology awareness has been applied to the StorageOS volume.

func (*Client) EnsureUnreservedNodeLabels added in v1.1.0

func (c *Client) EnsureUnreservedNodeLabels(ctx context.Context, key client.ObjectKey, labels map[string]string) error

EnsureUnreservedNodeLabels applies a set of labels to the StorageOS node if different. Existing labels will be overwritten. The set of labels must not include StorageOS reserved labels.

func (*Client) EnsureUnreservedVolumeLabels added in v1.1.0

func (c *Client) EnsureUnreservedVolumeLabels(ctx context.Context, key client.ObjectKey, labels map[string]string) error

EnsureUnreservedVolumeLabels applies a set of labels to the StorageOS volume if different. Existing labels will be overwritten. Any reserved labels will be ignored.

func (*Client) EnsureVolumeLabels added in v1.1.0

func (c *Client) EnsureVolumeLabels(ctx context.Context, key client.ObjectKey, labels map[string]string) error

EnsureVolumeLabels applies a set of labels to a StorageOS volume.

Labels prefixed with the StorageOS reserved label indicator ("storageos.com/") will need to be processed separately as most have individual API endpoints to ensure that they are applied atomically.

Unreserved labels are copied as a blob and are not evaluated.

func (*Client) GetVolume added in v1.1.0

func (c *Client) GetVolume(ctx context.Context, key client.ObjectKey) (Object, error)

GetVolume returns the StorageOS volume object matching the key.

func (*Client) ListNamespaces added in v1.1.0

func (c *Client) ListNamespaces(ctx context.Context) ([]Object, error)

ListNamespaces returns a list of all StorageOS namespace objects.

func (*Client) ListNodes added in v1.1.0

func (c *Client) ListNodes(ctx context.Context) ([]client.Object, error)

ListNodes returns a list of all StorageOS node objects.

func (*Client) ListSharedVolumes

func (c *Client) ListSharedVolumes(ctx context.Context) (SharedVolumeList, error)

ListSharedVolumes returns a list of active shared volumes.

func (*Client) ListVolumes added in v1.1.0

func (c *Client) ListVolumes(ctx context.Context) ([]Object, error)

ListVolumes returns a list of all StorageOS volume objects.

func (*Client) NodeObjects added in v1.1.0

func (c *Client) NodeObjects(ctx context.Context) (map[client.ObjectKey]Object, error)

NodeObjects returns a map of node objects, indexed on ObjectKey for efficient lookups.

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context, secretPath string, reset chan struct{}, interval time.Duration, resultCounter metrics.ResultMetric, log logr.Logger) error

Refresh the api token on a given interval, or reset is received on the reset channel. This function is blocking and is intended to be run in a goroutine. Errors are currently logged at info level since they will be retried and should be recoverable. Only a cancelled context will cause this to stop. Be aware that any errors returned will trigger a process shutdown.

func (*Client) SetExternalEndpoint

func (c *Client) SetExternalEndpoint(ctx context.Context, volID string, namespace string, endpoint string) error

SetExternalEndpoint sets the external endpoint on a SharedVolume. The endpoint should be <host|ip>:<port>.

func (*Client) VolumeObjects added in v1.1.0

func (c *Client) VolumeObjects(ctx context.Context) (map[client.ObjectKey]Object, error)

VolumeObjects returns a map of volume objects, indexed on object key for efficient lookups.

type ControlPlane added in v1.0.2

type ControlPlane interface {
	RefreshJwt(ctx context.Context) (api.UserSession, *http.Response, error)
	AuthenticateUser(ctx context.Context, authUserData api.AuthUserData) (api.UserSession, *http.Response, error)
	ListNamespaces(ctx context.Context) ([]api.Namespace, *http.Response, error)
	DeleteNamespace(ctx context.Context, id string, version string, localVarOptionals *api.DeleteNamespaceOpts) (*http.Response, error)
	ListNodes(ctx context.Context) ([]api.Node, *http.Response, error)
	UpdateNode(ctx context.Context, id string, updateNodeData api.UpdateNodeData) (api.Node, *http.Response, error)
	DeleteNode(ctx context.Context, id string, version string, localVarOptionals *api.DeleteNodeOpts) (*http.Response, error)
	SetComputeOnly(ctx context.Context, id string, setComputeOnlyNodeData api.SetComputeOnlyNodeData, localVarOptionals *api.SetComputeOnlyOpts) (api.Node, *http.Response, error)
	ListVolumes(ctx context.Context, namespaceID string) ([]api.Volume, *http.Response, error)
	GetVolume(ctx context.Context, namespaceID string, id string) (api.Volume, *http.Response, error)
	UpdateVolume(ctx context.Context, namespaceID string, id string, updateVolumeData api.UpdateVolumeData, localVarOptionals *api.UpdateVolumeOpts) (api.Volume, *http.Response, error)
	SetReplicas(ctx context.Context, namespaceID string, id string, setReplicasRequest api.SetReplicasRequest, localVarOptionals *api.SetReplicasOpts) (api.AcceptedMessage, *http.Response, error)
	SetFailureMode(ctx context.Context, namespaceID string, id string, setFailureModeRequest api.SetFailureModeRequest, localVarOptionals *api.SetFailureModeOpts) (api.Volume, *http.Response, error)
	SetPlacementStrategy(ctx context.Context, namespaceID string, id string, setPlacementStrategyData api.SetPlacementStrategyData, localVarOptionals *api.SetPlacementStrategyOpts) (api.AcceptedMessage, *http.Response, error)
	UpdateNFSVolumeMountEndpoint(ctx context.Context, namespaceID string, id string, nfsVolumeMountEndpoint api.NfsVolumeMountEndpoint, localVarOptionals *api.UpdateNFSVolumeMountEndpointOpts) (*http.Response, error)
}

ControlPlane is the subset of the StorageOS control plane ControlPlane that api-manager requires. New methods should be added here as needed, then the mocks regenerated.

type Identifier added in v1.1.0

type Identifier interface {
	GetID() string
	GetName() string
	GetNamespace() string
}

Identifier is a StorageOS object that has an identity.

type MockClient

type MockClient struct {
	DeleteNamespaceCallCount map[client.ObjectKey]int
	DeleteNodeCallCount      map[client.ObjectKey]int
	ListNamespacesErr        error
	DeleteNamespaceErr       error
	GetNodeErr               error
	NodeObjectsErr           error
	ListNodesErr             error
	DeleteNodeErr            error
	EnsureNodeLabelsErr      error
	GetNodeLabelsErr         error
	GetVolumeErr             error
	VolumeObjectsErr         error
	EnsureVolumeLabelsErr    error
	SharedVolsErr            error
	SharedVolErr             error
	SetEndpointErr           error
	// contains filtered or unexported fields
}

MockClient provides a test interface to the StorageOS api.

func NewMockClient added in v1.1.0

func NewMockClient() *MockClient

NewMockClient returns an initialized MockClient.

func (*MockClient) AddNamespace added in v1.1.0

func (c *MockClient) AddNamespace(key client.ObjectKey) error

AddNamespace adds a namespace to the StorageOS cluster.

func (*MockClient) AddNode added in v1.1.0

func (c *MockClient) AddNode(obj Object) error

AddNode adds a node to the StorageOS cluster.

func (*MockClient) AddVolume added in v1.1.0

func (c *MockClient) AddVolume(obj Object) error

AddVolume adds a volume to the StorageOS cluster.

func (*MockClient) Delete

func (c *MockClient) Delete(id string, namespace string)

Delete a shared volume.

func (*MockClient) DeleteNamespace added in v1.1.0

func (c *MockClient) DeleteNamespace(ctx context.Context, key client.ObjectKey) error

DeleteNamespace removes a namespace from the StorageOS cluster.

func (*MockClient) DeleteNode added in v1.1.0

func (c *MockClient) DeleteNode(ctx context.Context, key client.ObjectKey) error

DeleteNode removes a node from the StorageOS cluster.

func (*MockClient) EnsureNodeLabels added in v1.1.0

func (c *MockClient) EnsureNodeLabels(ctx context.Context, key client.ObjectKey, labels map[string]string) error

EnsureNodeLabels applies a set of labels to the StorageOS node.

func (*MockClient) EnsureVolumeLabels added in v1.1.0

func (c *MockClient) EnsureVolumeLabels(ctx context.Context, key client.ObjectKey, labels map[string]string) error

EnsureVolumeLabels applies a set of labels to the StorageOS volume.

func (*MockClient) Get

func (c *MockClient) Get(id string, namespace string) (*SharedVolume, error)

Get returns a SharedVolume.

func (*MockClient) GetNodeLabels added in v1.1.0

func (c *MockClient) GetNodeLabels(key client.ObjectKey) (map[string]string, error)

GetNodeLabels retrieves the set of labels.

func (*MockClient) GetVolume added in v1.1.0

func (c *MockClient) GetVolume(ctx context.Context, key client.ObjectKey) (Object, error)

GetVolume retrieves a volume object.

func (*MockClient) ListNamespaces added in v1.1.0

func (c *MockClient) ListNamespaces(ctx context.Context) ([]Object, error)

ListNamespaces returns a list of StorageOS namespace objects.

func (*MockClient) ListNodes added in v1.1.0

func (c *MockClient) ListNodes(ctx context.Context) ([]client.Object, error)

ListNodes returns a list of StorageOS node objects.

func (*MockClient) ListSharedVolumes

func (c *MockClient) ListSharedVolumes(ctx context.Context) (SharedVolumeList, error)

ListSharedVolumes returns a list of active shared volumes.

func (*MockClient) NamespaceExists added in v1.1.0

func (c *MockClient) NamespaceExists(key client.ObjectKey) bool

NamespaceExists returns true if the namespace exists.

func (*MockClient) NodeExists added in v1.1.0

func (c *MockClient) NodeExists(key client.ObjectKey) bool

NodeExists returns true if the node exists.

func (*MockClient) NodeObjects added in v1.1.0

func (c *MockClient) NodeObjects(ctx context.Context) (map[client.ObjectKey]Object, error)

NodeObjects returns a map of nodes objects, indexed on object key.

func (*MockClient) RandomVol

func (c *MockClient) RandomVol() *SharedVolume

RandomVol returns a randomly generated shared volume. Always uses default namespace since it will always exist.

func (*MockClient) Reset

func (c *MockClient) Reset()

Reset the shared volume list.

func (*MockClient) Set

func (c *MockClient) Set(v *SharedVolume) *SharedVolume

Set adds or replaces a shared volume, and also returns it.

func (*MockClient) SetExternalEndpoint

func (c *MockClient) SetExternalEndpoint(ctx context.Context, id string, namespace string, endpoint string) error

SetExternalEndpoint sets the external endpoint on a SharedVolume. The endpoint should be <host|ip>:<port>.

func (*MockClient) UpdateNodeHealth added in v1.1.0

func (c *MockClient) UpdateNodeHealth(key client.ObjectKey, healthy bool) bool

UpdateNodeHealth sets the node health.

func (*MockClient) UpdateVolumeHealth added in v1.1.0

func (c *MockClient) UpdateVolumeHealth(key client.ObjectKey, healthy bool) bool

UpdateVolumeHealth sets the volume health.

func (*MockClient) VolumeObjects added in v1.1.0

func (c *MockClient) VolumeObjects(ctx context.Context) (map[client.ObjectKey]Object, error)

VolumeObjects returns a map of volume objects, indexed on object key.

type MockObject added in v1.1.0

type MockObject struct {
	ID        string
	Name      string
	Namespace string
	Labels    map[string]string
	Healthy   bool
}

MockObject can be be used to replace an api object.

func (MockObject) GetID added in v1.1.0

func (m MockObject) GetID() string

GetID returns the object ID.

func (MockObject) GetLabels added in v1.1.0

func (m MockObject) GetLabels() map[string]string

GetLabels returns the object labels.

func (MockObject) GetName added in v1.1.0

func (m MockObject) GetName() string

GetName returns the object name.

func (MockObject) GetNamespace added in v1.1.0

func (m MockObject) GetNamespace() string

GetNamespace returns the object namespace.

func (MockObject) IsHealthy added in v1.1.0

func (m MockObject) IsHealthy() bool

IsHealthy returns true if the object is healthy.

type Object added in v1.1.0

type Object interface {
	Identifier
	GetLabels() map[string]string
	IsHealthy() bool
}

Object is a StorageOS object with metadata.

type ObjectKey added in v1.1.0

type ObjectKey = types.NamespacedName

ObjectKey identifies a Kubernetes Object. https://github.com/kubernetes-sigs/controller-runtime/blob/74fd294a89c65c8efc17ab92e0d2014d36e357a8/pkg/client/interfaces.go

func ObjectKeyFromObject added in v1.1.0

func ObjectKeyFromObject(obj Object) ObjectKey

ObjectKeyFromObject returns the ObjectKey given a runtime.Object.

func ObjectKeys added in v1.1.0

func ObjectKeys(objects []Object) []ObjectKey

ObjectKeys converts objects to Kubernetes ObjectKeys.

type SharedVolume

type SharedVolume struct {
	ID               string
	ServiceName      string
	PVCName          string
	Namespace        string
	InternalEndpoint string
	ExternalEndpoint string
}

SharedVolume represents a single StorageOS shared volume.

func NewSharedVolume

func NewSharedVolume(id, pvName, pvcName, pvcNamespace, intEndpoint, extEndpoint string) *SharedVolume

NewSharedVolume returns a sharedvolume object.

func (*SharedVolume) Endpoints

func (v *SharedVolume) Endpoints() *corev1.Endpoints

Endpoints returns the desired endpoints corresponding to the SharedVolume.

func (*SharedVolume) EndpointsIsEqual

func (v *SharedVolume) EndpointsIsEqual(e *corev1.Endpoints) bool

EndpointsIsEqual returns true if the endpoints provided matches the desired state of the SharedVolume.

func (*SharedVolume) EndpointsUpdate

func (v *SharedVolume) EndpointsUpdate(e *corev1.Endpoints) *corev1.Endpoints

EndpointsUpdate returns the provided endpoints, with updates to match the SharedVolume.

func (*SharedVolume) InternalAddress

func (v *SharedVolume) InternalAddress() string

InternalAddress returns the address of the intenral SharedVolume listener.

func (*SharedVolume) InternalPort

func (v *SharedVolume) InternalPort() int

InternalPort returns the port of the intenral SharedVolume listener.

func (*SharedVolume) IsEqual

func (v *SharedVolume) IsEqual(obj *SharedVolume) bool

IsEqual returns true if the given SharedVolume object is equivalent.

func (*SharedVolume) Service

func (v *SharedVolume) Service(ownerRef metav1.OwnerReference) *corev1.Service

Service returns the desired service corresponding to the SharedVolume. ClusterIP can be provided if an existing ClusterIP should be re-used. The ownerRef must be set to the volume's PersistentVolumeClaim.

func (*SharedVolume) ServiceIsEqual

func (v *SharedVolume) ServiceIsEqual(svc *corev1.Service) bool

ServiceIsEqual returns true if the service provided matches the desired state of the SharedVolume.

func (*SharedVolume) ServiceUpdate

func (v *SharedVolume) ServiceUpdate(svc *corev1.Service) *corev1.Service

ServiceUpdate returns the provided service, with updates to match the SharedVolume.

type SharedVolumeList

type SharedVolumeList []*SharedVolume

SharedVolumeList is a collection of SharedVolumes.

Directories

Path Synopsis
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