registry

package
v0.0.0-...-a541f19 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2023 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(task Task, queryKey, queryValue string) bool

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

func LabelsMatch

func LabelsMatch(task Task, labelQuery *map[string]string) bool

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

func MakeControllerRegistryStorage

func MakeControllerRegistryStorage(registry ControllerRegistry) apiserver.RESTStorage

func MakeServiceRegistryStorage

func MakeServiceRegistryStorage(registry ServiceRegistry) apiserver.RESTStorage

func MakeTaskRegistryStorage

func MakeTaskRegistryStorage(registry TaskRegistry, containerInfo client.ContainerInfo, scheduler Scheduler) apiserver.RESTStorage

Types

type BasicManifestFactory

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

func (*BasicManifestFactory) MakeManifest

func (b *BasicManifestFactory) MakeManifest(machine string, task Task) (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, taskRegistry TaskRegistry) *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 TaskRegistry 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) CreateService

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

func (*EtcdRegistry) CreateTask

func (registry *EtcdRegistry) CreateTask(machineIn string, task Task) error

func (*EtcdRegistry) DeleteController

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

func (*EtcdRegistry) DeleteService

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

func (*EtcdRegistry) DeleteTask

func (registry *EtcdRegistry) DeleteTask(taskID string) error

func (*EtcdRegistry) GetController

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

func (*EtcdRegistry) GetService

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

func (*EtcdRegistry) GetTask

func (registry *EtcdRegistry) GetTask(taskID string) (*Task, error)

func (*EtcdRegistry) ListControllers

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

func (*EtcdRegistry) ListServices

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

func (*EtcdRegistry) ListTasks

func (registry *EtcdRegistry) ListTasks(query *map[string]string) ([]Task, error)

func (*EtcdRegistry) UpdateController

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

func (*EtcdRegistry) UpdateEndpoints

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

func (*EtcdRegistry) UpdateService

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

func (*EtcdRegistry) UpdateTask

func (registry *EtcdRegistry) UpdateTask(task Task) 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(task Task) (string, error)

type ManifestFactory

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

type MemoryRegistry

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

An implementation of TaskRegistry 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) CreateService

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

func (*MemoryRegistry) CreateTask

func (registry *MemoryRegistry) CreateTask(machine string, task Task) error

func (*MemoryRegistry) DeleteController

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

func (*MemoryRegistry) DeleteService

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

func (*MemoryRegistry) DeleteTask

func (registry *MemoryRegistry) DeleteTask(taskID string) error

func (*MemoryRegistry) GetController

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

func (*MemoryRegistry) GetService

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

func (*MemoryRegistry) GetTask

func (registry *MemoryRegistry) GetTask(taskID string) (*Task, error)

func (*MemoryRegistry) ListControllers

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

func (*MemoryRegistry) ListServices

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

func (*MemoryRegistry) ListTasks

func (registry *MemoryRegistry) ListTasks(labelQuery *map[string]string) ([]Task, error)

func (*MemoryRegistry) UpdateController

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

func (*MemoryRegistry) UpdateEndpoints

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

func (*MemoryRegistry) UpdateService

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

func (*MemoryRegistry) UpdateTask

func (registry *MemoryRegistry) UpdateTask(task Task) 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 RandomScheduler

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

RandomScheduler choses machines uniformly at random.

func (*RandomScheduler) Schedule

func (s *RandomScheduler) Schedule(task Task) (string, error)

type RealTaskControl

type RealTaskControl 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 tasks. 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(task Task) (string, error)

type Scheduler

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

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

func MakeFirstFitScheduler

func MakeFirstFitScheduler(machines []string, registry TaskRegistry) 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

type TaskControlInterface

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

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

type TaskRegistry

type TaskRegistry interface {
	// ListTasks obtains a list of tasks that match query.
	// Query may be nil in which case all tasks are returned.
	ListTasks(query *map[string]string) ([]api.Task, error)
	// Get a specific task
	GetTask(taskId string) (*api.Task, error)
	// Create a task based on a specification, schedule it onto a specific machine.
	CreateTask(machine string, task api.Task) error
	// Update an existing task
	UpdateTask(task api.Task) error
	// Delete an existing task
	DeleteTask(taskId string) error
}

TaskRegistry is an interface implemented by things that know how to store Task objects

type TaskRegistryStorage

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

TaskRegistryStorage implements the RESTStorage interface in terms of a TaskRegistry

func (*TaskRegistryStorage) Create

func (storage *TaskRegistryStorage) Create(task interface{}) error

func (*TaskRegistryStorage) Delete

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

func (*TaskRegistryStorage) Extract

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

func (*TaskRegistryStorage) Get

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

func (*TaskRegistryStorage) List

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

func (*TaskRegistryStorage) Update

func (storage *TaskRegistryStorage) Update(task interface{}) error

Jump to

Keyboard shortcuts

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