istio: istio.io/istio/pilot/pkg/model Index | Files | Directories

package model

import "istio.io/istio/pilot/pkg/model"

Copyright Istio Authors

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

Package Files

authentication.go authorization.go config.go context.go controller.go destination_rule.go disabled_ledger.go envoyfilter.go fake_store.go gateway.go jwks_resolver.go log.go push_context.go service.go sidecar.go validation.go virtualservice.go

Constants

const (

    // JwtPubKeyEvictionDuration is the life duration for cached item.
    // Cached item will be removed from the cache if it hasn't been used longer than JwtPubKeyEvictionDuration or if pilot
    // has failed to refresh it for more than JwtPubKeyEvictionDuration.
    JwtPubKeyEvictionDuration = 24 * 7 * time.Hour

    // JwtPubKeyRefreshInterval is the running interval of JWT pubKey refresh job.
    JwtPubKeyRefreshInterval = time.Minute * 20
)
const (
    // IstioDefaultConfigNamespace constant for default namespace
    IstioDefaultConfigNamespace = "default"

    // LocalityLabel indicates the region/zone/subzone of an instance. It is used to override the native
    // registry's value.
    //
    // Note: because k8s labels does not support `/`, so we use `.` instead in k8s.
    LocalityLabel = "istio-locality"
)
const (
    // TLSModeLabelShortname name used for determining endpoint level tls transport socket configuration
    TLSModeLabelShortname = "tlsMode"

    // DisabledTLSModeLabel implies that this endpoint should receive traffic as is (mostly plaintext)
    DisabledTLSModeLabel = "disabled"

    // IstioMutualTLSModeLabel implies that the endpoint is ready to receive Istio mTLS connections.
    IstioMutualTLSModeLabel = "istio"

    // IstioCanonicalServiceLabelName is the name of label for the Istio Canonical Service for a workload instance.
    IstioCanonicalServiceLabelName = "service.istio.io/canonical-name"

    // IstioCanonicalServiceRevisionLabelName is the name of label for the Istio Canonical Service revision for a workload instance.
    IstioCanonicalServiceRevisionLabelName = "service.istio.io/canonical-revision"
)
const (
    // NamespaceAll is a designated symbol for listing across all namespaces
    NamespaceAll = ""
)
const (
    ResourceSeparator = "~"
)
const SidecarDNSListenerPort = 15013

SidecarDNSListenerPort specifes the port at which the sidecar hosts a DNS resolver listener. TODO: customize me. tools/istio-iptables package also has this hardcoded.

const UnixAddressPrefix = "unix://"

UnixAddressPrefix is the prefix used to indicate an address is for a Unix Domain socket. It is used in ServiceEntry.Endpoint.Address message.

const UnnamedNetwork = ""

UnnamedNetwork is the default network that proxies in the mesh get when they don't request a specific network view.

Variables

var (

    // EndpointNoPod tracks endpoints without an associated pod. This is an error condition, since
    // we can't figure out the labels. It may be a transient problem, if endpoint is processed before
    // pod.
    EndpointNoPod = monitoring.NewGauge(
        "endpoint_no_pod",
        "Endpoints without an associated pod.",
    )

    // ProxyStatusNoService represents proxies not selected by any service
    // This can be normal - for workloads that act only as client, or are not covered by a Service.
    // It can also be an error, for example in cases the Endpoint list of a service was not updated by the time
    // the sidecar calls.
    // Updated by GetProxyServiceInstances
    ProxyStatusNoService = monitoring.NewGauge(
        "pilot_no_ip",
        "Pods not found in the endpoint table, possibly invalid.",
    )

    // ProxyStatusEndpointNotReady represents proxies found not be ready.
    // Updated by GetProxyServiceInstances. Normal condition when starting
    // an app with readiness, error if it doesn't change to 0.
    ProxyStatusEndpointNotReady = monitoring.NewGauge(
        "pilot_endpoint_not_ready",
        "Endpoint found in unready state.",
    )

    // ProxyStatusConflictOutboundListenerTCPOverHTTP metric tracks number of
    // wildcard TCP listeners that conflicted with existing wildcard HTTP listener on same port
    ProxyStatusConflictOutboundListenerTCPOverHTTP = monitoring.NewGauge(
        "pilot_conflict_outbound_listener_tcp_over_current_http",
        "Number of conflicting wildcard tcp listeners with current wildcard http listener.",
    )

    // ProxyStatusConflictOutboundListenerTCPOverTCP metric tracks number of
    // TCP listeners that conflicted with existing TCP listeners on same port
    ProxyStatusConflictOutboundListenerTCPOverTCP = monitoring.NewGauge(
        "pilot_conflict_outbound_listener_tcp_over_current_tcp",
        "Number of conflicting tcp listeners with current tcp listener.",
    )

    // ProxyStatusConflictOutboundListenerHTTPOverTCP metric tracks number of
    // wildcard HTTP listeners that conflicted with existing wildcard TCP listener on same port
    ProxyStatusConflictOutboundListenerHTTPOverTCP = monitoring.NewGauge(
        "pilot_conflict_outbound_listener_http_over_current_tcp",
        "Number of conflicting wildcard http listeners with current wildcard tcp listener.",
    )

    // ProxyStatusConflictInboundListener tracks cases of multiple inbound
    // listeners - 2 services selecting the same port of the pod.
    ProxyStatusConflictInboundListener = monitoring.NewGauge(
        "pilot_conflict_inbound_listener",
        "Number of conflicting inbound listeners.",
    )

    // DuplicatedClusters tracks duplicate clusters seen while computing CDS
    DuplicatedClusters = monitoring.NewGauge(
        "pilot_duplicate_envoy_clusters",
        "Duplicate envoy clusters caused by service entries with same hostname",
    )

    // DNSNoEndpointClusters tracks dns clusters without endpoints
    DNSNoEndpointClusters = monitoring.NewGauge(
        "pilot_dns_cluster_without_endpoints",
        "DNS clusters without endpoints caused by the endpoint field in "+
            "STRICT_DNS type cluster is not set or the corresponding subset cannot select any endpoint",
    )

    // ProxyStatusClusterNoInstances tracks clusters (services) without workloads.
    ProxyStatusClusterNoInstances = monitoring.NewGauge(
        "pilot_eds_no_instances",
        "Number of clusters without instances.",
    )

    // DuplicatedDomains tracks rejected VirtualServices due to duplicated hostname.
    DuplicatedDomains = monitoring.NewGauge(
        "pilot_vservice_dup_domain",
        "Virtual services with dup domains.",
    )

    // DuplicatedSubsets tracks duplicate subsets that we rejected while merging multiple destination rules for same host
    DuplicatedSubsets = monitoring.NewGauge(
        "pilot_destrule_subsets",
        "Duplicate subsets across destination rules for same host",
    )

    // LastPushStatus preserves the metrics and data collected during lasts global push.
    // It can be used by debugging tools to inspect the push event. It will be reset after each push with the
    // new version.
    LastPushStatus *PushContext
    // LastPushMutex will protect the LastPushStatus
    LastPushMutex sync.Mutex
)
var (
    MaxIstioVersion = &IstioVersion{Major: 65535, Minor: 65535, Patch: 65535}
)

func BuildDNSSrvSubsetKey Uses

func BuildDNSSrvSubsetKey(direction TrafficDirection, subsetName string, hostname host.Name, port int) string

BuildDNSSrvSubsetKey generates a unique string referencing service instances for a given service name, a subset and a port. The proxy queries Pilot with this key to obtain the list of instances in a subset. This is used only for the SNI-DNAT router. Do not use for other purposes. The DNS Srv format of the cluster is also used as the default SNI string for Istio mTLS connections

func BuildSubsetKey Uses

func BuildSubsetKey(direction TrafficDirection, subsetName string, hostname host.Name, port int) string

BuildSubsetKey generates a unique string referencing service instances for a given service name, a subset and a port. The proxy queries Pilot with this key to obtain the list of instances in a subset.

func ConfigNamesOfKind Uses

func ConfigNamesOfKind(configs map[ConfigKey]struct{}, kind resource.GroupVersionKind) map[string]struct{}

ConfigNamesOfKind extracts config names of the specified kind.

func ConfigsOfKind Uses

func ConfigsOfKind(configs map[ConfigKey]struct{}, kind resource.GroupVersionKind) map[ConfigKey]struct{}

ConfigsOfKind extracts configs of the specified kind.

func ForeignSeviceInstancesEqual Uses

func ForeignSeviceInstancesEqual(first, second *ServiceInstance) bool

a custom comparison of foreign service instances based on the fields that we need i.e. excluding the ports. Returns true if equal, false otherwise.

func GetLocalityLabelOrDefault Uses

func GetLocalityLabelOrDefault(label, defaultLabel string) string

GetLocalityLabelOrDefault returns the locality from the supplied label, or falls back to the supplied default locality if the supplied label is empty. Because Kubernetes labels don't support `/`, we replace "." with "/" in the supplied label as a workaround.

func GetNetworkView Uses

func GetNetworkView(node *Proxy) map[string]bool

GetNetworkView returns the networks that the proxy requested. When sending EDS/CDS-with-dns-endpoints, Pilot will only send endpoints corresponding to the networks that the proxy wants to see. If not set, we assume that the proxy wants to see endpoints from the default unnamed network.

func GetOrDefault Uses

func GetOrDefault(s string, def string) string

GetOrDefault returns either the value, or the default if the value is empty. Useful when retrieving node metadata fields.

func GetProxyConfigNamespace Uses

func GetProxyConfigNamespace(proxy *Proxy) string

GetProxyConfigNamespace extracts the namespace associated with the proxy from the proxy metadata or the proxy ID

func GetServiceAccounts Uses

func GetServiceAccounts(svc *Service, ports []int, discovery ServiceDiscovery) []string

GetServiceAccounts returns aggregated list of service accounts of Service plus its instances.

func GetTLSModeFromEndpointLabels Uses

func GetTLSModeFromEndpointLabels(labels map[string]string) string

GetTLSModeFromEndpointLabels returns the value of the label security.istio.io/tlsMode if set. Do not return Enums or constants from this function as users could provide values other than istio/disabled and apply custom transport socket matchers here.

func IsApplicationNodeType Uses

func IsApplicationNodeType(nType NodeType) bool

IsApplicationNodeType verifies that the NodeType is one of the declared constants in the model

func IsValidSubsetKey Uses

func IsValidSubsetKey(s string) bool

IsValidSubsetKey checks if a string is valid for subset key parsing.

func Key Uses

func Key(typ, name, namespace string) string

Key function for the configuration objects

func MatchesDestHost Uses

func MatchesDestHost(destinationHost string, meta ConfigMeta, svc *mccpb.IstioService) bool

MatchesDestHost returns true if the service instance matches the given IstioService ex: binding host(details.istio-system.svc.cluster.local) ?= instance(reviews.default.svc.cluster.local)

func MostSpecificHostMatch Uses

func MostSpecificHostMatch(needle host.Name, stack []host.Name) (host.Name, bool)

MostSpecificHostMatch compares the elements of the stack to the needle, and returns the longest stack element matching the needle, or false if no element in the stack matches the needle.

func ParseGatewayRDSRouteName Uses

func ParseGatewayRDSRouteName(name string) (portNumber int, portName, gatewayName string)

ParseGatewayRDSRouteName is used by the EnvoyFilter patching logic to match a specific route configuration to patch.

func ParsePort Uses

func ParsePort(addr string) int

ParsePort extracts port number from a valid proxy address

func ResolveHostname Uses

func ResolveHostname(meta ConfigMeta, svc *mccpb.IstioService) host.Name

ResolveHostname produces a FQDN based on either the service or a concat of the namespace + domain Deprecated. Do not use

func ResolveShortnameToFQDN Uses

func ResolveShortnameToFQDN(hostname string, meta ConfigMeta) host.Name

ResolveShortnameToFQDN uses metadata information to resolve a reference to shortname of the service to FQDN

func SortQuotaSpec Uses

func SortQuotaSpec(specs []Config)

SortQuotaSpec sorts a slice in a stable manner.

type AuthenticationPolicies Uses

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

AuthenticationPolicies organizes authentication (mTLS + JWT) policies by namespace.

func (*AuthenticationPolicies) GetJwtPoliciesForWorkload Uses

func (policy *AuthenticationPolicies) GetJwtPoliciesForWorkload(namespace string,
    workloadLabels labels.Collection) []*Config

GetJwtPoliciesForWorkload returns a list of JWT policies matching to labels.

func (*AuthenticationPolicies) GetNamespaceMutualTLSMode Uses

func (policy *AuthenticationPolicies) GetNamespaceMutualTLSMode(namespace string) MutualTLSMode

GetNamespaceMutualTLSMode returns the MutualTLSMode as defined by a namespace or mesh level PeerAuthentication. The return value could be `MTLSUnknown` if there is no mesh nor namespace PeerAuthentication policy for the given namespace.

func (*AuthenticationPolicies) GetPeerAuthenticationsForWorkload Uses

func (policy *AuthenticationPolicies) GetPeerAuthenticationsForWorkload(namespace string,
    workloadLabels labels.Collection) []*Config

GetPeerAuthenticationsForWorkload returns a list of peer authentication policies matching to labels.

func (*AuthenticationPolicies) GetRootNamespace Uses

func (policy *AuthenticationPolicies) GetRootNamespace() string

GetRootNamespace return root namespace that is tracked by the policy object.

type AuthorizationPolicies Uses

type AuthorizationPolicies struct {
    // Maps from namespace to the Authorization policies.
    NamespaceToPolicies map[string][]AuthorizationPolicy `json:"namespace_to_policies"`

    // The name of the root namespace. Policy in the root namespace applies to workloads in all namespaces.
    RootNamespace string `json:"root_namespace"`
}

AuthorizationPolicies organizes AuthorizationPolicy by namespace.

func GetAuthorizationPolicies Uses

func GetAuthorizationPolicies(env *Environment) (*AuthorizationPolicies, error)

GetAuthorizationPolicies returns the AuthorizationPolicies for the given environment.

func (*AuthorizationPolicies) ListAuthorizationPolicies Uses

func (policy *AuthorizationPolicies) ListAuthorizationPolicies(namespace string, workload labels.Collection) (
    denyPolicies []AuthorizationPolicy, allowPolicies []AuthorizationPolicy)

ListAuthorizationPolicies returns the deny and allow AuthorizationPolicy for the workload in the given namespace.

type AuthorizationPolicy Uses

type AuthorizationPolicy struct {
    Name      string                      `json:"name"`
    Namespace string                      `json:"namespace"`
    Spec      *authpb.AuthorizationPolicy `json:"spec"`
}

type BootstrapNodeMetadata Uses

type BootstrapNodeMetadata struct {
    NodeMetadata

    // ExchangeKeys specifies a list of metadata keys that should be used for Node Metadata Exchange.
    ExchangeKeys StringList `json:"EXCHANGE_KEYS,omitempty"`

    // InstanceName is the short name for the workload instance (ex: pod name)
    // replaces POD_NAME
    InstanceName string `json:"NAME,omitempty"`

    // WorkloadName specifies the name of the workload represented by this node.
    WorkloadName string `json:"WORKLOAD_NAME,omitempty"`

    // Owner specifies the workload owner (opaque string). Typically, this is the owning controller of
    // of the workload instance (ex: k8s deployment for a k8s pod).
    Owner string `json:"OWNER,omitempty"`

    // PlatformMetadata contains any platform specific metadata
    PlatformMetadata map[string]string `json:"PLATFORM_METADATA,omitempty"`

    StatsInclusionPrefixes string `json:"sidecar.istio.io/statsInclusionPrefixes,omitempty"`
    StatsInclusionRegexps  string `json:"sidecar.istio.io/statsInclusionRegexps,omitempty"`
    StatsInclusionSuffixes string `json:"sidecar.istio.io/statsInclusionSuffixes,omitempty"`
    ExtraStatTags          string `json:"sidecar.istio.io/extraStatTags,omitempty"`
}

BootstrapNodeMetadata is a superset of NodeMetadata, intended to model the entirety of the node metadata we configure in the Envoy bootstrap. This is split out from NodeMetadata to explicitly segment the parameters that are consumed by Pilot from the parameters used only as part of the bootstrap. Fields used by bootstrap only are consumed by Envoy itself, such as the telemetry filters.

func (*BootstrapNodeMetadata) UnmarshalJSON Uses

func (m *BootstrapNodeMetadata) UnmarshalJSON(data []byte) error

type Config Uses

type Config struct {
    ConfigMeta

    // Spec holds the configuration object as a gogo protobuf message
    Spec proto.Message
}

Config is a configuration unit consisting of the type of configuration, the key identifier that is unique per type, and the content represented as a protobuf message.

func (Config) DeepCopy Uses

func (c Config) DeepCopy() Config

type ConfigKey Uses

type ConfigKey struct {
    Kind      resource.GroupVersionKind
    Name      string
    Namespace string
}

ConfigKey describe a specific config item. In most cases, the name is the config's name. However, for ServiceEntry it is service's FQDN.

type ConfigMeta Uses

type ConfigMeta struct {
    // GroupVersionKind is a short configuration name that matches the content message type
    // (e.g. "route-rule")
    GroupVersionKind resource.GroupVersionKind `json:"type,omitempty"`

    // Name is a unique immutable identifier in a namespace
    Name string `json:"name,omitempty"`

    // Namespace defines the space for names (optional for some types),
    // applications may choose to use namespaces for a variety of purposes
    // (security domains, fault domains, organizational domains)
    Namespace string `json:"namespace,omitempty"`

    // Domain defines the suffix of the fully qualified name past the namespace.
    // Domain is not a part of the unique key unlike name and namespace.
    Domain string `json:"domain,omitempty"`

    // Map of string keys and values that can be used to organize and categorize
    // (scope and select) objects.
    Labels map[string]string `json:"labels,omitempty"`

    // Annotations is an unstructured key value map stored with a resource that may be
    // set by external tools to store and retrieve arbitrary metadata. They are not
    // queryable and should be preserved when modifying objects.
    Annotations map[string]string `json:"annotations,omitempty"`

    // ResourceVersion is an opaque identifier for tracking updates to the config registry.
    // The implementation may use a change index or a commit log for the revision.
    // The config client should not make any assumptions about revisions and rely only on
    // exact equality to implement optimistic concurrency of read-write operations.
    //
    // The lifetime of an object of a particular revision depends on the underlying data store.
    // The data store may compactify old revisions in the interest of storage optimization.
    //
    // An empty revision carries a special meaning that the associated object has
    // not been stored and assigned a revision.
    ResourceVersion string `json:"resourceVersion,omitempty"`

    // CreationTimestamp records the creation time
    CreationTimestamp time.Time `json:"creationTimestamp,omitempty"`
}

ConfigMeta is metadata attached to each configuration unit. The revision is optional, and if provided, identifies the last update operation on the object.

func (*ConfigMeta) Key Uses

func (meta *ConfigMeta) Key() string

Key is the unique identifier for a configuration object TODO: this is *not* unique - needs the version and group

type ConfigStore Uses

type ConfigStore interface {
    // Schemas exposes the configuration type schema known by the config store.
    // The type schema defines the bidrectional mapping between configuration
    // types and the protobuf encoding schema.
    Schemas() collection.Schemas

    // Get retrieves a configuration element by a type and a key
    Get(typ resource.GroupVersionKind, name, namespace string) *Config

    // List returns objects by type and namespace.
    // Use "" for the namespace to list across namespaces.
    List(typ resource.GroupVersionKind, namespace string) ([]Config, error)

    // Create adds a new configuration object to the store. If an object with the
    // same name and namespace for the type already exists, the operation fails
    // with no side effects.
    Create(config Config) (revision string, err error)

    // Update modifies an existing configuration object in the store.  Update
    // requires that the object has been created.  Resource version prevents
    // overriding a value that has been changed between prior _Get_ and _Put_
    // operation to achieve optimistic concurrency. This method returns a new
    // revision if the operation succeeds.
    Update(config Config) (newRevision string, err error)

    // Delete removes an object from the store by key
    Delete(typ resource.GroupVersionKind, name, namespace string) error

    Version() string

    GetResourceAtVersion(version string, key string) (resourceVersion string, err error)

    GetLedger() ledger.Ledger

    SetLedger(ledger.Ledger) error
}

ConfigStore describes a set of platform agnostic APIs that must be supported by the underlying platform to store and retrieve Istio configuration.

Configuration key is defined to be a combination of the type, name, and namespace of the configuration object. The configuration key is guaranteed to be unique in the store.

The storage interface presented here assumes that the underlying storage layer supports _Get_ (list), _Update_ (update), _Create_ (create) and _Delete_ semantics but does not guarantee any transactional semantics.

_Update_, _Create_, and _Delete_ are mutator operations. These operations are asynchronous, and you might not see the effect immediately (e.g. _Get_ might not return the object by key immediately after you mutate the store.) Intermittent errors might occur even though the operation succeeds, so you should always check if the object store has been modified even if the mutating operation returns an error. Objects should be created with _Create_ operation and updated with _Update_ operation.

Resource versions record the last mutation operation on each object. If a mutation is applied to a different revision of an object than what the underlying storage expects as defined by pure equality, the operation is blocked. The client of this interface should not make assumptions about the structure or ordering of the revision identifier.

Object references supplied and returned from this interface should be treated as read-only. Modifying them violates thread-safety.

type ConfigStoreCache Uses

type ConfigStoreCache interface {
    ConfigStore

    // RegisterEventHandler adds a handler to receive config update events for a
    // configuration type
    RegisterEventHandler(kind resource.GroupVersionKind, handler func(Config, Config, Event))

    // Run until a signal is received
    Run(stop <-chan struct{})

    // HasSynced returns true after initial cache synchronization is complete
    HasSynced() bool
}

ConfigStoreCache is a local fully-replicated cache of the config store. The cache actively synchronizes its local state with the remote store and provides a notification mechanism to receive update events. As such, the notification handlers must be registered prior to calling _Run_, and the cache requires initial synchronization grace period after calling _Run_.

Update notifications require the following consistency guarantee: the view in the cache must be AT LEAST as fresh as the moment notification arrives, but MAY BE more fresh (e.g. if _Delete_ cancels an _Add_ event).

Handlers execute on the single worker queue in the order they are appended. Handlers receive the notification event and the associated object. Note that all handlers must be registered before starting the cache controller.

type Controller Uses

type Controller interface {
    // AppendServiceHandler notifies about changes to the service catalog.
    AppendServiceHandler(f func(*Service, Event)) error

    // AppendInstanceHandler notifies about changes to the service instances
    // for a service.
    AppendInstanceHandler(f func(*ServiceInstance, Event)) error

    // Run until a signal is received
    Run(stop <-chan struct{})

    // HasSynced returns true after initial cache synchronization is complete
    HasSynced() bool
}

Controller defines an event controller loop. Proxy agent registers itself with the controller loop and receives notifications on changes to the service topology or changes to the configuration artifacts.

The controller guarantees the following consistency requirement: registry view in the controller is as AT LEAST as fresh as the moment notification arrives, but MAY BE more fresh (e.g. "delete" cancels an "add" event). For example, an event for a service creation will see a service registry without the service if the event is immediately followed by the service deletion event.

Handlers execute on the single worker queue in the order they are appended. Handlers receive the notification event and the associated object. Note that all handlers must be appended before starting the controller.

type DisabledLedger Uses

type DisabledLedger struct {
    ledger.Ledger
}

DisabledLedger is an empty mock of the ledger.Ledger interface which we will substitute when distribution tracking is disabled.

func (*DisabledLedger) Delete Uses

func (d *DisabledLedger) Delete(key string) error

func (*DisabledLedger) Get Uses

func (d *DisabledLedger) Get(key string) (string, error)

func (*DisabledLedger) GetPreviousValue Uses

func (d *DisabledLedger) GetPreviousValue(previousHash, key string) (result string, err error)

func (*DisabledLedger) Put Uses

func (d *DisabledLedger) Put(key, value string) (string, error)

func (*DisabledLedger) RootHash Uses

func (d *DisabledLedger) RootHash() string

type Environment Uses

type Environment struct {
    // Discovery interface for listing services and instances.
    ServiceDiscovery

    // Config interface for listing routing rules
    IstioConfigStore

    // Watcher is the watcher for the mesh config (to be merged into the config store)
    mesh.Watcher

    // NetworksWatcher (loaded from a config map) provides information about the
    // set of networks inside a mesh and how to route to endpoints in each
    // network. Each network provides information about the endpoints in a
    // routable L3 network. A single routable L3 network can have one or more
    // service registries.
    mesh.NetworksWatcher

    // PushContext holds informations during push generation. It is reset on config change, at the beginning
    // of the pushAll. It will hold all errors and stats and possibly caches needed during the entire cache computation.
    // DO NOT USE EXCEPT FOR TESTS AND HANDLING OF NEW CONNECTIONS.
    // ALL USE DURING A PUSH SHOULD USE THE ONE CREATED AT THE
    // START OF THE PUSH, THE GLOBAL ONE MAY CHANGE AND REFLECT A DIFFERENT
    // CONFIG AND PUSH
    PushContext *PushContext

    // DomainSuffix provides a default domain for the Istio server.
    DomainSuffix string
}

Environment provides an aggregate environmental API for Pilot

func (*Environment) AddMeshHandler Uses

func (e *Environment) AddMeshHandler(h func())

func (*Environment) AddMetric Uses

func (e *Environment) AddMetric(metric monitoring.Metric, key string, proxy *Proxy, msg string)

func (*Environment) AddNetworksHandler Uses

func (e *Environment) AddNetworksHandler(h func())

func (*Environment) GetDiscoveryAddress Uses

func (e *Environment) GetDiscoveryAddress() (host.Name, string, error)

GetDiscoveryAddress parses the DiscoveryAddress specified via MeshConfig.

func (*Environment) GetDomainSuffix Uses

func (e *Environment) GetDomainSuffix() string

func (*Environment) Mesh Uses

func (e *Environment) Mesh() *meshconfig.MeshConfig

func (*Environment) Networks Uses

func (e *Environment) Networks() *meshconfig.MeshNetworks

type EnvoyFilterConfigPatchWrapper Uses

type EnvoyFilterConfigPatchWrapper struct {
    Value     proto.Message
    Match     *networking.EnvoyFilter_EnvoyConfigObjectMatch
    ApplyTo   networking.EnvoyFilter_ApplyTo
    Operation networking.EnvoyFilter_Patch_Operation
    // Pre-compile the regex from proxy version match in the match
    ProxyVersionRegex *regexp.Regexp
    // ProxyPrefixMatch provides a prefix match for the proxy version. The current API only allows
    // regex match, but as an optimization we can reduce this to a prefix match for common cases.
    // If this is set, ProxyVersionRegex is ignored.
    ProxyPrefixMatch string
}

EnvoyFilterConfigPatchWrapper is a wrapper over the EnvoyFilter ConfigPatch api object fields are ordered such that this struct is aligned

type EnvoyFilterWrapper Uses

type EnvoyFilterWrapper struct {
    Patches map[networking.EnvoyFilter_ApplyTo][]*EnvoyFilterConfigPatchWrapper
    // contains filtered or unexported fields
}

EnvoyFilterWrapper is a wrapper for the EnvoyFilter api object with pre-processed data

type Event Uses

type Event int

Event represents a registry update event

const (
    // EventAdd is sent when an object is added
    EventAdd Event = iota

    // EventUpdate is sent when an object is modified
    // Captures the modified object
    EventUpdate

    // EventDelete is sent when an object is deleted
    // Captures the object at the last known state
    EventDelete
)

func (Event) String Uses

func (event Event) String() string

type FakeStore Uses

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

func NewFakeStore Uses

func NewFakeStore() *FakeStore

func (*FakeStore) Create Uses

func (s *FakeStore) Create(config Config) (revision string, err error)

func (*FakeStore) Delete Uses

func (*FakeStore) Delete(typ resource.GroupVersionKind, name, namespace string) error

func (*FakeStore) Get Uses

func (*FakeStore) Get(typ resource.GroupVersionKind, name, namespace string) *Config

func (*FakeStore) GetLedger Uses

func (s *FakeStore) GetLedger() ledger.Ledger

func (*FakeStore) GetResourceAtVersion Uses

func (s *FakeStore) GetResourceAtVersion(version string, key string) (resourceVersion string, err error)

func (*FakeStore) List Uses

func (s *FakeStore) List(typ resource.GroupVersionKind, namespace string) ([]Config, error)

func (*FakeStore) Schemas Uses

func (s *FakeStore) Schemas() collection.Schemas

func (*FakeStore) SetLedger Uses

func (s *FakeStore) SetLedger(l ledger.Ledger) error

func (*FakeStore) Update Uses

func (*FakeStore) Update(config Config) (newRevision string, err error)

func (*FakeStore) Version Uses

func (s *FakeStore) Version() string

type Gateway Uses

type Gateway struct {
    // gateway ip address
    Addr string
    // gateway port
    Port uint32
}

Gateway is the gateway of a network

type IstioConfigStore Uses

type IstioConfigStore interface {
    ConfigStore

    // ServiceEntries lists all service entries
    ServiceEntries() []Config

    // Gateways lists all gateways bound to the specified workload labels
    Gateways(workloadLabels labels.Collection) []Config

    // QuotaSpecByDestination selects Mixerclient quota specifications
    // associated with destination service instances.
    QuotaSpecByDestination(hostname host.Name) []Config

    // AuthorizationPolicies selects AuthorizationPolicies in the specified namespace.
    AuthorizationPolicies(namespace string) []Config
}

IstioConfigStore is a specialized interface to access config store using Istio configuration types nolint

func MakeIstioStore Uses

func MakeIstioStore(store ConfigStore) IstioConfigStore

MakeIstioStore creates a wrapper around a store. In pilot it is initialized with a ConfigStoreCache, tests only use a regular ConfigStore.

type IstioEgressListenerWrapper Uses

type IstioEgressListenerWrapper struct {
    // The actual IstioEgressListener api object from the Config. It can be
    // nil if this is for the default sidecar scope.
    IstioListener *networking.IstioEgressListener
    // contains filtered or unexported fields
}

IstioEgressListenerWrapper is a wrapper for networking.IstioEgressListener object. The wrapper provides performance optimizations as it allows us to precompute and store the list of services/virtualServices that apply to this listener.

func (*IstioEgressListenerWrapper) Services Uses

func (ilw *IstioEgressListenerWrapper) Services() []*Service

Services returns the list of services imported by this egress listener

func (*IstioEgressListenerWrapper) VirtualServices Uses

func (ilw *IstioEgressListenerWrapper) VirtualServices() []Config

VirtualServices returns the list of virtual services imported by this egress listener

type IstioEndpoint Uses

type IstioEndpoint struct {
    // Labels points to the workload or deployment labels.
    Labels labels.Instance

    // Address is the address of the endpoint, using envoy proto.
    Address string

    // ServicePortName tracks the name of the port, this is used to select the IstioEndpoint by service port.
    ServicePortName string

    // UID identifies the workload, for telemetry purpose.
    UID string

    // EnvoyEndpoint is a cached LbEndpoint, converted from the data, to
    // avoid recomputation
    EnvoyEndpoint *endpoint.LbEndpoint

    // ServiceAccount holds the associated service account.
    ServiceAccount string

    // Network holds the network where this endpoint is present
    Network string

    // The locality where the endpoint is present.
    Locality Locality

    // EndpointPort is the port where the workload is listening, can be different
    // from the service port.
    EndpointPort uint32

    // The load balancing weight associated with this endpoint.
    LbWeight uint32

    // TLSMode endpoint is injected with istio sidecar and ready to configure Istio mTLS
    TLSMode string
}

IstioEndpoint defines a network address (IP:port) associated with an instance of the service. A service has one or more instances each running in a container/VM/pod. If a service has multiple ports, then the same instance IP is expected to be listening on multiple ports (one per each service port). Note that the port associated with an instance does not have to be the same as the port associated with the service. Depending on the network setup (NAT, overlays), this could vary.

For e.g., if catalog.mystore.com is accessible through port 80 and 8080, and it maps to an instance with IP 172.16.0.1, such that connections to port 80 are forwarded to port 55446, and connections to port 8080 are forwarded to port 33333,

then internally, we have two two endpoint structs for the service catalog.mystore.com

--> 172.16.0.1:54546 (with ServicePort pointing to 80) and
--> 172.16.0.1:33333 (with ServicePort pointing to 8080)

TODO: Investigate removing ServiceInstance entirely.

func (*IstioEndpoint) DeepCopy Uses

func (ep *IstioEndpoint) DeepCopy() *IstioEndpoint

DeepCopy creates a clone of IstioEndpoint.

type IstioVersion Uses

type IstioVersion struct {
    Major int
    Minor int
    Patch int
}

IstioVersion encodes the Istio version of the proxy. This is a low key way to do semver style comparisons and generate the appropriate envoy config

func ParseIstioVersion Uses

func ParseIstioVersion(ver string) *IstioVersion

ParseIstioVersion parses a version string and returns IstioVersion struct

func (*IstioVersion) Compare Uses

func (pversion *IstioVersion) Compare(inv *IstioVersion) int

Compare returns -1/0/1 if version is less than, equal or greater than inv To compare only on major, call this function with { X, -1, -1}. to compare only on major & minor, call this function with {X, Y, -1}.

type JwksResolver Uses

type JwksResolver struct {
    // cache for jwksURI.
    JwksURICache cache.ExpiringCache

    // Callback function to invoke when detecting jwt public key change.
    PushFunc func()
    // contains filtered or unexported fields
}

JwksResolver is resolver for jwksURI and jwt public key.

func GetJwtKeyResolver Uses

func GetJwtKeyResolver() *JwksResolver

GetJwtKeyResolver lazy-creates JwtKeyResolver resolves JWT public key and JwksURI.

func NewJwksResolver Uses

func NewJwksResolver(evictionDuration, refreshInterval time.Duration) *JwksResolver

NewJwksResolver creates new instance of JwksResolver.

func (*JwksResolver) Close Uses

func (r *JwksResolver) Close()

Shut down the refresher job. TODO: may need to figure out the right place to call this function. (right now calls it from initDiscoveryService in pkg/bootstrap/server.go).

func (*JwksResolver) GetPublicKey Uses

func (r *JwksResolver) GetPublicKey(jwksURI string) (string, error)

GetPublicKey gets JWT public key and cache the key for future use.

func (*JwksResolver) ResolveJwksURI Uses

func (r *JwksResolver) ResolveJwksURI(policy *v1beta1.RequestAuthentication)

ResolveJwksURI sets jwks_uri through openID discovery if it's not set in request authentication policy.

type Locality Uses

type Locality struct {
    // Label for locality on the endpoint. This is a "/" separated string.
    Label string

    // ClusterID where the endpoint is located
    ClusterID string
}

Locality information for an IstioEndpoint

type MergedGateway Uses

type MergedGateway struct {
    // maps from physical port to virtual servers
    Servers map[uint32][]*networking.Server

    // maps from server to the owning gateway name
    // Needed to select the set of virtual services that apply to a port
    GatewayNameForServer map[*networking.Server]string

    // maps from port names to virtual hosts
    // Used for RDS. No two port names share same port except for HTTPS
    // The typical length of the value is always 1, except for HTTP (not HTTPS),
    ServersByRouteName map[string][]*networking.Server

    // maps from server to a corresponding RDS route name
    // Inverse of ServersByRouteName. Returning this as part of merge result allows to keep route name generation logic
    // encapsulated within the model and, as a side effect, to avoid generating route names twice.
    RouteNamesByServer map[*networking.Server]string
}

MergedGateway describes a set of gateways for a workload merged into a single logical gateway.

TODO: do we need a `func (m *MergedGateway) MergeInto(gateway *networking.Gateway)`?

func MergeGateways Uses

func MergeGateways(gateways ...Config) *MergedGateway

MergeGateways combines multiple gateways targeting the same workload into a single logical Gateway. Note that today any Servers in the combined gateways listening on the same port must have the same protocol. If servers with different protocols attempt to listen on the same port, one of the protocols will be chosen at random.

type Metrics Uses

type Metrics interface {
    // AddMetric will add an case to the metric for the given node.
    AddMetric(metric monitoring.Metric, key string, proxy *Proxy, msg string)
}

Metrics is an interface for capturing metrics on a per-node basis.

type MutualTLSMode Uses

type MutualTLSMode int

MutualTLSMode is the mutule TLS mode specified by authentication policy.

const (
    // MTLSUnknown is used to indicate the variable hasn't been initialized correctly (with the authentication policy).
    MTLSUnknown MutualTLSMode = iota

    // MTLSDisable if authentication policy disable mTLS.
    MTLSDisable

    // MTLSPermissive if authentication policy enable mTLS in permissive mode.
    MTLSPermissive

    // MTLSStrict if authentication policy enable mTLS in strict mode.
    MTLSStrict
)

func (MutualTLSMode) String Uses

func (mode MutualTLSMode) String() string

String converts MutualTLSMode to human readable string for debugging.

type NodeMetaProxyConfig Uses

type NodeMetaProxyConfig meshconfig.ProxyConfig

ProxyConfig can only be marshaled using (gogo) jsonpb. However, the rest of node meta is not a proto To allow marshaling, we need to define a custom type that calls out to the gogo marshaller

func (NodeMetaProxyConfig) MarshalJSON Uses

func (s NodeMetaProxyConfig) MarshalJSON() ([]byte, error)

func (*NodeMetaProxyConfig) UnmarshalJSON Uses

func (s *NodeMetaProxyConfig) UnmarshalJSON(data []byte) error

type NodeMetadata Uses

type NodeMetadata struct {
    // ProxyConfig defines the proxy config specified for a proxy.
    // Note that this setting may be configured different for each proxy, due user overrides
    // or from different versions of proxies connecting. While Pilot has access to the meshConfig.defaultConfig,
    // this field should be preferred if it is present.
    ProxyConfig *NodeMetaProxyConfig `json:"PROXY_CONFIG,omitempty"`

    // IstioVersion specifies the Istio version associated with the proxy
    IstioVersion string `json:"ISTIO_VERSION,omitempty"`

    // Labels specifies the set of workload instance (ex: k8s pod) labels associated with this node.
    Labels map[string]string `json:"LABELS,omitempty"`

    // InstanceIPs is the set of IPs attached to this proxy
    InstanceIPs StringList `json:"INSTANCE_IPS,omitempty"`

    // Namespace is the namespace in which the workload instance is running.
    Namespace string `json:"NAMESPACE,omitempty"`

    // InterceptionMode is the name of the metadata variable that carries info about
    // traffic interception mode at the proxy
    InterceptionMode TrafficInterceptionMode `json:"INTERCEPTION_MODE,omitempty"`

    // ServiceAccount specifies the service account which is running the workload.
    ServiceAccount string `json:"SERVICE_ACCOUNT,omitempty"`

    // RouterMode indicates whether the proxy is functioning as a SNI-DNAT router
    // processing the AUTO_PASSTHROUGH gateway servers
    RouterMode string `json:"ROUTER_MODE,omitempty"`

    // MeshID specifies the mesh ID environment variable.
    MeshID string `json:"MESH_ID,omitempty"`

    // ClusterID defines the cluster the node belongs to.
    ClusterID string `json:"CLUSTER_ID,omitempty"`

    // Network defines the network the node belongs to. It is an optional metadata,
    // set at injection time. When set, the Endpoints returned to a note and not on same network
    // will be replaced with the gateway defined in the settings.
    Network string `json:"NETWORK,omitempty"`

    // RequestedNetworkView specifies the networks that the proxy wants to see
    RequestedNetworkView StringList `json:"REQUESTED_NETWORK_VIEW,omitempty"`

    // PodPorts defines the ports on a pod. This is used to lookup named ports.
    PodPorts PodPortList `json:"POD_PORTS,omitempty"`

    PolicyCheck                  string `json:"policy.istio.io/check,omitempty"`
    PolicyCheckRetries           string `json:"policy.istio.io/checkRetries,omitempty"`
    PolicyCheckBaseRetryWaitTime string `json:"policy.istio.io/checkBaseRetryWaitTime,omitempty"`
    PolicyCheckMaxRetryWaitTime  string `json:"policy.istio.io/checkMaxRetryWaitTime,omitempty"`

    // TLSServerCertChain is the absolute path to server cert-chain file
    TLSServerCertChain string `json:"TLS_SERVER_CERT_CHAIN,omitempty"`
    // TLSServerKey is the absolute path to server private key file
    TLSServerKey string `json:"TLS_SERVER_KEY,omitempty"`
    // TLSServerRootCert is the absolute path to server root cert file
    TLSServerRootCert string `json:"TLS_SERVER_ROOT_CERT,omitempty"`
    // TLSClientCertChain is the absolute path to client cert-chain file
    TLSClientCertChain string `json:"TLS_CLIENT_CERT_CHAIN,omitempty"`
    // TLSClientKey is the absolute path to client private key file
    TLSClientKey string `json:"TLS_CLIENT_KEY,omitempty"`
    // TLSClientRootCert is the absolute path to client root cert file
    TLSClientRootCert string `json:"TLS_CLIENT_ROOT_CERT,omitempty"`

    CertBaseDir string `json:"BASE,omitempty"`
    // SdsEnabled indicates if SDS is enabled or not. This is are set to "1" if true
    SdsEnabled StringBool `json:"SDS,omitempty"`

    // StsPort specifies the port of security token exchange server (STS).
    // Used by envoy filters
    StsPort string `json:"STS_PORT,omitempty"`

    // IdleTimeout specifies the idle timeout for the proxy, in duration format (10s).
    // If not set, no timeout is set.
    IdleTimeout string `json:"IDLE_TIMEOUT,omitempty"`

    // HTTP10 indicates the application behind the sidecar is making outbound http requests with HTTP/1.0
    // protocol. It will enable the "AcceptHttp_10" option on the http options for outbound HTTP listeners.
    // Alpha in 1.1, based on feedback may be turned into an API or change. Set to "1" to enable.
    HTTP10 string `json:"HTTP10,omitempty"`

    // Generator indicates the client wants to use a custom Generator plugin.
    Generator string `json:"GENERATOR,omitempty"`

    // DNSCapture indicates whether the workload has enabled dns capture
    DNSCapture string `json:"DNS_CAPTURE,omitempty"`

    // Contains a copy of the raw metadata. This is needed to lookup arbitrary values.
    // If a value is known ahead of time it should be added to the struct rather than reading from here,
    Raw map[string]interface{} `json:"-"`
}

NodeMetadata defines the metadata associated with a proxy Fields should not be assumed to exist on the proxy, especially newly added fields which will not exist on older versions. The JSON field names should never change, as they are needed for backward compatibility with older proxies nolint: maligned

func ParseMetadata Uses

func ParseMetadata(metadata *structpb.Struct) (*NodeMetadata, error)

ParseMetadata parses the opaque Metadata from an Envoy Node into string key-value pairs. Any non-string values are ignored.

func (NodeMetadata) ProxyConfigOrDefault Uses

func (m NodeMetadata) ProxyConfigOrDefault(def *meshconfig.ProxyConfig) *meshconfig.ProxyConfig

ProxyConfigOrDefault is a helper function to get the ProxyConfig from metadata, or fallback to a default This is useful as the logic should check for proxy config from proxy first and then defer to mesh wide defaults if not present.

func (NodeMetadata) ToStruct Uses

func (m NodeMetadata) ToStruct() *structpb.Struct

Converts this to a protobuf structure. This should be used only for debugging - performance is bad.

type NodeType Uses

type NodeType string

NodeType decides the responsibility of the proxy serves in the mesh

const (
    // SidecarProxy type is used for sidecar proxies in the application containers
    SidecarProxy NodeType = "sidecar"

    // Router type is used for standalone proxies acting as L7/L4 routers
    Router NodeType = "router"
)

type PodPort Uses

type PodPort struct {
    // If specified, this must be an IANA_SVC_NAME and unique within the pod. Each
    // named port in a pod must have a unique name. Name for the port that can be
    // referred to by services.
    // +optional
    Name string `json:"name,omitempty"`
    // Number of port to expose on the pod's IP address.
    // This must be a valid port number, 0 < x < 65536.
    ContainerPort int `json:"containerPort"`
    // Name of the protocol
    Protocol string `json:"protocol"`
}

PodPort describes a mapping of port name to port number. Generally, this is just the definition of a port in Kubernetes, but without depending on Kubernetes api.

type PodPortList Uses

type PodPortList []PodPort

PodPortList defines a list of PodPort's that is serialized as a string This is for legacy reasons, where proper JSON was not supported and was written as a string

func (PodPortList) MarshalJSON Uses

func (l PodPortList) MarshalJSON() ([]byte, error)

func (*PodPortList) UnmarshalJSON Uses

func (l *PodPortList) UnmarshalJSON(data []byte) error

type Port Uses

type Port struct {
    // Name ascribes a human readable name for the port object. When a
    // service has multiple ports, the name field is mandatory
    Name string `json:"name,omitempty"`

    // Port number where the service can be reached. Does not necessarily
    // map to the corresponding port numbers for the instances behind the
    // service.
    Port int `json:"port"`

    // Protocol to be used for the port.
    Protocol protocol.Instance `json:"protocol,omitempty"`
}

Port represents a network port where a service is listening for connections. The port should be annotated with the type of protocol used by the port.

type PortList Uses

type PortList []*Port

PortList is a set of ports

func (PortList) Get Uses

func (ports PortList) Get(name string) (*Port, bool)

Get retrieves a port declaration by name

func (PortList) GetByPort Uses

func (ports PortList) GetByPort(num int) (*Port, bool)

GetByPort retrieves a port declaration by port value

func (PortList) GetNames Uses

func (ports PortList) GetNames() []string

GetNames returns port names

type Probe Uses

type Probe struct {
    Port *Port  `json:"port,omitempty"`
    Path string `json:"path,omitempty"`
}

Probe represents a health probe associated with an instance of service.

type ProbeList Uses

type ProbeList []*Probe

ProbeList is a set of probes

type Proxy Uses

type Proxy struct {

    // Type specifies the node type. First part of the ID.
    Type NodeType

    // IPAddresses is the IP addresses of the proxy used to identify it and its
    // co-located service instances. Example: "10.60.1.6". In some cases, the host
    // where the poxy and service instances reside may have more than one IP address
    IPAddresses []string

    // ID is the unique platform-specific sidecar proxy ID. For k8s it is the pod ID and
    // namespace.
    ID  string

    // Locality is the location of where Envoy proxy runs. This is extracted from
    // the registry where possible. If the registry doesn't provide a locality for the
    // proxy it will use the one sent via ADS that can be configured in the Envoy bootstrap
    Locality *core.Locality

    // DNSDomain defines the DNS domain suffix for short hostnames (e.g.
    // "default.svc.cluster.local")
    DNSDomain string

    // ConfigNamespace defines the namespace where this proxy resides
    // for the purposes of network scoping.
    // NOTE: DO NOT USE THIS FIELD TO CONSTRUCT DNS NAMES
    ConfigNamespace string

    // Metadata key-value pairs extending the Node identifier
    Metadata *NodeMetadata

    // the sidecarScope associated with the proxy
    SidecarScope *SidecarScope

    // the sidecarScope associated with the proxy previously
    PrevSidecarScope *SidecarScope

    // The merged gateways associated with the proxy if this is a Router
    MergedGateway *MergedGateway

    // service instances associated with the proxy
    ServiceInstances []*ServiceInstance

    // Istio version associated with the Proxy
    IstioVersion *IstioVersion

    // GlobalUnicastIP stores the globacl unicast IP if available, otherwise nil
    GlobalUnicastIP string

    // XdsResourceGenerator is used to generate resources for the node, based on the PushContext.
    // If nil, the default networking/core v2 generator is used. This field can be set
    // at connect time, based on node metadata, to trigger generation of a different style
    // of configuration.
    XdsResourceGenerator XdsResourceGenerator

    // Active contains the list of watched resources for the proxy, keyed by the DiscoveryRequest type.
    // It is nil if the Proxy uses the default generator
    Active map[string]*WatchedResource

    // Envoy may request different versions of configuration (XDS v2 vs v3). While internally Pilot will
    // only generate one version or the other, because the protos are wire compatible we can cast to the
    // requested version. This struct keeps track of the types requested for each resource type.
    // For example, if Envoy requests Clusters v3, we would track that here. Pilot would generate a v2
    // cluster response, but change the TypeUrl in the response to be v3.
    RequestedTypes struct {
        CDS string
        EDS string
        RDS string
        LDS string
    }
    // contains filtered or unexported fields
}

Proxy contains information about an specific instance of a proxy (envoy sidecar, gateway, etc). The Proxy is initialized when a sidecar connects to Pilot, and populated from 'node' info in the protocol as well as data extracted from registries.

In current Istio implementation nodes use a 4-parts '~' delimited ID. Type~IPAddress~ID~Domain

func ParseServiceNodeWithMetadata Uses

func ParseServiceNodeWithMetadata(s string, metadata *NodeMetadata) (*Proxy, error)

ParseServiceNodeWithMetadata parse the Envoy Node from the string generated by ServiceNode function and the metadata.

func (*Proxy) DiscoverIPVersions Uses

func (node *Proxy) DiscoverIPVersions()

DiscoverIPVersions discovers the IP Versions supported by Proxy based on its IP addresses.

func (*Proxy) GetInterceptionMode Uses

func (node *Proxy) GetInterceptionMode() TrafficInterceptionMode

GetInterceptionMode extracts the interception mode associated with the proxy from the proxy metadata

func (*Proxy) GetRouterMode Uses

func (node *Proxy) GetRouterMode() RouterMode

GetRouterMode returns the operating mode associated with the router. Assumes that the proxy is of type Router

func (*Proxy) ServiceNode Uses

func (node *Proxy) ServiceNode() string

ServiceNode encodes the proxy node attributes into a URI-acceptable string

func (*Proxy) SetGatewaysForProxy Uses

func (node *Proxy) SetGatewaysForProxy(ps *PushContext)

SetGatewaysForProxy merges the Gateway objects associated with this proxy and caches the merged object in the proxy Node. This is a convenience hack so that callers can simply call push.MergedGateways(node) instead of having to fetch all the gateways and invoke the merge call in multiple places (lds/rds).

func (*Proxy) SetServiceInstances Uses

func (node *Proxy) SetServiceInstances(serviceDiscovery ServiceDiscovery) error

func (*Proxy) SetSidecarScope Uses

func (node *Proxy) SetSidecarScope(ps *PushContext)

SetSidecarScope identifies the sidecar scope object associated with this proxy and updates the proxy Node. This is a convenience hack so that callers can simply call push.Services(node) while the implementation of push.Services can return the set of services from the proxyNode's sidecar scope or from the push context's set of global services. Similar logic applies to push.VirtualServices and push.DestinationRule. The short cut here is useful only for CDS and parts of RDS generation code.

Listener generation code will still use the SidecarScope object directly as it needs the set of services for each listener port.

func (*Proxy) SetWorkloadLabels Uses

func (node *Proxy) SetWorkloadLabels(env *Environment) error

SetWorkloadLabels will set the node.Metadata.Labels only when it is nil.

func (*Proxy) SupportsIPv4 Uses

func (node *Proxy) SupportsIPv4() bool

SupportsIPv4 returns true if proxy supports IPv4 addresses.

func (*Proxy) SupportsIPv6 Uses

func (node *Proxy) SupportsIPv6() bool

SupportsIPv6 returns true if proxy supports IPv6 addresses.

type ProxyPushStatus Uses

type ProxyPushStatus struct {
    Proxy   string `json:"proxy,omitempty"`
    Message string `json:"message,omitempty"`
}

ProxyPushStatus represents an event captured during config push to proxies. It may contain additional message and the affected proxy.

type PushContext Uses

type PushContext struct {

    // ProxyStatus is keyed by the error code, and holds a map keyed
    // by the ID.
    ProxyStatus map[string]map[string]ProxyPushStatus

    // Mutex is used to protect the below store.
    // All data is set when the PushContext object is populated in `InitContext`,
    // data should not be changed by plugins.
    Mutex sync.Mutex `json:"-"`

    // ServiceByHostnameAndNamespace has all services, indexed by hostname then namespace.
    ServiceByHostnameAndNamespace map[host.Name]map[string]*Service `json:"-"`
    // ServiceAccounts contains a map of hostname and port to service accounts.
    ServiceAccounts map[host.Name]map[int][]string `json:"-"`
    // QuotaSpec has all quota specs
    QuotaSpec []Config `json:"-"`
    // QuotaSpecBindings has all quota bindings
    QuotaSpecBinding []Config `json:"-"`

    // AuthzPolicies stores the existing authorization policies in the cluster. Could be nil if there
    // are no authorization policies in the cluster.
    AuthzPolicies *AuthorizationPolicies `json:"-"`

    // Mesh configuration for the mesh.
    Mesh *meshconfig.MeshConfig `json:"-"`

    // Networks configuration.
    Networks *meshconfig.MeshNetworks `json:"-"`

    // Discovery interface for listing services and instances.
    ServiceDiscovery `json:"-"`

    // Config interface for listing routing rules
    IstioConfigStore `json:"-"`

    // AuthnBetaPolicies contains (beta) Authn policies by namespace.
    AuthnBetaPolicies *AuthenticationPolicies `json:"-"`

    Version string
    // contains filtered or unexported fields
}

PushContext tracks the status of a push - metrics and errors. Metrics are reset after a push - at the beginning all values are zero, and when push completes the status is reset. The struct is exposed in a debug endpoint - fields public to allow easy serialization as json.

func NewPushContext Uses

func NewPushContext() *PushContext

NewPushContext creates a new PushContext structure to track push status.

func (*PushContext) AddMetric Uses

func (ps *PushContext) AddMetric(metric monitoring.Metric, key string, proxy *Proxy, msg string)

AddMetric will add an case to the metric.

func (*PushContext) BestEffortInferServiceMTLSMode Uses

func (ps *PushContext) BestEffortInferServiceMTLSMode(service *Service, port *Port) MutualTLSMode

BestEffortInferServiceMTLSMode infers the mTLS mode for the service + port from all authentication policies (both alpha and beta) in the system. The function always returns MTLSUnknown for external service. The resulst is a best effort. It is because the PeerAuthentication is workload-based, this function is unable to compute the correct service mTLS mode without knowing service to workload binding. For now, this function uses only mesh and namespace level PeerAuthentication and ignore workload & port level policies. This function is used to give a hint for auto-mTLS configuration on client side.

func (*PushContext) DestinationRule Uses

func (ps *PushContext) DestinationRule(proxy *Proxy, service *Service) *Config

DestinationRule returns a destination rule for a service name in a given domain.

func (*PushContext) EnvoyFilters Uses

func (ps *PushContext) EnvoyFilters(proxy *Proxy) *EnvoyFilterWrapper

EnvoyFilters return the merged EnvoyFilterWrapper of a proxy

func (*PushContext) GatewayServices Uses

func (ps *PushContext) GatewayServices(proxy *Proxy) []*Service

GatewayServices returns the set of services which are referred from the proxy gateways.

func (*PushContext) InitContext Uses

func (ps *PushContext) InitContext(env *Environment, oldPushContext *PushContext, pushReq *PushRequest) error

InitContext will initialize the data structures used for code generation. This should be called before starting the push, from the thread creating the push context.

func (*PushContext) IsClusterLocal Uses

func (ps *PushContext) IsClusterLocal(service *Service) bool

IsClusterLocal indicates whether the endpoints for the service should only be accessible to clients within the cluster.

func (*PushContext) IsMixerEnabled Uses

func (ps *PushContext) IsMixerEnabled() bool

IsMixerEnabled returns true if mixer is enabled in the Mesh config.

func (*PushContext) NetworkGateways Uses

func (ps *PushContext) NetworkGateways() map[string][]*Gateway

func (*PushContext) NetworkGatewaysByNetwork Uses

func (ps *PushContext) NetworkGatewaysByNetwork(network string) []*Gateway

func (*PushContext) OnConfigChange Uses

func (ps *PushContext) OnConfigChange()

OnConfigChange is called when a config change is detected.

func (*PushContext) QuotaSpecByDestination Uses

func (ps *PushContext) QuotaSpecByDestination(hostname host.Name) []Config

func (*PushContext) Services Uses

func (ps *PushContext) Services(proxy *Proxy) []*Service

Services returns the list of services that are visible to a Proxy in a given config namespace

func (*PushContext) SetDestinationRules Uses

func (ps *PushContext) SetDestinationRules(configs []Config)

SetDestinationRules is updates internal structures using a set of configs. Split out of DestinationRule expensive conversions, computed once per push. This also allows tests to inject a config without having the mock. This will not work properly for Sidecars, which will precompute their destination rules on init

func (*PushContext) StatusJSON Uses

func (ps *PushContext) StatusJSON() ([]byte, error)

JSON implements json.Marshaller, with a lock.

func (*PushContext) SubsetToLabels Uses

func (ps *PushContext) SubsetToLabels(proxy *Proxy, subsetName string, hostname host.Name) labels.Collection

SubsetToLabels returns the labels associated with a subset of a given service.

func (*PushContext) UpdateMetrics Uses

func (ps *PushContext) UpdateMetrics()

UpdateMetrics will update the prometheus metrics based on the current status of the push.

func (*PushContext) VirtualServices Uses

func (ps *PushContext) VirtualServices(proxy *Proxy, gateways map[string]bool) []Config

VirtualServices lists all virtual services bound to the specified gateways This replaces store.VirtualServices. Used only by the gateways Sidecars use the egressListener.VirtualServices().

type PushRequest Uses

type PushRequest struct {
    // Full determines whether a full push is required or not. If set to false, only endpoints will be sent.
    Full bool

    // ConfigsUpdated keeps track of configs that have changed.
    // This is used as an optimization to avoid unnecessary pushes to proxies that are scoped with a Sidecar.
    // If this is empty, then all proxies will get an update.
    // Otherwise only proxies depend on these configs will get an update.
    // The kind of resources are defined in pkg/config/schemas.
    ConfigsUpdated map[ConfigKey]struct{}

    // Push stores the push context to use for the update. This may initially be nil, as we will
    // debounce changes before a PushContext is eventually created.
    Push *PushContext

    // Start represents the time a push was started. This represents the time of adding to the PushQueue.
    // Note that this does not include time spent debouncing.
    Start time.Time

    // Reason represents the reason for requesting a push. This should only be a fixed set of values,
    // to avoid unbounded cardinality in metrics. If this is not set, it may be automatically filled in later.
    // There should only be multiple reasons if the push request is the result of two distinct triggers, rather than
    // classifying a single trigger as having multiple reasons.
    Reason []TriggerReason
}

PushRequest defines a request to push to proxies It is used to send updates to the config update debouncer and pass to the PushQueue.

func (*PushRequest) Merge Uses

func (first *PushRequest) Merge(other *PushRequest) *PushRequest

Merge two update requests together

type Resolution Uses

type Resolution int

Resolution indicates how the service instances need to be resolved before routing traffic.

const (
    // ClientSideLB implies that the proxy will decide the endpoint from its local lb pool
    ClientSideLB Resolution = iota
    // DNSLB implies that the proxy will resolve a DNS address and forward to the resolved address
    DNSLB
    // Passthrough implies that the proxy should forward traffic to the destination IP requested by the caller
    Passthrough
)

func (Resolution) String Uses

func (resolution Resolution) String() string

String converts Resolution in to String.

type Resources Uses

type Resources = []*any.Any

Request is an alias for array of marshaled resources.

type RouterMode Uses

type RouterMode string

RouterMode decides the behavior of Istio Gateway (normal or sni-dnat)

const (
    // StandardRouter is the normal gateway mode
    StandardRouter RouterMode = "standard"

    // SniDnatRouter is used for bridging two networks
    SniDnatRouter RouterMode = "sni-dnat"
)

type SdsCertificateConfig Uses

type SdsCertificateConfig struct {
    CertificatePath   string
    PrivateKeyPath    string
    CaCertificatePath string
}

SdsCertificateConfig holds TLS certs needed to build SDS TLS context.

func SdsCertificateConfigFromResourceName Uses

func SdsCertificateConfigFromResourceName(resource string) (SdsCertificateConfig, bool)

SdsCertificateConfigFromResourceName converts the provided resource name into a SdsCertificateConfig If the resource name is not valid, false is returned.

func (SdsCertificateConfig) GetResourceName Uses

func (s SdsCertificateConfig) GetResourceName() string

GetResourceName converts a SdsCertificateConfig to a string to be used as an SDS resource name

func (SdsCertificateConfig) GetRootResourceName Uses

func (s SdsCertificateConfig) GetRootResourceName() string

GetRootResourceName converts a SdsCertificateConfig to a string to be used as an SDS resource name for the root

func (SdsCertificateConfig) IsKeyCertificate Uses

func (s SdsCertificateConfig) IsKeyCertificate() bool

IsKeyCertificate returns true if this config represents key certificate config.

func (SdsCertificateConfig) IsRootCertificate Uses

func (s SdsCertificateConfig) IsRootCertificate() bool

IsRootCertificate returns true if this config represents a root certificate config.

type Service Uses

type Service struct {
    // Attributes contains additional attributes associated with the service
    // used mostly by mixer and RBAC for policy enforcement purposes.
    Attributes ServiceAttributes

    // Ports is the set of network ports where the service is listening for
    // connections
    Ports PortList `json:"ports,omitempty"`

    // ServiceAccounts specifies the service accounts that run the service.
    ServiceAccounts []string `json:"serviceAccounts,omitempty"`

    // CreationTime records the time this service was created, if available.
    CreationTime time.Time `json:"creationTime,omitempty"`

    // Name of the service, e.g. "catalog.mystore.com"
    Hostname host.Name `json:"hostname"`

    // Address specifies the service IPv4 address of the load balancer
    Address string `json:"address,omitempty"`

    // Protect concurrent ClusterVIPs read/write
    Mutex sync.RWMutex

    // ClusterVIPs specifies the service address of the load balancer
    // in each of the clusters where the service resides
    ClusterVIPs map[string]string `json:"cluster-vips,omitempty"`

    // Resolution indicates how the service instances need to be resolved before routing
    // traffic. Most services in the service registry will use static load balancing wherein
    // the proxy will decide the service instance that will receive the traffic. Service entries
    // could either use DNS load balancing (i.e. proxy will query DNS server for the IP of the service)
    // or use the passthrough model (i.e. proxy will forward the traffic to the network endpoint requested
    // by the caller)
    Resolution Resolution

    // MeshExternal (if true) indicates that the service is external to the mesh.
    // These services are defined using Istio's ServiceEntry spec.
    MeshExternal bool
}

Service describes an Istio service (e.g., catalog.mystore.com:8080) Each service has a fully qualified domain name (FQDN) and one or more ports where the service is listening for connections. *Optionally*, a service can have a single load balancer/virtual IP address associated with it, such that the DNS queries for the FQDN resolves to the virtual IP address (a load balancer IP).

E.g., in kubernetes, a service foo is associated with foo.default.svc.cluster.local hostname, has a virtual IP of 10.0.1.1 and listens on ports 80, 8080

func (*Service) DeepCopy Uses

func (s *Service) DeepCopy() *Service

DeepCopy creates a clone of Service. TODO : See if there is any efficient alternative to this function - copystructure can not be used as is because Service has sync.RWMutex that can not be copied.

func (*Service) External Uses

func (s *Service) External() bool

External predicate checks whether the service is external

func (*Service) GetServiceAddressForProxy Uses

func (s *Service) GetServiceAddressForProxy(node *Proxy) string

GetServiceAddressForProxy returns a Service's IP address specific to the cluster where the node resides

func (*Service) Validate Uses

func (s *Service) Validate() error

Validate ensures that the service object is well-defined

type ServiceAttributes Uses

type ServiceAttributes struct {
    // ServiceRegistry indicates the backing service registry system where this service
    // was sourced from.
    // TODO: move the ServiceRegistry type from platform.go to model
    ServiceRegistry string
    // Name is "destination.service.name" attribute
    Name string
    // Namespace is "destination.service.namespace" attribute
    Namespace string
    // UID is "destination.service.uid" attribute
    UID string
    // ExportTo defines the visibility of Service in
    // a namespace when the namespace is imported.
    ExportTo map[visibility.Instance]bool

    // LabelSelectors are the labels used by the service to select workloads.
    // Applicable to both Kubernetes and ServiceEntries.
    LabelSelectors map[string]string

    // ClusterExternalAddresses is a mapping between a cluster name and the external
    // address(es) to access the service from outside the cluster.
    // Used by the aggregator to aggregate the Attributes.ClusterExternalAddresses
    // for clusters where the service resides
    ClusterExternalAddresses map[string][]string

    // ClusterExternalPorts is a mapping between a cluster name and the service port
    // to node port mappings for a given service. When accessing the service via
    // node port IPs, we need to use the kubernetes assigned node ports of the service
    // The port that the user provides in the meshNetworks config is the service port.
    // We translate that to the appropriate node port here.
    ClusterExternalPorts map[string]map[uint32]uint32
}

ServiceAttributes represents a group of custom attributes of the service.

type ServiceDiscovery Uses

type ServiceDiscovery interface {
    // Services list declarations of all services in the system
    Services() ([]*Service, error)

    // GetService retrieves a service by host name if it exists
    GetService(hostname host.Name) (*Service, error)

    // InstancesByPort retrieves instances for a service on the given ports with labels that match
    // any of the supplied labels. All instances match an empty tag list.
    //
    // For example, consider an example of catalog.mystore.com:
    // Instances(catalog.myservice.com, 80) ->
    //      --> IstioEndpoint(172.16.0.1:8888), Service(catalog.myservice.com), Labels(foo=bar)
    //      --> IstioEndpoint(172.16.0.2:8888), Service(catalog.myservice.com), Labels(foo=bar)
    //      --> IstioEndpoint(172.16.0.3:8888), Service(catalog.myservice.com), Labels(kitty=cat)
    //      --> IstioEndpoint(172.16.0.4:8888), Service(catalog.myservice.com), Labels(kitty=cat)
    //
    // Calling Instances with specific labels returns a trimmed list.
    // e.g., Instances(catalog.myservice.com, 80, foo=bar) ->
    //      --> IstioEndpoint(172.16.0.1:8888), Service(catalog.myservice.com), Labels(foo=bar)
    //      --> IstioEndpoint(172.16.0.2:8888), Service(catalog.myservice.com), Labels(foo=bar)
    //
    // Similar concepts apply for calling this function with a specific
    // port, hostname and labels.
    //
    // Introduced in Istio 0.8. It is only called with 1 port.
    // CDS (clusters.go) calls it for building 'dnslb' type clusters.
    // EDS calls it for building the endpoints result.
    // Consult istio-dev before using this for anything else (except debugging/tools)
    InstancesByPort(svc *Service, servicePort int, labels labels.Collection) ([]*ServiceInstance, error)

    // GetProxyServiceInstances returns the service instances that co-located with a given Proxy
    //
    // Co-located generally means running in the same network namespace and security context.
    //
    // A Proxy operating as a Sidecar will return a non-empty slice.  A stand-alone Proxy
    // will return an empty slice.
    //
    // There are two reasons why this returns multiple ServiceInstances instead of one:
    // - A ServiceInstance has a single IstioEndpoint which has a single Port.  But a Service
    //   may have many ports.  So a workload implementing such a Service would need
    //   multiple ServiceInstances, one for each port.
    // - A single workload may implement multiple logical Services.
    //
    // In the second case, multiple services may be implemented by the same physical port number,
    // though with a different ServicePort and IstioEndpoint for each.  If any of these overlapping
    // services are not HTTP or H2-based, behavior is undefined, since the listener may not be able to
    // determine the intended destination of a connection without a Host header on the request.
    GetProxyServiceInstances(*Proxy) ([]*ServiceInstance, error)

    GetProxyWorkloadLabels(*Proxy) (labels.Collection, error)

    // GetIstioServiceAccounts returns a list of service accounts looked up from
    // the specified service hostname and ports.
    // Deprecated - service account tracking moved to XdsServer, incremental.
    GetIstioServiceAccounts(svc *Service, ports []int) []string
}

ServiceDiscovery enumerates Istio service instances. nolint: lll

type ServiceInstance Uses

type ServiceInstance struct {
    Service     *Service       `json:"service,omitempty"`
    ServicePort *Port          `json:"servicePort,omitempty"`
    Endpoint    *IstioEndpoint `json:"endpoint,omitempty"`
}

ServiceInstance represents an individual instance of a specific version of a service. It binds a network endpoint (ip:port), the service description (which is oblivious to various versions) and a set of labels that describe the service version associated with this instance.

Since a ServiceInstance has a single IstioEndpoint, which has a single port, multiple ServiceInstances are required to represent a workload that listens on multiple ports.

The labels associated with a service instance are unique per a network endpoint. There is one well defined set of labels for each service instance network endpoint.

For example, the set of service instances associated with catalog.mystore.com are modeled like this

--> IstioEndpoint(172.16.0.1:8888), Service(catalog.myservice.com), Labels(foo=bar)
--> IstioEndpoint(172.16.0.2:8888), Service(catalog.myservice.com), Labels(foo=bar)
--> IstioEndpoint(172.16.0.3:8888), Service(catalog.myservice.com), Labels(kitty=cat)
--> IstioEndpoint(172.16.0.4:8888), Service(catalog.myservice.com), Labels(kitty=cat)

func (*ServiceInstance) DeepCopy Uses

func (instance *ServiceInstance) DeepCopy() *ServiceInstance

DeepCopy creates a copy of ServiceInstance.

func (*ServiceInstance) Validate Uses

func (instance *ServiceInstance) Validate() error

Validate ensures that the service instance is well-defined

type SidecarScope Uses

type SidecarScope struct {
    // The crd itself. Can be nil if we are constructing the default
    // sidecar scope
    Config *Config

    // Set of egress listeners, and their associated services.  A sidecar
    // scope should have either ingress/egress listeners or both.  For
    // every proxy workload that maps to a sidecar API object (or the
    // default object), we will go through every egress listener in the
    // object and process the Envoy listener or RDS based on the imported
    // services/virtual services in that listener.
    EgressListeners []*IstioEgressListenerWrapper

    // HasCustomIngressListeners is a convenience variable that if set to
    // true indicates that the config object has one or more listeners.
    // If set to false, networking code should derive the inbound
    // listeners from the proxy service instances
    HasCustomIngressListeners bool

    // OutboundTrafficPolicy defines the outbound traffic policy for this sidecar.
    // If OutboundTrafficPolicy is ALLOW_ANY traffic to unknown destinations will
    // be forwarded.
    OutboundTrafficPolicy *networking.OutboundTrafficPolicy
    // contains filtered or unexported fields
}

SidecarScope is a wrapper over the Sidecar resource with some preprocessed data to determine the list of services, virtualServices, and destinationRules that are accessible to a given sidecar. Precomputing the list of services, virtual services, dest rules for a sidecar improves performance as we no longer need to compute this list for every sidecar. We simply have to match a sidecar to a SidecarScope. Note that this is not the same as public/private scoped services. The list of services seen by every sidecar scope (namespace wide or per workload) depends on the imports, the listeners, and other settings.

Every proxy workload of SidecarProxy type will always map to a SidecarScope object. If the proxy's namespace does not have a user specified Sidecar CRD, we will construct one that has a catch all egress listener that imports every public service/virtualService in the mesh.

func ConvertToSidecarScope Uses

func ConvertToSidecarScope(ps *PushContext, sidecarConfig *Config, configNamespace string) *SidecarScope

ConvertToSidecarScope converts from Sidecar config to SidecarScope object

func DefaultSidecarScopeForNamespace Uses

func DefaultSidecarScopeForNamespace(ps *PushContext, configNamespace string) *SidecarScope

DefaultSidecarScopeForNamespace is a sidecar scope object with a default catch all egress listener that matches the default Istio behavior: a sidecar has listeners for all services in the mesh We use this scope when the user has not set any sidecar Config for a given config namespace.

func (*SidecarScope) AddConfigDependencies Uses

func (sc *SidecarScope) AddConfigDependencies(dependencies ...ConfigKey)

AddConfigDependencies add extra config dependencies to this scope. This action should be done before the SidecarScope being used to avoid concurrent read/write.

func (*SidecarScope) DependsOnConfig Uses

func (sc *SidecarScope) DependsOnConfig(config ConfigKey) bool

DependsOnConfig determines if the proxy depends on the given config. Returns whether depends on this config or this kind of config is not scoped(unknown to be depended) here.

func (*SidecarScope) DestinationRule Uses

func (sc *SidecarScope) DestinationRule(hostname host.Name) *Config

DestinationRule returns the destination rule applicable for a given hostname used by CDS code

func (*SidecarScope) GetEgressListenerForRDS Uses

func (sc *SidecarScope) GetEgressListenerForRDS(port int, bind string) *IstioEgressListenerWrapper

GetEgressListenerForRDS returns the egress listener corresponding to the listener port or the bind address or the catch all listener

func (*SidecarScope) ServiceForHostname Uses

func (sc *SidecarScope) ServiceForHostname(hostname host.Name, serviceByHostname map[host.Name]map[string]*Service) *Service

ServiceForHostname returns the service associated with a given hostname following SidecarScope

func (*SidecarScope) Services Uses

func (sc *SidecarScope) Services() []*Service

Services returns the list of services imported across all egress listeners by this Sidecar config

type StringBool Uses

type StringBool bool

StringBool defines a boolean that is serialized as a string for legacy reasons

func (StringBool) MarshalJSON Uses

func (s StringBool) MarshalJSON() ([]byte, error)

func (*StringBool) UnmarshalJSON Uses

func (s *StringBool) UnmarshalJSON(data []byte) error

type StringList Uses

type StringList []string

StringList is a list that will be marshaled to a comma separate string in Json

func (StringList) MarshalJSON Uses

func (l StringList) MarshalJSON() ([]byte, error)

func (*StringList) UnmarshalJSON Uses

func (l *StringList) UnmarshalJSON(data []byte) error

type TrafficDirection Uses

type TrafficDirection string

TrafficDirection defines whether traffic exists a service instance or enters a service instance

const (
    // TrafficDirectionInbound indicates inbound traffic
    TrafficDirectionInbound TrafficDirection = "inbound"
    // TrafficDirectionOutbound indicates outbound traffic
    TrafficDirectionOutbound TrafficDirection = "outbound"
)

func ParseSubsetKey Uses

func ParseSubsetKey(s string) (direction TrafficDirection, subsetName string, hostname host.Name, port int)

ParseSubsetKey is the inverse of the BuildSubsetKey method

type TrafficInterceptionMode Uses

type TrafficInterceptionMode string

TrafficInterceptionMode indicates how traffic to/from the workload is captured and sent to Envoy. This should not be confused with the CaptureMode in the API that indicates how the user wants traffic to be intercepted for the listener. TrafficInterceptionMode is always derived from the Proxy metadata

const (
    // InterceptionNone indicates that the workload is not using IPtables for traffic interception
    InterceptionNone TrafficInterceptionMode = "NONE"

    // InterceptionTproxy implies traffic intercepted by IPtables with TPROXY mode
    InterceptionTproxy TrafficInterceptionMode = "TPROXY"

    // InterceptionRedirect implies traffic intercepted by IPtables with REDIRECT mode
    // This is our default mode
    InterceptionRedirect TrafficInterceptionMode = "REDIRECT"
)

type TriggerReason Uses

type TriggerReason string
const (
    // Describes a push triggered by an Endpoint change
    EndpointUpdate TriggerReason = "endpoint"
    // Describes a push triggered by a config (generally and Istio CRD) change.
    ConfigUpdate TriggerReason = "config"
    // Describes a push triggered by a Service change
    ServiceUpdate TriggerReason = "service"
    // Describes a push triggered by a change to an individual proxy (such as label change)
    ProxyUpdate TriggerReason = "proxy"
    // Describes a push triggered by a change to global config, such as mesh config
    GlobalUpdate TriggerReason = "global"
    // Describes a push triggered by an unknown reason
    UnknownTrigger TriggerReason = "unknown"
    // Describes a push triggered for debugging
    DebugTrigger TriggerReason = "debug"
)

type WatchedResource Uses

type WatchedResource struct {
    // TypeUrl is copied from the DiscoveryRequest.TypeUrl that initiated watching this resource.
    // nolint
    TypeUrl string

    // ResourceNames tracks the list of resources that are actively watched. If empty, all resources of the
    // TypeUrl type are watched.
    ResourceNames []string

    // VersionSent is the version of the resource included in the last sent response.
    // It corresponds to the [Cluster/Route/Listener]VersionSent in the XDS package.
    VersionSent string

    // NonceSent is the nonce sent in the last sent response. If it is equal with NonceAcked, the
    // last message has been processed. If empty: we never sent a message of this type.
    NonceSent string

    // VersionAcked represents the version that was applied successfully. It can be different from
    // VersionSent: if NonceSent == NonceAcked and versions are different it means the client rejected
    // the last version, and VersionAcked is the last accepted and active config.
    // If empty it means the client has no accepted/valid version, and is not ready.
    VersionAcked string

    // NonceAcked is the last acked message.
    NonceAcked string

    // LastSent tracks the time of the generated push, to determine the time it takes the client to ack.
    LastSent time.Time

    // Updates count the number of generated updates for the resource
    Updates int

    // LastSize tracks the size of the last update
    LastSize int
}

WatchedResource tracks an active DiscoveryRequest type.

type XDSUpdater Uses

type XDSUpdater interface {

    // EDSUpdate is called when the list of endpoints or labels in a Service is changed.
    // For each cluster and hostname, the full list of active endpoints (including empty list)
    // must be sent. The shard name is used as a key - current implementation is using the
    // registry name.
    EDSUpdate(shard, hostname string, namespace string, entry []*IstioEndpoint) error

    // SvcUpdate is called when a service definition is updated/deleted.
    SvcUpdate(shard, hostname string, namespace string, event Event)

    // ConfigUpdate is called to notify the XDS server of config updates and request a push.
    // The requests may be collapsed and throttled.
    ConfigUpdate(req *PushRequest)

    // ProxyUpdate is called to notify the XDS server to send a push to the specified proxy.
    // The requests may be collapsed and throttled.
    ProxyUpdate(clusterID, ip string)
}

XDSUpdater is used for direct updates of the xDS model and incremental push. Pilot uses multiple registries - for example each K8S cluster is a registry instance, as well as consul. Each registry is responsible for tracking a set of endpoints associated with mesh services, and calling the EDSUpdate on changes. A registry may group endpoints for a service in smaller subsets - for example by deployment, or to deal with very large number of endpoints for a service. We want to avoid passing around large objects - like full list of endpoints for a registry, or the full list of endpoints for a service across registries, since it limits scalability.

Future optimizations will include grouping the endpoints by labels, gateway or region to reduce the time when subsetting or split-horizon is used. This design assumes pilot tracks all endpoints in the mesh and they fit in RAM - so limit is few M endpoints. It is possible to split the endpoint tracking in future.

type XdsResourceGenerator Uses

type XdsResourceGenerator interface {
    Generate(proxy *Proxy, push *PushContext, w *WatchedResource, updates XdsUpdates) Resources
}

XdsResourceGenerator creates the response for a typeURL DiscoveryRequest. If no generator is associated with a Proxy, the default (a networking.core.ConfigGenerator instance) will be used. The server may associate a different generator based on client metadata. Different WatchedResources may use same or different Generator.

type XdsUpdates Uses

type XdsUpdates = map[ConfigKey]struct{}

XdsUpdates include information about the subset of updated resources. See for example EDS incremental updates.

Directories

PathSynopsis
test

Package model imports 52 packages (graph) and is imported by 123 packages. Updated 2020-07-02. Refresh now. Tools for package owners.