client

package
v0.0.0-...-437b0eb Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2017 License: Apache-2.0 Imports: 23 Imported by: 14

Documentation

Index

Constants

View Source
const (
	// GroupName is the name prefix for all AppController TPRs
	GroupName string = "appcontroller.k8s"

	// Version of AppController TPRs
	Version string = "v1alpha1"
)

Variables

This section is empty.

Functions

func GetConfig

func GetConfig(url string) (*rest.Config, error)

GetConfig returns restclient.Config for given URL. If url is empty, assume in-cluster config. Otherwise, return config for remote cluster.

Types

type DependenciesInterface

type DependenciesInterface interface {
	List(opts api.ListOptions) (*DependencyList, error)
	Create(*Dependency) (*Dependency, error)
	Delete(name string, opts *api.DeleteOptions) error
}

DependenciesInterface is an interface to access Dependency objects in k8s

type Dependency

type Dependency struct {
	unversioned.TypeMeta `json:",inline"`

	// Standard object metadata
	api.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

	// Depending resource name
	Parent string `json:"parent"`

	// Dependent resource name
	Child string `json:"child"`

	// Dependency metadata
	Meta map[string]string `json:"meta,omitempty"`

	// Arguments passed to dependent resource
	Args map[string]string `json:"args,omitempty"`
}

Dependency represents dependency between two resources / resource definitions

type DependencyList

type DependencyList struct {
	unversioned.TypeMeta `json:",inline"`

	// Standard list metadata.
	unversioned.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

	// List of dependencies
	Items []Dependency `json:"items" protobuf:"bytes,2,rep,name=items"`
}

DependencyList is a k8s object representing list of dependencies

type Flow

type Flow struct {
	unversioned.TypeMeta `json:",inline"`

	// Standard object metadata
	api.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

	// Construction specifies (partial) label that is used to identify dependencies that belong to
	// the construction path of the Flow (i.e. Flows can have different paths for construction and destruction).
	// For example, if we have flow->job dependency and it matches the Construction label it would mean that
	// creating a job is what the flow does. Otherwise it would mean that the job depends on
	// the the flow (i.e. it won't be created before everything, the flow consists of)
	Construction map[string]string `json:"construction,omitempty"`

	// Destruction specifies (partial) label that is used to identify dependencies that belong to the destruction path of the Flow.
	Destruction map[string]string `json:"destruction,omitempty"`

	// Exported flows can be triggered by the user (through the CLI) whereas those that are not
	// can only be triggered by other flows (including DEFAULT flow which is exported by-default)
	Exported bool `json:"exported,omitempty"`

	// Parameters that the flow can accept (i.e. valid inputs for the flow)
	Parameters map[string]FlowParameter `json:"parameters,omitempty"`

	// ReplicaSpace name allows to share replicas across flows. Replicas of different flows with the same ReplicaSpace
	// name are treated as replicas of each of those flows. Thus replicas created by one flow can be deleted by another
	// or there might be several different ways to create replicas (e.g. two flows that represent two ways to deploy
	// something, but no matter what flow was used, the result would be one more application instance (cluster node)
	// represented by created replica
	// By default, replica space name equal to the flow name
	ReplicaSpace string `json:"replicaSpace,omitempty"`
}

Flow is a pseudo-resource (i.e. it looks like resource but cannot be created in k8s, but can be wrapped with ResourceDefinition), that represents the scope and parameters of the named reusable subgraph.

type FlowParameter

type FlowParameter struct {
	// Optional default value for the parameter. If the declared parameter has nil Default then the argument for
	// this parameter becomes mandatory (i.e. it MUST be provided)
	Default *string `json:"default,omitempty"`

	// Description of the parameter (help string)
	Description string `json:"description,omitempty"`
}

FlowParameter represents declaration of a parameter that flow can accept (its description, default value etc)

type Interface

type Interface interface {
	ConfigMaps() corev1.ConfigMapInterface
	Secrets() corev1.SecretInterface
	ServiceAccounts() corev1.ServiceAccountInterface
	Pods() corev1.PodInterface
	Jobs() batchv1.JobInterface
	Services() corev1.ServiceInterface
	ReplicaSets() v1beta1.ReplicaSetInterface
	StatefulSets() appsbeta1.StatefulSetInterface
	PetSets() v1alpha1.PetSetInterface
	DaemonSets() v1beta1.DaemonSetInterface
	Deployments() v1beta1.DeploymentInterface
	PersistentVolumeClaims() corev1.PersistentVolumeClaimInterface

	Dependencies() DependenciesInterface
	ResourceDefinitions() ResourceDefinitionsInterface
	Replicas() ReplicasInterface

	IsEnabled(version unversioned.GroupVersion) bool
	Namespace() string
}

Interface is as an interface for k8s clients. It expands native k8s client interface.

func New

func New(url string) (Interface, error)

New returns client k8s api server under given url

func NewClient

func NewClient(
	clientset kubernetes.Interface,
	alphaApps v1alpha1.AppsInterface,
	dependencies DependenciesInterface,
	resourceDefinitions ResourceDefinitionsInterface,
	replicas ReplicasInterface,
	namespace string,
	apiVersions *unversioned.APIGroupList) Interface

NewClient creates k8s client

func NewForNamespace

func NewForNamespace(url string, namespace string) (Interface, error)

NewForNamespace returns client k8s api server under given url. The client will use given namespace instead of getting the namespace from environment variable

type Replica

type Replica struct {
	unversioned.TypeMeta `json:",inline"`

	// Standard object metadata
	api.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

	// flow name
	FlowName string `json:"flowName,omitempty"`

	// replica-space name
	ReplicaSpace string `json:"replicaSpace,omitempty"`

	// AC sets this field to true after deployment of the dependency graph for this replica
	Deployed bool `json:"deployed,omitempty"`
}

Replica resource represents one instance of the replicated flow. Since the only difference between replicas is their $AC_NAME value which is replica name this resource is only needed to generate unique name for each replica and make those name persistent so that we could do CRUD on the list of replica names

func (*Replica) ReplicaName

func (r *Replica) ReplicaName() string

ReplicaName returns replica name (which then goes into $AC_NAME var) encoded in Replica k8s object name this is done in order to take advantage of GenerateName field which makes k8s generate unique name that cannot collide with other replicas

type ReplicaList

type ReplicaList struct {
	unversioned.TypeMeta `json:",inline"`

	// Standard list metadata.
	unversioned.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

	Items []Replica `json:"items" protobuf:"bytes,2,rep,name=items"`
}

ReplicaList is a list of replicas

type ReplicasInterface

type ReplicasInterface interface {
	List(opts api.ListOptions) (*ReplicaList, error)
	Create(replica *Replica) (*Replica, error)
	Delete(name string) error
	Update(replica *Replica) error
}

ReplicasInterface is an interface to access flow replica objects

type ResourceDefinition

type ResourceDefinition struct {
	unversioned.TypeMeta `json:",inline"`

	// Standard object metadata
	api.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

	Meta map[string]interface{} `json:"meta,omitempty"`

	//TODO: add other object types
	Pod                   *v1.Pod                   `json:"pod,omitempty"`
	Job                   *batchv1.Job              `json:"job,omitempty"`
	Service               *v1.Service               `json:"service,omitempty"`
	ReplicaSet            *v1beta1.ReplicaSet       `json:"replicaset,omitempty"`
	StatefulSet           *appsbeta1.StatefulSet    `json:"statefulset,omitempty"`
	ServiceAccount        *v1.ServiceAccount        `json:"serviceaccount,omitempty"`
	PetSet                *v1alpha1.PetSet          `json:"petset,omitempty"`
	DaemonSet             *v1beta1.DaemonSet        `json:"daemonset,omitempty"`
	ConfigMap             *v1.ConfigMap             `json:"configmap,omitempty"`
	Secret                *v1.Secret                `json:"secret,omitempty"`
	Deployment            *v1beta1.Deployment       `json:"deployment, omitempty"`
	PersistentVolumeClaim *v1.PersistentVolumeClaim `json:"persistentvolumeclaim, omitempty"`
	Flow                  *Flow                     `json:"flow, omitempty"`
}

ResourceDefinition represents template for one of supported k8s resource types

func (*ResourceDefinition) GetObjectKind

func (r *ResourceDefinition) GetObjectKind() unversioned.ObjectKind

GetObjectKind returns type header of ResourceDefinition object

func (*ResourceDefinition) GetObjectMeta

func (r *ResourceDefinition) GetObjectMeta() meta.Object

GetObjectMeta returns metadata of ResourceDefinition object

type ResourceDefinitionList

type ResourceDefinitionList struct {
	unversioned.TypeMeta `json:",inline"`

	// Standard list metadata.
	unversioned.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

	Items []ResourceDefinition `json:"items"`
}

ResourceDefinitionList is a k8s object representing list of resource definitions

type ResourceDefinitionsInterface

type ResourceDefinitionsInterface interface {
	Create(*ResourceDefinition) (*ResourceDefinition, error)
	List(opts api.ListOptions) (*ResourceDefinitionList, error)
	Delete(name string, opts *api.DeleteOptions) error
}

ResourceDefinitionsInterface is an interface to access Definition objects in k8s

Directories

Path Synopsis
petsets
apis/apps/install
Package install installs the apps API group, making it available as an option to all of the API encoding/decoding machinery.
Package install installs the apps API group, making it available as an option to all of the API encoding/decoding machinery.
apis/apps/v1alpha1
Package v1alpha1 is a generated protocol buffer package.
Package v1alpha1 is a generated protocol buffer package.
typed/apps/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/apps/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.

Jump to

Keyboard shortcuts

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