kubernetes: github.com/simon3z/kubernetes/pkg/proxy/config Index | Files

package config

import "github.com/simon3z/kubernetes/pkg/proxy/config"

Package config provides decoupling between various configuration sources (etcd, files,...) and the pieces that actually care about them (loadbalancer, proxy). Config takes 1 or more configuration sources and allows for incremental (add/remove) and full replace (set) changes from each of the sources, then creates a union of the configuration and provides a unified view for both service handlers as well as endpoint handlers. There is no attempt to resolve conflicts of any sort. Basic idea is that each configuration source gets a channel from the Config service and pushes updates to it via that channel. Config then keeps track of incremental & replace changes and distributes them to listeners as appropriate.

Index

Package Files

api.go config.go doc.go etcd.go

type ConfigSourceEtcd Uses

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

ConfigSourceEtcd communicates with a etcd via the client, and sends the change notification of services and endpoints to the specified channels.

func NewConfigSourceEtcd Uses

func NewConfigSourceEtcd(client *etcd.Client, serviceChannel chan ServiceUpdate, endpointsChannel chan EndpointsUpdate) ConfigSourceEtcd

NewConfigSourceEtcd creates a new ConfigSourceEtcd and immediately runs the created ConfigSourceEtcd in a goroutine.

func (ConfigSourceEtcd) GetEndpoints Uses

func (s ConfigSourceEtcd) GetEndpoints(namespace, service string) (api.Endpoints, error)

GetEndpoints finds the list of endpoints of the service from etcd.

func (ConfigSourceEtcd) GetServices Uses

func (s ConfigSourceEtcd) GetServices() ([]api.Service, []api.Endpoints, error)

GetServices finds the list of services and their endpoints from etcd. This operation is akin to a set a known good at regular intervals.

func (ConfigSourceEtcd) ProcessChange Uses

func (s ConfigSourceEtcd) ProcessChange(response *etcd.Response)

func (ConfigSourceEtcd) ProcessEndpointResponse Uses

func (s ConfigSourceEtcd) ProcessEndpointResponse(response *etcd.Response)

func (ConfigSourceEtcd) Run Uses

func (s ConfigSourceEtcd) Run()

Run begins watching for new services and their endpoints on etcd.

func (ConfigSourceEtcd) WatchForChanges Uses

func (s ConfigSourceEtcd) WatchForChanges()

type EndpointsConfig Uses

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

EndpointsConfig tracks a set of endpoints configurations. It accepts "set", "add" and "remove" operations of endpoints via channels, and invokes registered handlers on change.

func NewEndpointsConfig Uses

func NewEndpointsConfig() *EndpointsConfig

NewEndpointsConfig creates a new EndpointsConfig. It immediately runs the created EndpointsConfig.

func (*EndpointsConfig) Channel Uses

func (c *EndpointsConfig) Channel(source string) chan EndpointsUpdate

func (*EndpointsConfig) Config Uses

func (c *EndpointsConfig) Config() []api.Endpoints

func (*EndpointsConfig) RegisterHandler Uses

func (c *EndpointsConfig) RegisterHandler(handler EndpointsConfigHandler)

type EndpointsConfigHandler Uses

type EndpointsConfigHandler interface {
    // OnUpdate gets called when endpoints configuration is changed for a given
    // service on any of the configuration sources. An example is when a new
    // service comes up, or when containers come up or down for an existing service.
    OnUpdate(endpoints []api.Endpoints)
}

EndpointsConfigHandler is an abstract interface of objects which receive update notifications for the set of endpoints.

type EndpointsUpdate Uses

type EndpointsUpdate struct {
    Endpoints []api.Endpoints
    Op        Operation
}

EndpointsUpdate describes an operation of endpoints, sent on the channel. You can add or remove single endpoints by sending an array of size one and Op == ADD|REMOVE. For setting the state of the system to a given state for this source configuration, set Endpoints as desired and Op to SET, which will reset the system state to that specified in this operation for this source channel. To remove all endpoints, set Endpoints to empty array and Op to SET

type EndpointsWatcher Uses

type EndpointsWatcher interface {
    List(label labels.Selector) (*api.EndpointsList, error)
    Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
}

EndpointsWatcher is capable of listing and watching for changes to endpoints across ALL namespaces

type Operation Uses

type Operation int

Operation is a type of operation of services or endpoints.

const (
    SET Operation = iota
    ADD
    REMOVE
)

These are the available operation types.

type ServiceConfig Uses

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

ServiceConfig tracks a set of service configurations. It accepts "set", "add" and "remove" operations of services via channels, and invokes registered handlers on change.

func NewServiceConfig Uses

func NewServiceConfig() *ServiceConfig

NewServiceConfig creates a new ServiceConfig. It immediately runs the created ServiceConfig.

func (*ServiceConfig) Channel Uses

func (c *ServiceConfig) Channel(source string) chan ServiceUpdate

func (*ServiceConfig) Config Uses

func (c *ServiceConfig) Config() []api.Service

func (*ServiceConfig) RegisterHandler Uses

func (c *ServiceConfig) RegisterHandler(handler ServiceConfigHandler)

type ServiceConfigHandler Uses

type ServiceConfigHandler interface {
    // OnUpdate gets called when a configuration has been changed by one of the sources.
    // This is the union of all the configuration sources.
    OnUpdate(services []api.Service)
}

ServiceConfigHandler is an abstract interface of objects which receive update notifications for the set of services.

type ServiceUpdate Uses

type ServiceUpdate struct {
    Services []api.Service
    Op       Operation
}

ServiceUpdate describes an operation of services, sent on the channel. You can add or remove single services by sending an array of size one and Op == ADD|REMOVE. For setting the state of the system to a given state for this source configuration, set Services as desired and Op to SET, which will reset the system state to that specified in this operation for this source channel. To remove all services, set Services to empty array and Op to SET

type ServicesWatcher Uses

type ServicesWatcher interface {
    List(label labels.Selector) (*api.ServiceList, error)
    Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
}

TODO: to use Reflector, need to change the ServicesWatcher to a generic ListerWatcher. ServicesWatcher is capable of listing and watching for changes to services across ALL namespaces

type SourceAPI Uses

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

SourceAPI implements a configuration source for services and endpoints that uses the client watch API to efficiently detect changes.

func NewSourceAPI Uses

func NewSourceAPI(servicesWatcher ServicesWatcher, endpointsWatcher EndpointsWatcher, period time.Duration, services chan<- ServiceUpdate, endpoints chan<- EndpointsUpdate) *SourceAPI

NewSourceAPI creates a config source that watches for changes to the services and endpoints.

Package config imports 16 packages (graph). Updated 2018-01-06. Refresh now. Tools for package owners.