model

package
v0.0.0-...-a026827 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RouteRule defines the type for the route rule configuration
	RouteRule = "route-rule"
	// RouteRuleProto message name
	RouteRuleProto = "istio.proxy.v1.config.RouteRule"

	// IngressRule type
	IngressRule = "ingress-rule"
	// IngressRuleProto message name
	IngressRuleProto = "istio.proxy.v1.config.IngressRule"

	// DestinationPolicy defines the type for the destination policy configuration
	DestinationPolicy = "destination-policy"
	// DestinationPolicyProto message name
	DestinationPolicyProto = "istio.proxy.v1.config.DestinationPolicy"

	// HeaderURI is URI HTTP header
	HeaderURI = "uri"

	// HeaderAuthority is authority HTTP header
	HeaderAuthority = "authority"
)

Variables

View Source
var (
	// RouteRuleDescriptor describes route rules
	RouteRuleDescriptor = ProtoSchema{
		Type:        RouteRule,
		MessageName: RouteRuleProto,
		Validate:    ValidateRouteRule,
		Key: func(config proto.Message) string {
			rule := config.(*proxyconfig.RouteRule)
			return rule.Name
		},
	}

	// IngressRuleDescriptor describes ingress rules
	IngressRuleDescriptor = ProtoSchema{
		Type:        IngressRule,
		MessageName: IngressRuleProto,
		Validate:    ValidateIngressRule,
		Key: func(config proto.Message) string {
			rule := config.(*proxyconfig.IngressRule)
			return rule.Name
		},
	}

	// DestinationPolicyDescriptor describes destination rules
	DestinationPolicyDescriptor = ProtoSchema{
		Type:        DestinationPolicy,
		MessageName: DestinationPolicyProto,
		Validate:    ValidateDestinationPolicy,
		Key: func(config proto.Message) string {
			return config.(*proxyconfig.DestinationPolicy).Destination
		},
	}

	// IstioConfigTypes lists all Istio config types with schemas and validation
	IstioConfigTypes = ConfigDescriptor{
		RouteRuleDescriptor,
		IngressRuleDescriptor,
		DestinationPolicyDescriptor,
	}
)

Functions

func ApplyJSON

func ApplyJSON(js string, pb proto.Message) error

ApplyJSON unmarshals a JSON string into a proto message

func ApplyYAML

func ApplyYAML(yml string, pb proto.Message) error

ApplyYAML unmarshals a YAML string into a proto message

func IsDNS1123Label

func IsDNS1123Label(value string) bool

IsDNS1123Label tests for a string that conforms to the definition of a label in DNS (RFC 1123).

func ParseServiceKey

func ParseServiceKey(s string) (hostname string, ports PortList, tags TagsList)

ParseServiceKey is the inverse of the Service.String() method

func ServiceKey

func ServiceKey(hostname string, servicePorts PortList, serviceTags TagsList) string

ServiceKey generates a service key for a collection of ports and tags

func ValidateAbort

func ValidateAbort(abort *proxyconfig.HTTPFaultInjection_Abort) (errs error)

ValidateAbort checks that fault injection abort is well-formed

func ValidateAbortHTTPStatus

func ValidateAbortHTTPStatus(httpStatus *proxyconfig.HTTPFaultInjection_Abort_HttpStatus) (errs error)

ValidateAbortHTTPStatus checks that fault injection abort HTTP status is valid

func ValidateCIDRBlock

func ValidateCIDRBlock(cidr string) error

ValidateCIDRBlock validates that a string in "CIDR notation" or "Dot-decimal notation"

func ValidateCircuitBreaker

func ValidateCircuitBreaker(cb *proxyconfig.CircuitBreaker) (errs error)

ValidateCircuitBreaker validates Circuit Breaker

func ValidateConnectTimeout

func ValidateConnectTimeout(timeout *duration.Duration) error

ValidateConnectTimeout validates the envoy conncection timeout

func ValidateDelay

func ValidateDelay(delay *proxyconfig.HTTPFaultInjection_Delay) (errs error)

ValidateDelay checks that fault injection delay is well-formed

func ValidateDestinationPolicy

func ValidateDestinationPolicy(msg proto.Message) error

ValidateDestinationPolicy checks proxy policies

func ValidateDestinationWeight

func ValidateDestinationWeight(dw *proxyconfig.DestinationWeight) (errs error)

ValidateDestinationWeight validates DestinationWeight

func ValidateDuration

func ValidateDuration(pd *duration.Duration) error

ValidateDuration checks that a proto duration is well-formed

func ValidateDurationRange

func ValidateDurationRange(dur, min, max time.Duration) error

ValidateDurationRange verifies range is in specified duration

func ValidateFQDN

func ValidateFQDN(fqdn string) error

ValidateFQDN checks a fully-qualified domain name

func ValidateFloatPercent

func ValidateFloatPercent(val float32) error

ValidateFloatPercent checks that percent is in range

func ValidateHTTPFault

func ValidateHTTPFault(fault *proxyconfig.HTTPFaultInjection) (errs error)

ValidateHTTPFault validates HTTP Fault

func ValidateHTTPHeaderName

func ValidateHTTPHeaderName(name string) error

ValidateHTTPHeaderName checks that the name is lower-case

func ValidateHTTPRetries

func ValidateHTTPRetries(retry *proxyconfig.HTTPRetry) (errs error)

ValidateHTTPRetries validates HTTP Retries

func ValidateHTTPTimeout

func ValidateHTTPTimeout(timeout *proxyconfig.HTTPTimeout) (errs error)

ValidateHTTPTimeout validates HTTP Timeout

func ValidateIPv4Address

func ValidateIPv4Address(addr string) error

ValidateIPv4Address validates that a string in "CIDR notation" or "Dot-decimal notation"

func ValidateIPv4Subnet

func ValidateIPv4Subnet(subnet string) error

ValidateIPv4Subnet checks that a string is in "CIDR notation" or "Dot-decimal notation"

func ValidateIngressRule

func ValidateIngressRule(msg proto.Message) error

ValidateIngressRule checks ingress rules

func ValidateL4Fault

func ValidateL4Fault(fault *proxyconfig.L4FaultInjection) (errs error)

ValidateL4Fault validates L4 Fault

func ValidateL4MatchAttributes

func ValidateL4MatchAttributes(ma *proxyconfig.L4MatchAttributes) (errs error)

ValidateL4MatchAttributes validates L4 Match Attributes

func ValidateLoadBalancing

func ValidateLoadBalancing(lb *proxyconfig.LoadBalancing) (errs error)

ValidateLoadBalancing validates Load Balancing

func ValidateMatchCondition

func ValidateMatchCondition(mc *proxyconfig.MatchCondition) (errs error)

ValidateMatchCondition validates a match condition

func ValidateParentAndDrain

func ValidateParentAndDrain(drainTime, parentShutdown *duration.Duration) (errs error)

ValidateParentAndDrain checks that parent and drain durations are valid

func ValidatePercent

func ValidatePercent(val int32) error

ValidatePercent checks that percent is in range

func ValidatePort

func ValidatePort(port int) error

ValidatePort checks that the network port is in range

func ValidateProxyAddress

func ValidateProxyAddress(hostAddr string) error

ValidateProxyAddress checks that a network address is well-formed

func ValidateProxyMeshConfig

func ValidateProxyMeshConfig(mesh *proxyconfig.ProxyMeshConfig) (errs error)

ValidateProxyMeshConfig checks that the mesh config is well-formed

func ValidateRefreshDelay

func ValidateRefreshDelay(refresh *duration.Duration) error

ValidateRefreshDelay validates the discovery refresh delay time

func ValidateRouteRule

func ValidateRouteRule(msg proto.Message) error

ValidateRouteRule checks routing rules

func ValidateStringMatch

func ValidateStringMatch(match *proxyconfig.StringMatch) error

ValidateStringMatch checks that the match types are correct

func ValidateSubnet

func ValidateSubnet(subnet string) error

ValidateSubnet checks that IPv4 subnet form

func ValidateTerminate

func ValidateTerminate(terminate *proxyconfig.L4FaultInjection_Terminate) (errs error)

ValidateTerminate checks that fault injection terminate is well-formed

func ValidateThrottle

func ValidateThrottle(throttle *proxyconfig.L4FaultInjection_Throttle) (errs error)

ValidateThrottle checks that fault injections throttle is well-formed

func ValidateWeights

func ValidateWeights(routes []*proxyconfig.DestinationWeight, defaultDestination string) (errs error)

ValidateWeights checks that destination weights sum to 100

Types

type Config

type Config struct {
	// Type is a short configuration name that matches the content message type
	Type string

	// Key is the type-dependent unique identifier for this config object, derived
	// from its content
	Key string

	// Revision 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.
	Revision string

	// Content holds the configuration object as a protobuf message
	Content 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. The revision is optional, and if provided, identifies the last update operation on the object.

type ConfigDescriptor

type ConfigDescriptor []ProtoSchema

ConfigDescriptor defines the bijection between the short type name and its fully qualified protobuf message name

func (ConfigDescriptor) GetByMessageName

func (descriptor ConfigDescriptor) GetByMessageName(name string) (ProtoSchema, bool)

GetByMessageName finds a schema by message name if it is available

func (ConfigDescriptor) GetByType

func (descriptor ConfigDescriptor) GetByType(name string) (ProtoSchema, bool)

GetByType finds a schema by type if it is available

func (ConfigDescriptor) Types

func (descriptor ConfigDescriptor) Types() []string

Types lists all known types in the config schema

func (ConfigDescriptor) Validate

func (descriptor ConfigDescriptor) Validate() error

Validate checks that each name conforms to the spec and has a ProtoMessage

func (ConfigDescriptor) ValidateConfig

func (descriptor ConfigDescriptor) ValidateConfig(typ string, obj interface{}) error

ValidateConfig ensures that the config object is well-defined

type ConfigStore

type ConfigStore interface {
	// ConfigDescriptor 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.
	ConfigDescriptor() ConfigDescriptor

	// Get retrieves a configuration element by a type and a key
	Get(typ, key string) (config proto.Message, exists bool, revision string)

	// List returns objects by type
	List(typ string) ([]Config, error)

	// Post creates a configuration object. If an object with the same key for
	// the type already exists, the operation fails with no side effects.
	Post(config proto.Message) (revision string, err error)

	// Put updates a configuration object in the store.  Put requires that the
	// object has been created.  Revision 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.
	Put(config proto.Message, oldRevision string) (newRevision string, err error)

	// Delete removes an object from the store by key
	Delete(typ, key string) error
}

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

The storage interface presented here assumes that the underlying storage layer supports _GET_ (list), _PUT_ (update), _POST_ (create) and _DELETE_ semantics but does not guarantee any transactional semantics.

Configuration objects possess a type property and a key property. The configuration key is derived from the content of the config object and uniquely identifies objects for a particular type. For example, if the object schema contains metadata fields _name_ and _namespace_, the configuration key may be defined as _namespace/name_. Key definition is provided as part of the config type definition.

_PUT_, _POST_, 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 _POST_ operation and updated with _PUT_ operation.

Revisions 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

type ConfigStoreCache interface {
	ConfigStore

	// RegisterEventHandler adds a handler to receive config update events for a
	// configuration type
	RegisterEventHandler(typ string, handler func(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

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{})
}

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 Event

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

func (event Event) String() string

type IstioConfigStore

type IstioConfigStore interface {
	// RouteRules lists all routing rules
	RouteRules() map[string]*proxyconfig.RouteRule

	// IngressRules lists all ingress rules
	IngressRules() map[string]*proxyconfig.IngressRule

	// DestinationPolicies lists all destination rules
	DestinationPolicies() []*proxyconfig.DestinationPolicy

	// RouteRulesBySource selects routing rules by source service instances.
	// A rule must match at least one of the input service instances since the proxy
	// does not distinguish between source instances in the request.
	// The rules are sorted by precedence (high first) in a stable manner.
	RouteRulesBySource(instances []*ServiceInstance) []*proxyconfig.RouteRule

	// DestinationPolicy returns a policy for a service version.
	DestinationPolicy(destination string, tags Tags) *proxyconfig.DestinationVersionPolicy
}

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

func MakeIstioStore

func MakeIstioStore(store ConfigStore) IstioConfigStore

MakeIstioStore creates a wrapper around a store

type ItemAlreadyExistsError

type ItemAlreadyExistsError struct {
	Key string
	Msg string
}

ItemAlreadyExistsError is a typed error that should be used to identify when an item already is present in the configuration registry. To overwrite the default error message set the Msg field.

func (*ItemAlreadyExistsError) Error

func (e *ItemAlreadyExistsError) Error() string

Error fulfills the basic Error interface for the ItemAlreadyExistsError If a message is set it returns that otherwise it returns a default error including the key

type ItemNotFoundError

type ItemNotFoundError struct {
	Key string
	Msg string
}

ItemNotFoundError is a typed error that should be used to identify when an item cant be found in the configuration registry. To overwrite the default error message set the Msg field.

func (*ItemNotFoundError) Error

func (e *ItemNotFoundError) Error() string

Error fulfills the basic Error interface for the ItemNotFoundError If a message is set it returns that otherwise it returns a default error including the key

type NetworkEndpoint

type NetworkEndpoint struct {
	// Address of the network endpoint, typically an IPv4 address
	Address string `json:"ip_address,omitempty"`

	// Port number where this instance is listening for connections This
	// need not be the same as the port where the service is accessed.
	// e.g., catalog.mystore.com:8080 -> 172.16.0.1:55446
	Port int `json:"port"`

	// Port declaration from the service declaration This is the port for
	// the service associated with this instance (e.g.,
	// catalog.mystore.com)
	ServicePort *Port `json:"service_port"`
}

NetworkEndpoint 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)

type Port

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. See NetworkEndpoint definition below.
	Port int `json:"port"`

	// Protocol to be used for the port.
	Protocol Protocol `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

type PortList []*Port

PortList is a set of ports

func (PortList) Get

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

Get retrieves a port declaration by name

func (PortList) GetByPort

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

GetByPort retrieves a port declaration by port value

func (PortList) GetNames

func (ports PortList) GetNames() []string

GetNames returns port names

type ProtoSchema

type ProtoSchema struct {
	// Type refers to the short configuration type name
	Type string

	// MessageName refers to the protobuf message type name corresponding to the type
	MessageName string

	// Validate configuration as a protobuf message assuming the object is an
	// instance of the expected message type
	Validate func(config proto.Message) error

	// Key function derives the unique key from the configuration object metadata
	// properties. The object is not required to be complete or even valid to
	// derive its key, but must be an instance of the expected message type. For
	// example, if _name_ field is designated as the key, then the proto message
	// must only possess _name_ property.
	Key func(config proto.Message) string
}

ProtoSchema provides description of the configuration schema and its key function

func (*ProtoSchema) FromJSON

func (ps *ProtoSchema) FromJSON(js string) (proto.Message, error)

FromJSON converts a canonical JSON to a proto message

func (*ProtoSchema) FromJSONMap

func (ps *ProtoSchema) FromJSONMap(data interface{}) (proto.Message, error)

FromJSONMap converts from a generic map to a proto message using canonical JSON encoding JSON encoding is specified here: https://developers.google.com/protocol-buffers/docs/proto3#json

func (*ProtoSchema) FromYAML

func (ps *ProtoSchema) FromYAML(yml string) (proto.Message, error)

FromYAML converts a canonical YAML to a proto message

func (*ProtoSchema) Make

func (ps *ProtoSchema) Make() (proto.Message, error)

Make creates a new instance of the proto message

func (*ProtoSchema) ToJSON

func (ps *ProtoSchema) ToJSON(msg proto.Message) (string, error)

ToJSON marshals a proto to canonical JSON

func (*ProtoSchema) ToJSONMap

func (ps *ProtoSchema) ToJSONMap(msg proto.Message) (map[string]interface{}, error)

ToJSONMap converts a proto message to a generic map using canonical JSON encoding JSON encoding is specified here: https://developers.google.com/protocol-buffers/docs/proto3#json

func (*ProtoSchema) ToYAML

func (ps *ProtoSchema) ToYAML(msg proto.Message) (string, error)

ToYAML marshals a proto to canonical YAML

type Protocol

type Protocol string

Protocol defines network protocols for ports

const (
	// ProtocolGRPC declares that the port carries gRPC traffic
	ProtocolGRPC Protocol = "GRPC"
	// ProtocolHTTPS declares that the port carries HTTPS traffic
	ProtocolHTTPS Protocol = "HTTPS"
	// ProtocolHTTP2 declares that the port carries HTTP/2 traffic
	ProtocolHTTP2 Protocol = "HTTP2"
	// ProtocolHTTP declares that the port carries HTTP/1.1 traffic.
	// Note that HTTP/1.0 or earlier may not be supported by the proxy.
	ProtocolHTTP Protocol = "HTTP"
	// ProtocolTCP declares the the port uses TCP.
	// This is the default protocol for a service port.
	ProtocolTCP Protocol = "TCP"
	// ProtocolUDP declares that the port uses UDP.
	// Note that UDP protocol is not currently supported by the proxy.
	ProtocolUDP Protocol = "UDP"
)

func (Protocol) IsHTTP

func (p Protocol) IsHTTP() bool

IsHTTP is true for protocols that use HTTP as transport protocol

type SecretRegistry

type SecretRegistry interface {
	// GetTLSSecret retrieves a TLS secret by implementation specific URI
	GetTLSSecret(uri string) (*TLSSecret, error)
}

SecretRegistry defines a read-only interface for secret key material The implementation should not cache or persist the secrets and pass the data immediately to the client of this interface.

type Service

type Service struct {
	// Hostname of the service, e.g. "catalog.mystore.com"
	Hostname string `json:"hostname"`

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

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

	// ExternalName is only set for external services and holds the external
	// service DNS name.  External services are name-based solution to represent
	// external service instances as a service inside the cluster.
	ExternalName string `json:"external"`
}

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) External

func (s *Service) External() bool

External predicate checks whether the service is external

func (*Service) Key

func (s *Service) Key(port *Port, tag Tags) string

Key generates a unique string referencing service instances for a given port and tags. The separator character must be exclusive to the regular expressions allowed in the service declaration.

func (*Service) Validate

func (s *Service) Validate() error

Validate ensures that the service object is well-defined

type ServiceAccounts

type ServiceAccounts interface {
	// GetIstioServiceAccounts returns a list of service accounts looked up from
	// the specified service hostname and ports.
	GetIstioServiceAccounts(hostname string, ports []string) []string
}

ServiceAccounts exposes Istio service accounts

type ServiceDiscovery

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

	// GetService retrieves a service by host name if it exists
	GetService(hostname string) (*Service, bool)

	// Instances retrieves instances for a service and its ports that match
	// any of the supplied tags. All instances match an empty tag list.
	//
	// For example, consider the example of catalog.mystore.com as described in NetworkEndpoints
	// Instances(catalog.myservice.com, 80) ->
	//      --> NetworkEndpoint(172.16.0.1:8888), Service(catalog.myservice.com), Tag(foo=bar)
	//      --> NetworkEndpoint(172.16.0.2:8888), Service(catalog.myservice.com), Tag(foo=bar)
	//      --> NetworkEndpoint(172.16.0.3:8888), Service(catalog.myservice.com), Tag(kitty=cat)
	//      --> NetworkEndpoint(172.16.0.4:8888), Service(catalog.myservice.com), Tag(kitty=cat)
	//
	// Calling Instances with specific tags returns a trimmed list.
	// e.g., Instances(catalog.myservice.com, 80, foo=bar) ->
	//      --> NetworkEndpoint(172.16.0.1:8888), Service(catalog.myservice.com), Tag(foo=bar)
	//      --> NetworkEndpoint(172.16.0.2:8888), Service(catalog.myservice.com), Tag(foo=bar)
	//
	// Similar concepts apply for calling this function with a specific
	// port, hostname and tags.
	Instances(hostname string, ports []string, tags TagsList) []*ServiceInstance

	// HostInstances lists service instances for a given set of IPv4 addresses.
	HostInstances(addrs map[string]bool) []*ServiceInstance
}

ServiceDiscovery enumerates Istio service instances.

type ServiceInstance

type ServiceInstance struct {
	Endpoint         NetworkEndpoint `json:"endpoint,omitempty"`
	Service          *Service        `json:"service,omitempty"`
	Tags             Tags            `json:"tags,omitempty"`
	AvailabilityZone string          `json:"az,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 tags that describe the service version associated with this instance.

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

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

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

func (*ServiceInstance) Validate

func (instance *ServiceInstance) Validate() error

Validate ensures that the service instance is well-defined

type TLSSecret

type TLSSecret struct {
	Certificate []byte `json:"cert"`
	PrivateKey  []byte `json:"key"`
}

TLSSecret defines a TLS configuration.

type Tags

type Tags map[string]string

Tags is a non empty set of arbitrary strings. Each version of a service can be differentiated by a unique set of tags associated with the version. These tags are assigned to all instances of a particular service version. For example, lets say catalog.mystore.com has 2 versions v1 and v2. v1 instances could have tags gitCommit=aeiou234, region=us-east, while v2 instances could have tags name=kittyCat,region=us-east.

func ParseTagString

func ParseTagString(s string) Tags

ParseTagString extracts tags from a string

func (Tags) Equals

func (t Tags) Equals(that Tags) bool

Equals returns true if the tags are identical

func (Tags) String

func (t Tags) String() string

func (Tags) SubsetOf

func (t Tags) SubsetOf(that Tags) bool

SubsetOf is true if the tag has identical values for the keys

func (Tags) Validate

func (t Tags) Validate() error

Validate ensures tag is well-formed

type TagsList

type TagsList []Tags

TagsList is a collection of tags used for comparing tags against a collection of tags

func (TagsList) HasSubsetOf

func (tags TagsList) HasSubsetOf(that Tags) bool

HasSubsetOf returns true if the input tags are a super set of one tags in a collection or if the tag collection is empty

Jump to

Keyboard shortcuts

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