istio: Index | Files

package controller

import ""


Package Files

controller.go endpoint_builder.go endpointcontroller.go endpoints.go endpointslice.go fake.go multicluster.go namespacecontroller.go network.go pod.go util.go


const (
    // NodeRegionLabel is the well-known label for kubernetes node region in beta
    NodeRegionLabel = ""
    // NodeZoneLabel is the well-known label for kubernetes node zone in beta
    NodeZoneLabel = ""
    // NodeRegionLabelGA is the well-known label for kubernetes node region in ga
    NodeRegionLabelGA = ""
    // NodeZoneLabelGA is the well-known label for kubernetes node zone in ga
    NodeZoneLabelGA = ""
    // IstioNamespace used by default for Istio cluster-wide installation
    IstioNamespace = "istio-system"

    // IstioGatewayPortLabel overrides the default 15443 value to use for a multi-network gateway's port
    // TODO move gatewayPort to api repo
    IstioGatewayPortLabel = ""
    // DefaultNetworkGatewayPort is the port used by default for cross-network traffic if not otherwise specified
    // by meshNetworks or ""
    DefaultNetworkGatewayPort = 15443
const (
    // Every NamespaceResyncPeriod, namespaceUpdated() will be invoked
    // for every namespace. This value must be configured so Citadel
    // can update its CA certificate in a ConfigMap in every namespace.
    NamespaceResyncPeriod = time.Second * 60
    // The name of the ConfigMap in each namespace storing the root cert of non-Kube CA.
    CACertNamespaceConfigMap = "istio-ca-root-cert"


var EndpointModeNames = map[EndpointMode]string{
    EndpointsOnly:     "EndpointsOnly",
    EndpointSliceOnly: "EndpointSliceOnly",

func FindPort Uses

func FindPort(pod *v1.Pod, svcPort *v1.ServicePort) (int, error)

Forked from Kubernetes FindPort locates the container port for the given pod and portName. If the targetPort is a number, use that. If the targetPort is a string, look that string up in all named ports in all containers in the target pod. If no match is found, fail.

func NewFakeControllerWithOptions Uses

func NewFakeControllerWithOptions(opts FakeControllerOptions) (*FakeController, *FakeXdsUpdater)

type Controller Uses

type Controller struct {
    // contains filtered or unexported fields

Controller is a collection of synchronized resource watchers Caches are thread-safe

func NewController Uses

func NewController(kubeClient kubelib.Client, options Options) *Controller

NewController creates a new Kubernetes controller Created by bootstrap and multicluster (see secretcontroler).

func (*Controller) AppendServiceHandler Uses

func (c *Controller) AppendServiceHandler(f func(*model.Service, model.Event))

AppendServiceHandler implements a service catalog operation

func (*Controller) AppendWorkloadHandler Uses

func (c *Controller) AppendWorkloadHandler(f func(*model.WorkloadInstance, model.Event))

AppendWorkloadHandler implements a service catalog operation

func (*Controller) Cleanup Uses

func (c *Controller) Cleanup() error

func (*Controller) Cluster Uses

func (c *Controller) Cluster() string

func (*Controller) GetIstioServiceAccounts Uses

func (c *Controller) GetIstioServiceAccounts(svc *model.Service, ports []int) []string

GetIstioServiceAccounts returns the Istio service accounts running a serivce hostname. Each service account is encoded according to the SPIFFE VSID spec. For example, a service account named "bar" in namespace "foo" is encoded as "spiffe://cluster.local/ns/foo/sa/bar".

func (*Controller) GetProxyServiceInstances Uses

func (c *Controller) GetProxyServiceInstances(proxy *model.Proxy) []*model.ServiceInstance

GetProxyServiceInstances returns service instances co-located with a given proxy TODO: this code does not return k8s service instances when the proxy's IP is a workload entry To tackle this, we need a ip2instance map like what we have in service entry.

func (*Controller) GetProxyWorkloadLabels Uses

func (c *Controller) GetProxyWorkloadLabels(proxy *model.Proxy) labels.Collection

func (*Controller) GetService Uses

func (c *Controller) GetService(hostname host.Name) (*model.Service, error)

GetService implements a service catalog operation by hostname specified.

func (*Controller) HasSynced Uses

func (c *Controller) HasSynced() bool

HasSynced returns true after the initial state synchronization

func (*Controller) InstancesByPort Uses

func (c *Controller) InstancesByPort(svc *model.Service, reqSvcPort int, labelsList labels.Collection) []*model.ServiceInstance

InstancesByPort implements a service catalog operation

func (*Controller) NetworkGateways Uses

func (c *Controller) NetworkGateways() map[string][]*model.Gateway

func (*Controller) Provider Uses

func (c *Controller) Provider() serviceregistry.ProviderID

func (*Controller) Run Uses

func (c *Controller) Run(stop <-chan struct{})

Run all controllers until a signal is received

func (*Controller) Services Uses

func (c *Controller) Services() ([]*model.Service, error)

Services implements a service catalog operation

func (*Controller) Stop Uses

func (c *Controller) Stop()

Stop the controller. Only for tests, to simplify the code (defer c.Stop())

func (*Controller) SyncAll Uses

func (c *Controller) SyncAll() error

SyncAll syncs all the objects node->service->pod->endpoint in order TODO: sync same kind of objects in parallel This can cause great performance cost in multi clusters scenario. Maybe just sync the cache and trigger one push at last.

func (*Controller) WorkloadInstanceHandler Uses

func (c *Controller) WorkloadInstanceHandler(si *model.WorkloadInstance, event model.Event)

WorkloadInstanceHandler defines the handler for service instances generated by other registries

type EndpointBuilder Uses

type EndpointBuilder struct {
    // contains filtered or unexported fields

A stateful IstioEndpoint builder with metadata used to build IstioEndpoint

func NewEndpointBuilder Uses

func NewEndpointBuilder(c controllerInterface, pod *v1.Pod) *EndpointBuilder

func NewEndpointBuilderFromMetadata Uses

func NewEndpointBuilderFromMetadata(c controllerInterface, proxy *model.Proxy) *EndpointBuilder

type EndpointMode Uses

type EndpointMode int

EndpointMode decides what source to use to get endpoint information

const (
    // EndpointsOnly type will use only Kubernetes Endpoints
    EndpointsOnly EndpointMode = iota

    // EndpointSliceOnly type will use only Kubernetes EndpointSlices

func (EndpointMode) String Uses

func (m EndpointMode) String() string

type FakeController Uses

type FakeController struct {

type FakeControllerOptions Uses

type FakeControllerOptions struct {
    Client            kubelib.Client
    NetworksWatcher   mesh.NetworksWatcher
    ServiceHandler    func(service *model.Service, event model.Event)
    Mode              EndpointMode
    ClusterID         string
    WatchedNamespaces string
    DomainSuffix      string
    XDSUpdater        model.XDSUpdater

type FakeXdsEvent Uses

type FakeXdsEvent struct {
    // Type of the event
    Type string

    // The id of the event
    ID  string

    // The endpoints associated with an EDS push if any
    Endpoints []*model.IstioEndpoint

FakeXdsEvent is used to watch XdsEvents

type FakeXdsUpdater Uses

type FakeXdsUpdater struct {
    // Events tracks notifications received by the updater
    Events chan FakeXdsEvent

FakeXdsUpdater is used to test the registry.

func NewFakeXDS Uses

func NewFakeXDS() *FakeXdsUpdater

NewFakeXDS creates a XdsUpdater reporting events via a channel.

func (*FakeXdsUpdater) Clear Uses

func (fx *FakeXdsUpdater) Clear()

Clear any pending event

func (*FakeXdsUpdater) ConfigUpdate Uses

func (fx *FakeXdsUpdater) ConfigUpdate(req *model.PushRequest)

func (*FakeXdsUpdater) EDSCacheUpdate Uses

func (fx *FakeXdsUpdater) EDSCacheUpdate(_, _, _ string, entry []*model.IstioEndpoint)

func (*FakeXdsUpdater) EDSUpdate Uses

func (fx *FakeXdsUpdater) EDSUpdate(_, hostname string, _ string, entry []*model.IstioEndpoint)

func (*FakeXdsUpdater) ProxyUpdate Uses

func (fx *FakeXdsUpdater) ProxyUpdate(_, _ string)

func (*FakeXdsUpdater) SvcUpdate Uses

func (fx *FakeXdsUpdater) SvcUpdate(_, hostname string, _ string, _ model.Event)

SvcUpdate is called when a service port mapping definition is updated. This interface is WIP - labels, annotations and other changes to service may be updated to force a EDS and CDS recomputation and incremental push, as it doesn't affect LDS/RDS.

func (*FakeXdsUpdater) Wait Uses

func (fx *FakeXdsUpdater) Wait(et string) *FakeXdsEvent

type FilterOutFunc Uses

type FilterOutFunc func(old, cur interface{}) bool

FilterOutFunc func for filtering out objects during update callback

type Multicluster Uses

type Multicluster struct {
    XDSUpdater model.XDSUpdater
    // contains filtered or unexported fields

Multicluster structure holds the remote kube Controllers and multicluster specific attributes.

func NewMulticluster Uses

func NewMulticluster(
    serverID string,
    kc kubernetes.Interface,
    secretNamespace string,
    opts Options,
    serviceController *aggregate.Controller,
    serviceEntryStore *serviceentry.ServiceEntryStore,
    caBundlePath string,
    fetchCaRoot func() map[string]string,
    networksWatcher mesh.NetworksWatcher,
) *Multicluster

NewMulticluster initializes data structure to store multicluster information It also starts the secret controller

func (*Multicluster) AddMemberCluster Uses

func (m *Multicluster) AddMemberCluster(client kubelib.Client, clusterID string) error

AddMemberCluster is passed to the secret controller as a callback to be called when a remote cluster is added. This function needs to set up all the handlers to watch for resources being added, deleted or changed on remote clusters.

func (*Multicluster) DeleteMemberCluster Uses

func (m *Multicluster) DeleteMemberCluster(clusterID string) error

DeleteMemberCluster is passed to the secret controller as a callback to be called when a remote cluster is deleted. Also must clear the cache so remote resources are removed.

func (*Multicluster) GetRemoteKubeClient Uses

func (m *Multicluster) GetRemoteKubeClient(clusterID string) kubernetes.Interface

func (*Multicluster) HasSynced Uses

func (m *Multicluster) HasSynced() bool

func (*Multicluster) InitSecretController Uses

func (m *Multicluster) InitSecretController(stop <-chan struct{})

func (*Multicluster) UpdateMemberCluster Uses

func (m *Multicluster) UpdateMemberCluster(clients kubelib.Client, clusterID string) error

type NamespaceController Uses

type NamespaceController struct {
    // contains filtered or unexported fields

NamespaceController manages reconciles a configmap in each namespace with a desired set of data.

func NewNamespaceController Uses

func NewNamespaceController(data func() map[string]string, kubeClient kube.Client) *NamespaceController

NewNamespaceController returns a pointer to a newly constructed NamespaceController instance.

func (*NamespaceController) Run Uses

func (nc *NamespaceController) Run(stopCh <-chan struct{})

Run starts the NamespaceController until a value is sent to stopCh.

type Options Uses

type Options struct {
    SystemNamespace string

    // Namespace the controller watches. If set to meta_v1.NamespaceAll (""), controller watches all namespaces
    WatchedNamespaces string
    ResyncPeriod      time.Duration
    DomainSuffix      string

    // ClusterID identifies the remote cluster in a multicluster env.
    ClusterID string

    // Metrics for capturing node-based metrics.
    Metrics model.Metrics

    // XDSUpdater will push changes to the xDS server.
    XDSUpdater model.XDSUpdater

    // TrustDomain used in SPIFFE identity
    // Deprecated - MeshConfig should be used.
    TrustDomain string

    // NetworksWatcher observes changes to the mesh networks config.
    NetworksWatcher mesh.NetworksWatcher

    // EndpointMode decides what source to use to get endpoint information
    EndpointMode EndpointMode

    // Maximum QPS when communicating with kubernetes API
    KubernetesAPIQPS float32

    // Maximum burst for throttle when communicating with the kubernetes API
    KubernetesAPIBurst int

    // Duration to wait for cache syncs
    SyncInterval time.Duration

Options stores the configurable attributes of a Controller.

func (Options) GetSyncInterval Uses

func (o Options) GetSyncInterval() time.Duration

type PodCache Uses

type PodCache struct {

    // IPByPods is a reverse map of podsByIP. This exists to allow us to prune stale entries in the
    // pod cache if a pod changes IP.
    IPByPods map[string]string
    // contains filtered or unexported fields

PodCache is an eventually consistent pod cache

Package controller imports 48 packages (graph) and is imported by 18 packages. Updated 2020-11-26. Refresh now. Tools for package owners.