controller

package
v0.0.0-...-fc8dc7e Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 84 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// NodeRegionLabel is the well-known label for kubernetes node region in beta
	NodeRegionLabel = v1.LabelFailureDomainBetaRegion
	// NodeZoneLabel is the well-known label for kubernetes node zone in beta
	NodeZoneLabel = v1.LabelFailureDomainBetaZone
	// NodeRegionLabelGA is the well-known label for kubernetes node region in ga
	NodeRegionLabelGA = v1.LabelTopologyRegion
	// NodeZoneLabelGA is the well-known label for kubernetes node zone in ga
	NodeZoneLabelGA = v1.LabelTopologyZone

	// DefaultNetworkGatewayPort is the port used by default for cross-network traffic if not otherwise specified
	// by meshNetworks or "networking.istio.io/gatewayPort"
	DefaultNetworkGatewayPort = 15443
)
View Source
const (
	// CACertNamespaceConfigMap is the name of the ConfigMap in each namespace storing the root cert of non-Kube CA.
	CACertNamespaceConfigMap = "istio-ca-root-cert"
)

Variables

This section is empty.

Functions

func FindPort

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.

func GetPodCondition

func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)

func GetPodConditionFromList

func GetPodConditionFromList(conditions []v1.PodCondition, conditionType v1.PodConditionType) (int, *v1.PodCondition)

GetPodConditionFromList extracts the provided condition from the given list of condition and returns the index of the condition and the condition. Returns -1 and nil if the condition is not present.

func GetPodReadyCondition

func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition

func GetServiceImportIPs

func GetServiceImportIPs(si *unstructured.Unstructured) []string

GetServiceImportIPs returns the list of ClusterSet IPs for the ServiceImport. Exported for testing only.

func IsPodReady

func IsPodReady(pod *v1.Pod) bool

IsPodReady is copied from kubernetes/pkg/api/v1/pod/utils.go

func IsPodReadyConditionTrue

func IsPodReadyConditionTrue(status v1.PodStatus) bool

IsPodReadyConditionTrue returns true if a pod is ready; false otherwise.

func IsPodRunning

func IsPodRunning(pod *v1.Pod) bool

Types

type Controller

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

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

func NewController

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

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

func (*Controller) AppendCrdHandlers

func (c *Controller) AppendCrdHandlers(f func(name string))

AppendCrdHandlers register handlers on crd event.

func (*Controller) AppendNamespaceDiscoveryHandlers

func (c *Controller) AppendNamespaceDiscoveryHandlers(f func(string, model.Event))

AppendNamespaceDiscoveryHandlers register handlers on namespace selected/deselected by discovery selectors change.

func (*Controller) AppendServiceHandler

func (c *Controller) AppendServiceHandler(f model.ServiceHandler)

AppendServiceHandler implements a service catalog operation

func (*Controller) AppendWorkloadHandler

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

AppendWorkloadHandler implements a service catalog operation

func (*Controller) Cleanup

func (c *Controller) Cleanup() error

func (*Controller) Cluster

func (c *Controller) Cluster() cluster.ID

func (*Controller) GetProxyServiceTargets

func (c *Controller) GetProxyServiceTargets(proxy *model.Proxy) []model.ServiceTarget

GetProxyServiceTargets returns service targets co-located with a given proxy

func (*Controller) GetProxyServiceTargetsByPod

func (c *Controller) GetProxyServiceTargetsByPod(pod *v1.Pod, service *v1.Service) []model.ServiceTarget

func (*Controller) GetProxyServiceTargetsFromMetadata

func (c *Controller) GetProxyServiceTargetsFromMetadata(proxy *model.Proxy) ([]model.ServiceTarget, error)

GetProxyServiceTargetsFromMetadata retrieves ServiceTargets using proxy Metadata rather than from the Pod. This allows retrieving Instances immediately, regardless of delays in Kubernetes. If the proxy doesn't have enough metadata, an error is returned

func (*Controller) GetProxyWorkloadLabels

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

func (*Controller) GetService

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

GetService implements a service catalog operation by hostname specified.

func (*Controller) HasSynced

func (c *Controller) HasSynced() bool

HasSynced returns true after the initial state synchronization

func (*Controller) MCSServices

func (c *Controller) MCSServices() []model.MCSServiceInfo

func (*Controller) Network

func (c *Controller) Network(endpointIP string, labels labels.Instance) network.ID

func (*Controller) NetworkGateways

func (c *Controller) NetworkGateways() []model.NetworkGateway

func (*Controller) NewEndpointBuilder

func (c *Controller) NewEndpointBuilder(pod *v1.Pod) *EndpointBuilder

func (*Controller) NewEndpointBuilderFromMetadata

func (c *Controller) NewEndpointBuilderFromMetadata(proxy *model.Proxy) *EndpointBuilder

func (*Controller) Provider

func (c *Controller) Provider() provider.ID

func (*Controller) Run

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

Run all controllers until a signal is received

func (*Controller) Services

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

Services implements a service catalog operation

func (*Controller) Stop

func (c *Controller) Stop()

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

func (*Controller) WorkloadInstanceHandler

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

WorkloadInstanceHandler defines the handler for service instances generated by other registries

type EndpointBuilder

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

EndpointBuilder is a stateful IstioEndpoint builder with metadata used to build IstioEndpoint

type FakeController

type FakeController struct {
	*Controller
	Endpoints *model.EndpointIndex
}

func NewFakeControllerWithOptions

func NewFakeControllerWithOptions(t test.Failer, opts FakeControllerOptions) (*FakeController, *xdsfake.Updater)

type FakeControllerOptions

type FakeControllerOptions struct {
	Client            kubelib.Client
	CRDs              []schema.GroupVersionResource
	NetworksWatcher   mesh.NetworksWatcher
	MeshWatcher       mesh.Watcher
	ServiceHandler    model.ServiceHandler
	ClusterID         cluster.ID
	WatchedNamespaces string
	DomainSuffix      string
	XDSUpdater        model.XDSUpdater
	Stop              chan struct{}
	SkipRun           bool
	ConfigCluster     bool
	SystemNamespace   string
}

type FilterOutFunc

type FilterOutFunc[T controllers.Object] func(old, cur T) bool

FilterOutFunc func for filtering out objects during update callback

type Multicluster

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

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

func NewMulticluster

func NewMulticluster(
	serverID string,
	kc kubernetes.Interface,
	secretNamespace string,
	opts Options,
	serviceEntryController *serviceentry.Controller,
	configController model.ConfigStoreController,
	caBundleWatcher *keycertbundle.Watcher,
	revision string,
	startNsController bool,
	clusterLocal model.ClusterLocalProvider,
	s server.Instance,
	controller *multicluster.Controller,
) *Multicluster

NewMulticluster initializes data structure to store multicluster information

type NamespaceController

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

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

func NewNamespaceController

func NewNamespaceController(kubeClient kube.Client, caBundleWatcher *keycertbundle.Watcher) *NamespaceController

NewNamespaceController returns a pointer to a newly constructed NamespaceController instance.

func (*NamespaceController) Run

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

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

type Options

type Options struct {
	SystemNamespace string

	// MeshServiceController is a mesh-wide service Controller.
	MeshServiceController *aggregate.Controller

	DomainSuffix string

	// ClusterID identifies the cluster which the controller communicate with.
	ClusterID cluster.ID

	// ClusterAliases are alias names for cluster. When a proxy connects with a cluster ID
	// and if it has a different alias we should use that a cluster ID for proxy.
	ClusterAliases map[string]string

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

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

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

	// MeshWatcher observes changes to the mesh config
	MeshWatcher mesh.Watcher

	// Maximum QPS when communicating with kubernetes API
	KubernetesAPIQPS float32

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

	// SyncTimeout, if set, causes HasSynced to be returned when timeout.
	SyncTimeout time.Duration

	// Revision of this Istiod instance
	Revision string

	ConfigCluster bool

	CniNamespace string

	// StatusWritingEnabled determines if status writing is enabled. This may be set to `nil`, in which case status
	// writing will never be enabled
	StatusWritingEnabled *activenotifier.ActiveNotifier
}

Options stores the configurable attributes of a Controller.

type PodCache

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[types.NamespacedName]string
	// contains filtered or unexported fields
}

PodCache is an eventually consistent pod cache

Directories

Path Synopsis
nolint: gocritic
nolint: gocritic

Jump to

Keyboard shortcuts

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