istio: istio.io/istio/pilot/pkg/serviceregistry/kube/controller Index | Files

package controller

import "istio.io/istio/pilot/pkg/serviceregistry/kube/controller"

package controller implements the shared and reusable library for Kubernetes

Index

Package Files

client.go controller.go endpoint_builder.go endpoints.go endpointsdiscovery.go endpointslice.go multicluster.go pod.go util.go

Constants

const (
    // NodeRegionLabel is the well-known label for kubernetes node region in beta
    NodeRegionLabel = "failure-domain.beta.kubernetes.io/region"
    // NodeZoneLabel is the well-known label for kubernetes node zone in beta
    NodeZoneLabel = "failure-domain.beta.kubernetes.io/zone"
    // NodeRegionLabelGA is the well-known label for kubernetes node region in ga
    NodeRegionLabelGA = "topology.kubernetes.io/region"
    // NodeZoneLabelGA is the well-known label for kubernetes node zone in ga
    NodeZoneLabelGA = "topology.kubernetes.io/zone"
    // IstioSubzoneLabel is custom subzone label for locality-based routing in Kubernetes see: https://github.com/istio/istio/issues/19114
    IstioSubzoneLabel = "topology.istio.io/subzone"
    // IstioNamespace used by default for Istio cluster-wide installation
    IstioNamespace = "istio-system"
    // IstioConfigMap is used by default
    IstioConfigMap = "istio"
    // PrometheusScrape is the annotation used by prometheus to determine if service metrics should be scraped (collected)
    PrometheusScrape = "prometheus.io/scrape"
    // PrometheusPort is the annotation used to explicitly specify the port to use for scraping metrics
    PrometheusPort = "prometheus.io/port"
    // PrometheusPath is the annotation used to specify a path for scraping metrics. Default is "/metrics"
    PrometheusPath = "prometheus.io/path"
    // PrometheusPathDefault is the default value for the PrometheusPath annotation
    PrometheusPathDefault = "/metrics"
)

Variables

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

func CreateInterface Uses

func CreateInterface(kubeconfig string) (kubernetes.Interface, error)

CreateInterface is a helper function to create Kubernetes interface from kubeconfig file

func FindPort Uses

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

Forked from Kubernetes k8s.io/kubernetes/pkg/api/v1/pod 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.

type Controller Uses

type Controller struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

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

func NewController Uses

func NewController(client kubernetes.Interface, options Options) *Controller

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

func (*Controller) AppendInstanceHandler Uses

func (c *Controller) AppendInstanceHandler(func(*model.ServiceInstance, model.Event)) error

AppendInstanceHandler implements a service catalog operation

func (*Controller) AppendServiceHandler Uses

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

AppendServiceHandler implements a service catalog operation

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, error)

GetProxyServiceInstances returns service instances co-located with a given proxy

func (*Controller) GetProxyWorkloadLabels Uses

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

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, error)

InstancesByPort implements a service catalog operation

func (*Controller) ManagementPorts Uses

func (c *Controller) ManagementPorts(addr string) model.PortList

ManagementPorts implements a service catalog operation

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. Mostly for tests, to simplify the code (defer c.Stop())

func (*Controller) WorkloadHealthCheckInfo Uses

func (c *Controller) WorkloadHealthCheckInfo(addr string) model.ProbeList

WorkloadHealthCheckInfo implements a service catalog operation

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 *Controller, pod *v1.Pod) *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
    EndpointSliceOnly
)

func (EndpointMode) String Uses

func (m EndpointMode) String() string

type Multicluster Uses

type Multicluster struct {
    WatchedNamespace string
    DomainSuffix     string
    ResyncPeriod     time.Duration

    XDSUpdater model.XDSUpdater
    // contains filtered or unexported fields
}

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

func NewMulticluster Uses

func NewMulticluster(kc kubernetes.Interface, secretNamespace string, opts Options,
    serviceController *aggregate.Controller, xds model.XDSUpdater, networksWatcher mesh.NetworksWatcher) (*Multicluster, error)

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

func (*Multicluster) AddMemberCluster Uses

func (m *Multicluster) AddMemberCluster(clientset kubernetes.Interface, 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) UpdateMemberCluster Uses

func (m *Multicluster) UpdateMemberCluster(clientset kubernetes.Interface, clusterID string) error

type Options Uses

type Options struct {
    // Namespace the controller watches. If set to meta_v1.NamespaceAll (""), controller watches all namespaces
    WatchedNamespace 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
    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
}

Options stores the configurable attributes of a Controller.

type PodCache Uses

type PodCache struct {
    sync.RWMutex

    // 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 37 packages (graph) and is imported by 15 packages. Updated 2020-03-30. Refresh now. Tools for package owners.