registry

package
v0.0.0-...-54d1e7e Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2014 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetServiceEnvironmentVariables

func GetServiceEnvironmentVariables(registry ServiceRegistry, machine string) ([]EnvVar, error)

GetServiceEnvironmentVariables populates a list of environment variables that are use in the container environment to get access to services.

func LabelMatch

func LabelMatch(pod Pod, queryKey, queryValue string) bool

LabelMatch tests to see if a Pod's labels map contains 'key' mapping to 'value'

func LabelsMatch

func LabelsMatch(pod Pod, labelQuery *map[string]string) bool

LabelMatch tests to see if a Pod's labels map contains all key/value pairs in 'labelQuery'

func MakeControllerRegistryStorage

func MakeControllerRegistryStorage(registry ControllerRegistry) apiserver.RESTStorage

func MakePodRegistryStorage

func MakePodRegistryStorage(registry PodRegistry, containerInfo client.ContainerInfo, scheduler Scheduler) apiserver.RESTStorage

func MakeServiceRegistryStorage

func MakeServiceRegistryStorage(registry ServiceRegistry) apiserver.RESTStorage

Types

type BasicManifestFactory

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

func (*BasicManifestFactory) MakeManifest

func (b *BasicManifestFactory) MakeManifest(machine string, pod Pod) (ContainerManifest, error)

type ControllerRegistry

type ControllerRegistry interface {
	ListControllers() ([]api.ReplicationController, error)
	GetController(controllerId string) (*api.ReplicationController, error)
	CreateController(controller api.ReplicationController) error
	UpdateController(controller api.ReplicationController) error
	DeleteController(controllerId string) error
}

ControllerRegistry is an interface for things that know how to store Controllers

type ControllerRegistryStorage

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

Implementation of RESTStorage for the api server.

func (*ControllerRegistryStorage) Create

func (storage *ControllerRegistryStorage) Create(controller interface{}) error

func (*ControllerRegistryStorage) Delete

func (storage *ControllerRegistryStorage) Delete(id string) error

func (*ControllerRegistryStorage) Extract

func (storage *ControllerRegistryStorage) Extract(body string) (interface{}, error)

func (*ControllerRegistryStorage) Get

func (storage *ControllerRegistryStorage) Get(id string) (interface{}, error)

func (*ControllerRegistryStorage) List

func (storage *ControllerRegistryStorage) List(*url.URL) (interface{}, error)

func (*ControllerRegistryStorage) Update

func (storage *ControllerRegistryStorage) Update(controller interface{}) error

type EndpointController

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

func MakeEndpointController

func MakeEndpointController(serviceRegistry ServiceRegistry, podRegistry PodRegistry) *EndpointController

func (*EndpointController) SyncServiceEndpoints

func (e *EndpointController) SyncServiceEndpoints() error

type EtcdClient

type EtcdClient interface {
	AddChild(key, data string, ttl uint64) (*etcd.Response, error)
	Get(key string, sort, recursive bool) (*etcd.Response, error)
	Set(key, value string, ttl uint64) (*etcd.Response, error)
	Create(key, value string, ttl uint64) (*etcd.Response, error)
	Delete(key string, recursive bool) (*etcd.Response, error)
	// I'd like to use directional channels here (e.g. <-chan) but this interface mimics
	// the etcd client interface which doesn't, and it doesn't seem worth it to wrap the api.
	Watch(prefix string, waitIndex uint64, recursive bool, receiver chan *etcd.Response, stop chan bool) (*etcd.Response, error)
}

EtcdClient is an injectable interface for testing.

type EtcdRegistry

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

EtcdRegistry is an implementation of both ControllerRegistry and PodRegistry which is backed with etcd.

func MakeEtcdRegistry

func MakeEtcdRegistry(client EtcdClient, machines []string) *EtcdRegistry

MakeEtcdRegistry creates an etcd registry. 'client' is the connection to etcd 'machines' is the list of machines 'scheduler' is the scheduling algorithm to use.

func MakeTestEtcdRegistry

func MakeTestEtcdRegistry(client EtcdClient, machines []string) *EtcdRegistry

func (*EtcdRegistry) CreateController

func (registry *EtcdRegistry) CreateController(controller ReplicationController) error

func (*EtcdRegistry) CreatePod

func (registry *EtcdRegistry) CreatePod(machineIn string, pod Pod) error

func (*EtcdRegistry) CreateService

func (registry *EtcdRegistry) CreateService(svc Service) error

func (*EtcdRegistry) DeleteController

func (registry *EtcdRegistry) DeleteController(controllerID string) error

func (*EtcdRegistry) DeletePod

func (registry *EtcdRegistry) DeletePod(podID string) error

func (*EtcdRegistry) DeleteService

func (registry *EtcdRegistry) DeleteService(name string) error

func (*EtcdRegistry) GetController

func (registry *EtcdRegistry) GetController(controllerID string) (*ReplicationController, error)

func (*EtcdRegistry) GetPod

func (registry *EtcdRegistry) GetPod(podID string) (*Pod, error)

func (*EtcdRegistry) GetService

func (registry *EtcdRegistry) GetService(name string) (*Service, error)

func (*EtcdRegistry) ListControllers

func (registry *EtcdRegistry) ListControllers() ([]ReplicationController, error)

func (*EtcdRegistry) ListPods

func (registry *EtcdRegistry) ListPods(query *map[string]string) ([]Pod, error)

func (*EtcdRegistry) ListServices

func (registry *EtcdRegistry) ListServices() (ServiceList, error)

func (*EtcdRegistry) UpdateController

func (registry *EtcdRegistry) UpdateController(controller ReplicationController) error

func (*EtcdRegistry) UpdateEndpoints

func (registry *EtcdRegistry) UpdateEndpoints(e Endpoints) error

func (*EtcdRegistry) UpdatePod

func (registry *EtcdRegistry) UpdatePod(pod Pod) error

func (*EtcdRegistry) UpdateService

func (registry *EtcdRegistry) UpdateService(svc Service) error

type EtcdResponseWithError

type EtcdResponseWithError struct {
	R *etcd.Response
	E error
}

type FakeEtcdClient

type FakeEtcdClient struct {
	Data map[string]EtcdResponseWithError
	// contains filtered or unexported fields
}

func MakeFakeEtcdClient

func MakeFakeEtcdClient(t *testing.T) *FakeEtcdClient

func (*FakeEtcdClient) AddChild

func (f *FakeEtcdClient) AddChild(key, data string, ttl uint64) (*etcd.Response, error)

func (*FakeEtcdClient) Create

func (f *FakeEtcdClient) Create(key, value string, ttl uint64) (*etcd.Response, error)

func (*FakeEtcdClient) Delete

func (f *FakeEtcdClient) Delete(key string, recursive bool) (*etcd.Response, error)

func (*FakeEtcdClient) Get

func (f *FakeEtcdClient) Get(key string, sort, recursive bool) (*etcd.Response, error)

func (*FakeEtcdClient) Set

func (f *FakeEtcdClient) Set(key, value string, ttl uint64) (*etcd.Response, error)

func (*FakeEtcdClient) Watch

func (f *FakeEtcdClient) Watch(prefix string, waitIndex uint64, recursive bool, receiver chan *etcd.Response, stop chan bool) (*etcd.Response, error)

type FirstFitScheduler

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

func (*FirstFitScheduler) Schedule

func (s *FirstFitScheduler) Schedule(pod Pod) (string, error)

type ManifestFactory

type ManifestFactory interface {
	// Make a container object for a given pod, given the machine that the pod is running on.
	MakeManifest(machine string, pod Pod) (ContainerManifest, error)
}

type MemoryRegistry

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

An implementation of PodRegistry and ControllerRegistry that is backed by memory Mainly used for testing.

func MakeMemoryRegistry

func MakeMemoryRegistry() *MemoryRegistry

func (*MemoryRegistry) CreateController

func (registry *MemoryRegistry) CreateController(controller ReplicationController) error

func (*MemoryRegistry) CreatePod

func (registry *MemoryRegistry) CreatePod(machine string, pod Pod) error

func (*MemoryRegistry) CreateService

func (registry *MemoryRegistry) CreateService(svc Service) error

func (*MemoryRegistry) DeleteController

func (registry *MemoryRegistry) DeleteController(controllerId string) error

func (*MemoryRegistry) DeletePod

func (registry *MemoryRegistry) DeletePod(podID string) error

func (*MemoryRegistry) DeleteService

func (registry *MemoryRegistry) DeleteService(name string) error

func (*MemoryRegistry) GetController

func (registry *MemoryRegistry) GetController(controllerID string) (*ReplicationController, error)

func (*MemoryRegistry) GetPod

func (registry *MemoryRegistry) GetPod(podID string) (*Pod, error)

func (*MemoryRegistry) GetService

func (registry *MemoryRegistry) GetService(name string) (*Service, error)

func (*MemoryRegistry) ListControllers

func (registry *MemoryRegistry) ListControllers() ([]ReplicationController, error)

func (*MemoryRegistry) ListPods

func (registry *MemoryRegistry) ListPods(labelQuery *map[string]string) ([]Pod, error)

func (*MemoryRegistry) ListServices

func (registry *MemoryRegistry) ListServices() (ServiceList, error)

func (*MemoryRegistry) UpdateController

func (registry *MemoryRegistry) UpdateController(controller ReplicationController) error

func (*MemoryRegistry) UpdateEndpoints

func (registry *MemoryRegistry) UpdateEndpoints(e Endpoints) error

func (*MemoryRegistry) UpdatePod

func (registry *MemoryRegistry) UpdatePod(pod Pod) error

func (*MemoryRegistry) UpdateService

func (registry *MemoryRegistry) UpdateService(svc Service) error

type MockServiceRegistry

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

func (*MockServiceRegistry) CreateService

func (m *MockServiceRegistry) CreateService(svc Service) error

func (*MockServiceRegistry) DeleteService

func (m *MockServiceRegistry) DeleteService(name string) error

func (*MockServiceRegistry) GetService

func (m *MockServiceRegistry) GetService(name string) (*Service, error)

func (*MockServiceRegistry) ListServices

func (m *MockServiceRegistry) ListServices() (ServiceList, error)

func (*MockServiceRegistry) UpdateEndpoints

func (m *MockServiceRegistry) UpdateEndpoints(e Endpoints) error

func (*MockServiceRegistry) UpdateService

func (m *MockServiceRegistry) UpdateService(svc Service) error

type PodControlInterface

type PodControlInterface interface {
	// contains filtered or unexported methods
}

An interface that knows how to add or delete pods created as an interface to allow testing.

type PodRegistry

type PodRegistry interface {
	// ListPods obtains a list of pods that match query.
	// Query may be nil in which case all pods are returned.
	ListPods(query *map[string]string) ([]api.Pod, error)
	// Get a specific pod
	GetPod(podID string) (*api.Pod, error)
	// Create a pod based on a specification, schedule it onto a specific machine.
	CreatePod(machine string, pod api.Pod) error
	// Update an existing pod
	UpdatePod(pod api.Pod) error
	// Delete an existing pod
	DeletePod(podID string) error
}

PodRegistry is an interface implemented by things that know how to store Pod objects

type PodRegistryStorage

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

PodRegistryStorage implements the RESTStorage interface in terms of a PodRegistry

func (*PodRegistryStorage) Create

func (storage *PodRegistryStorage) Create(pod interface{}) error

func (*PodRegistryStorage) Delete

func (storage *PodRegistryStorage) Delete(id string) error

func (*PodRegistryStorage) Extract

func (storage *PodRegistryStorage) Extract(body string) (interface{}, error)

func (*PodRegistryStorage) Get

func (storage *PodRegistryStorage) Get(id string) (interface{}, error)

func (*PodRegistryStorage) List

func (storage *PodRegistryStorage) List(url *url.URL) (interface{}, error)

func (*PodRegistryStorage) Update

func (storage *PodRegistryStorage) Update(pod interface{}) error

type RandomScheduler

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

RandomScheduler choses machines uniformly at random.

func (*RandomScheduler) Schedule

func (s *RandomScheduler) Schedule(pod Pod) (string, error)

type RealPodControl

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

type ReplicationManager

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

ReplicationManager is responsible for synchronizing ReplicationController objects stored in etcd with actual running pods. TODO: Remove the etcd dependency and re-factor in terms of a generic watch interface

func MakeReplicationManager

func MakeReplicationManager(etcdClient *etcd.Client, kubeClient client.ClientInterface) *ReplicationManager

func (*ReplicationManager) Synchronize

func (rm *ReplicationManager) Synchronize()

func (*ReplicationManager) WatchControllers

func (rm *ReplicationManager) WatchControllers()

type RoundRobinScheduler

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

RoundRobinScheduler chooses machines in order.

func (*RoundRobinScheduler) Schedule

func (s *RoundRobinScheduler) Schedule(pod Pod) (string, error)

type Scheduler

type Scheduler interface {
	Schedule(Pod) (string, error)
}

Scheduler is an interface implemented by things that know how to schedule pods onto machines.

func MakeFirstFitScheduler

func MakeFirstFitScheduler(machines []string, registry PodRegistry, random *rand.Rand) Scheduler

func MakeRandomScheduler

func MakeRandomScheduler(machines []string, random rand.Rand) Scheduler

func MakeRoundRobinScheduler

func MakeRoundRobinScheduler(machines []string) Scheduler

type ServiceRegistry

type ServiceRegistry interface {
	ListServices() (ServiceList, error)
	CreateService(svc Service) error
	GetService(name string) (*Service, error)
	DeleteService(name string) error
	UpdateService(svc Service) error
	UpdateEndpoints(e Endpoints) error
}

type ServiceRegistryStorage

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

func (*ServiceRegistryStorage) Create

func (sr *ServiceRegistryStorage) Create(obj interface{}) error

func (*ServiceRegistryStorage) Delete

func (sr *ServiceRegistryStorage) Delete(id string) error

func (*ServiceRegistryStorage) Extract

func (sr *ServiceRegistryStorage) Extract(body string) (interface{}, error)

func (*ServiceRegistryStorage) Get

func (sr *ServiceRegistryStorage) Get(id string) (interface{}, error)

func (*ServiceRegistryStorage) List

func (sr *ServiceRegistryStorage) List(*url.URL) (interface{}, error)

func (*ServiceRegistryStorage) Update

func (sr *ServiceRegistryStorage) Update(obj interface{}) error

Jump to

Keyboard shortcuts

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