Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyJSON(js string, pb proto.Message) error
- func ApplyYAML(yml string, pb proto.Message) error
- func IsDNS1123Label(value string) bool
- func Key(typ, name, namespace string) string
- func MatchSource(meta ConfigMeta, source *proxyconfig.IstioService, ...) bool
- func ParseServiceKey(s string) (hostname string, ports PortList, labels LabelsCollection)
- func RejectConflictingEgressRules(egressRules map[string]*proxyconfig.EgressRule) (map[string]*proxyconfig.EgressRule, error)
- func ResolveHostname(meta ConfigMeta, svc *proxyconfig.IstioService) string
- func ServiceKey(hostname string, servicePorts PortList, labelsList LabelsCollection) string
- func SortRouteRules(rules []Config)
- func ToJSON(msg proto.Message) (string, error)
- func ToJSONMap(msg proto.Message) (map[string]interface{}, error)
- func ToYAML(msg proto.Message) (string, error)
- func ValidateAbort(abort *proxyconfig.HTTPFaultInjection_Abort) (errs error)
- func ValidateAbortHTTPStatus(httpStatus *proxyconfig.HTTPFaultInjection_Abort_HttpStatus) (errs error)
- func ValidateCircuitBreaker(cb *proxyconfig.CircuitBreaker) (errs error)
- func ValidateConnectTimeout(timeout *duration.Duration) error
- func ValidateDelay(delay *proxyconfig.HTTPFaultInjection_Delay) (errs error)
- func ValidateDestinationPolicy(msg proto.Message) error
- func ValidateDestinationWeight(dw *proxyconfig.DestinationWeight) (errs error)
- func ValidateDuration(pd *duration.Duration) error
- func ValidateDurationRange(dur, min, max time.Duration) error
- func ValidateEgressRule(msg proto.Message) error
- func ValidateEgressRuleDestination(destination *proxyconfig.IstioService) error
- func ValidateEgressRuleDomain(domain string) error
- func ValidateEgressRulePort(port *proxyconfig.EgressRule_Port) error
- func ValidateFQDN(fqdn string) error
- func ValidateFloatPercent(val float32) error
- func ValidateHTTPFault(fault *proxyconfig.HTTPFaultInjection) (errs error)
- func ValidateHTTPHeaderName(name string) error
- func ValidateHTTPRetries(retry *proxyconfig.HTTPRetry) (errs error)
- func ValidateHTTPTimeout(timeout *proxyconfig.HTTPTimeout) (errs error)
- func ValidateIPv4Address(addr string) error
- func ValidateIPv4Subnet(subnet string) error
- func ValidateIngressRule(msg proto.Message) error
- func ValidateIstioService(svc *proxyconfig.IstioService) (errs error)
- func ValidateL4Fault(fault *proxyconfig.L4FaultInjection) (errs error)
- func ValidateL4MatchAttributes(ma *proxyconfig.L4MatchAttributes) (errs error)
- func ValidateLoadBalancing(lb *proxyconfig.LoadBalancing) (errs error)
- func ValidateMatchCondition(mc *proxyconfig.MatchCondition) (errs error)
- func ValidateMeshConfig(mesh *proxyconfig.MeshConfig) (errs error)
- func ValidateParentAndDrain(drainTime, parentShutdown *duration.Duration) (errs error)
- func ValidatePercent(val int32) error
- func ValidatePort(port int) error
- func ValidateProxyAddress(hostAddr string) error
- func ValidateProxyConfig(config *proxyconfig.ProxyConfig) (errs error)
- func ValidateRefreshDelay(refresh *duration.Duration) error
- func ValidateRouteRule(msg proto.Message) error
- func ValidateStringMatch(match *proxyconfig.StringMatch) error
- func ValidateSubnet(subnet string) error
- func ValidateTerminate(terminate *proxyconfig.L4FaultInjection_Terminate) (errs error)
- func ValidateThrottle(throttle *proxyconfig.L4FaultInjection_Throttle) (errs error)
- func ValidateWeights(routes []*proxyconfig.DestinationWeight) (errs error)
- type Config
- type ConfigDescriptor
- func (descriptor ConfigDescriptor) GetByMessageName(name string) (ProtoSchema, bool)
- func (descriptor ConfigDescriptor) GetByType(name string) (ProtoSchema, bool)
- func (descriptor ConfigDescriptor) Types() []string
- func (descriptor ConfigDescriptor) Validate() error
- func (descriptor ConfigDescriptor) ValidateConfig(typ string, obj interface{}) error
- type ConfigMeta
- type ConfigStore
- type ConfigStoreCache
- type Controller
- type Event
- type IstioConfigStore
- type Labels
- type LabelsCollection
- type NetworkEndpoint
- type Port
- type PortList
- type ProtoSchema
- type Protocol
- type Service
- type ServiceAccounts
- type ServiceDiscovery
- type ServiceInstance
Constants ¶
const ( // IstioAPIGroup defines API group name for Istio configuration resources IstioAPIGroup = "config.istio.io" // IstioAPIVersion defines API group version IstioAPIVersion = "v1alpha2" // HeaderURI is URI HTTP header HeaderURI = "uri" // HeaderAuthority is authority HTTP header HeaderAuthority = "authority" // NamespaceAll is a designated symbol for listing across all namespaces NamespaceAll = "" )
Variables ¶
var ( // MockConfig is used purely for testing MockConfig = ProtoSchema{ Type: "mock-config", Plural: "mock-configs", MessageName: "test.MockConfig", Validate: func(config proto.Message) error { if config.(*test.MockConfig).Key == "" { return errors.New("empty key") } return nil }, } // RouteRule describes route rules RouteRule = ProtoSchema{ Type: "route-rule", Plural: "route-rules", MessageName: "istio.proxy.v1.config.RouteRule", Validate: ValidateRouteRule, } // IngressRule describes ingress rules IngressRule = ProtoSchema{ Type: "ingress-rule", Plural: "ingress-rules", MessageName: "istio.proxy.v1.config.IngressRule", Validate: ValidateIngressRule, } // EgressRule describes egress rule EgressRule = ProtoSchema{ Type: "egress-rule", Plural: "egress-rules", MessageName: "istio.proxy.v1.config.EgressRule", Validate: ValidateEgressRule, } // DestinationPolicy describes destination rules DestinationPolicy = ProtoSchema{ Type: "destination-policy", Plural: "destination-policies", MessageName: "istio.proxy.v1.config.DestinationPolicy", Validate: ValidateDestinationPolicy, } // IstioConfigTypes lists all Istio config types with schemas and validation IstioConfigTypes = ConfigDescriptor{ RouteRule, IngressRule, EgressRule, DestinationPolicy, } )
Functions ¶
func IsDNS1123Label ¶
IsDNS1123Label tests for a string that conforms to the definition of a label in DNS (RFC 1123).
func MatchSource ¶
func MatchSource(meta ConfigMeta, source *proxyconfig.IstioService, instances []*ServiceInstance) bool
MatchSource checks that a rule applies for source service instances. Empty source match condition applies for all cases.
func ParseServiceKey ¶
func ParseServiceKey(s string) (hostname string, ports PortList, labels LabelsCollection)
ParseServiceKey is the inverse of the Service.String() method
func RejectConflictingEgressRules ¶
func RejectConflictingEgressRules(egressRules map[string]*proxyconfig.EgressRule) ( map[string]*proxyconfig.EgressRule, error)
RejectConflictingEgressRules rejects rules that have the destination which is equal to the destionation of some other rule. According to Envoy's virtual host specification, no virtual hosts can share the same domain. The following code rejects conflicting rules deterministically, by a lexicographical order - a rule with a smaller key lexicographically wins. Here the key of the rule is the key of the Istio configuration objects - see `func (meta *ConfigMeta) Key() string`
func ResolveHostname ¶
func ResolveHostname(meta ConfigMeta, svc *proxyconfig.IstioService) string
ResolveHostname uses metadata information to resolve a service reference to a fully qualified hostname. The metadata namespace and domain are used as fallback values to fill up the complete name.
func ServiceKey ¶
func ServiceKey(hostname string, servicePorts PortList, labelsList LabelsCollection) string
ServiceKey generates a service key for a collection of ports and labels
func SortRouteRules ¶
func SortRouteRules(rules []Config)
SortRouteRules sorts a slice of rules by precedence in a stable manner
func ToJSONMap ¶
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 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 ValidateCircuitBreaker ¶
func ValidateCircuitBreaker(cb *proxyconfig.CircuitBreaker) (errs error)
ValidateCircuitBreaker validates Circuit Breaker
func ValidateConnectTimeout ¶
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 ¶
ValidateDestinationPolicy checks proxy policies
func ValidateDestinationWeight ¶
func ValidateDestinationWeight(dw *proxyconfig.DestinationWeight) (errs error)
ValidateDestinationWeight validates DestinationWeight
func ValidateDuration ¶
ValidateDuration checks that a proto duration is well-formed
func ValidateDurationRange ¶
ValidateDurationRange verifies range is in specified duration
func ValidateEgressRule ¶
ValidateEgressRule checks egress rules
func ValidateEgressRuleDestination ¶
func ValidateEgressRuleDestination(destination *proxyconfig.IstioService) error
ValidateEgressRuleDestination checks that valid destination is used for an egress-rule only service field is allowed, all other fields are forbidden
func ValidateEgressRuleDomain ¶
ValidateEgressRuleDomain validates domains in the egress rules domains are according to the definion of Envoy's domain of virtual hosts.
Wildcard hosts are supported in the form of “*.foo.com” or “*-bar.foo.com”. Note that the wildcard will not match the empty string. e.g. “*-bar.foo.com” will match “baz-bar.foo.com” but not “-bar.foo.com”. Additionally, a special entry “*” is allowed which will match any host/authority header.
func ValidateEgressRulePort ¶
func ValidateEgressRulePort(port *proxyconfig.EgressRule_Port) error
ValidateEgressRulePort checks the port of the egress rule (communication port and protocol)
func ValidateFQDN ¶
ValidateFQDN checks a fully-qualified domain name
func ValidateFloatPercent ¶
ValidateFloatPercent checks that percent is in range
func ValidateHTTPFault ¶
func ValidateHTTPFault(fault *proxyconfig.HTTPFaultInjection) (errs error)
ValidateHTTPFault validates HTTP Fault
func ValidateHTTPHeaderName ¶
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 ¶
ValidateIPv4Address validates that a string in "CIDR notation" or "Dot-decimal notation"
func ValidateIPv4Subnet ¶
ValidateIPv4Subnet checks that a string is in "CIDR notation" or "Dot-decimal notation"
func ValidateIngressRule ¶
ValidateIngressRule checks ingress rules
func ValidateIstioService ¶
func ValidateIstioService(svc *proxyconfig.IstioService) (errs error)
ValidateIstioService checks for validity of a service reference
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 ValidateMeshConfig ¶
func ValidateMeshConfig(mesh *proxyconfig.MeshConfig) (errs error)
ValidateMeshConfig checks that the mesh config is well-formed
func ValidateParentAndDrain ¶
ValidateParentAndDrain checks that parent and drain durations are valid
func ValidatePercent ¶
ValidatePercent checks that percent is in range
func ValidatePort ¶
ValidatePort checks that the network port is in range
func ValidateProxyAddress ¶
ValidateProxyAddress checks that a network address is well-formed
func ValidateProxyConfig ¶
func ValidateProxyConfig(config *proxyconfig.ProxyConfig) (errs error)
ValidateProxyConfig checks that the mesh config is well-formed
func ValidateRefreshDelay ¶
ValidateRefreshDelay validates the discovery refresh delay time
func ValidateRouteRule ¶
ValidateRouteRule checks routing rules
func ValidateStringMatch ¶
func ValidateStringMatch(match *proxyconfig.StringMatch) error
ValidateStringMatch checks that the match types are correct
func ValidateSubnet ¶
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) (errs error)
ValidateWeights checks that destination weights sum to 100
Types ¶
type Config ¶
type Config struct { ConfigMeta // Spec holds the configuration object as a 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.
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 TODO: also check name and namespace
type ConfigMeta ¶
type ConfigMeta struct { // Type is a short configuration name that matches the content message type // (e.g. "route-rule") Type string `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"` }
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 ¶
func (meta *ConfigMeta) Key() string
Key is the unique identifier for a configuration object
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, name, namespace string) (config *Config, exists bool) // List returns objects by type and namespace. // Use "" for the namespace to list across namespaces. List(typ, 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, name, namespace string) 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 ¶
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 IstioConfigStore ¶
type IstioConfigStore interface { ConfigStore // EgressRules lists all egress rules EgressRules() map[string]*proxyconfig.EgressRule // RouteRules selects routing rules by source service instances and // destination service. A rule must match at least one of the input service // instances since the proxy does not distinguish between source instances in // the request. RouteRules(source []*ServiceInstance, destination string) []Config // RouteRulesByDestination selects routing rules associated with destination // service instances. A rule must match at least one of the input // destination instances. RouteRulesByDestination(destination []*ServiceInstance) []Config // Policy returns a policy for a service version that match at least one of // the source instances. The labels must match precisely in the policy. Policy(source []*ServiceInstance, destination string, labels Labels) *Config }
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 Labels ¶
Labels is a non empty set of arbitrary strings. Each version of a service can be differentiated by a unique set of labels associated with the version. These labels 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 labels gitCommit=aeiou234, region=us-east, while v2 instances could have labels name=kittyCat,region=us-east.
func ParseLabelsString ¶
ParseLabelsString extracts labels from a string
type LabelsCollection ¶
type LabelsCollection []Labels
LabelsCollection is a collection of labels used for comparing labels against a collection of labels
func (LabelsCollection) HasSubsetOf ¶
func (labels LabelsCollection) HasSubsetOf(that Labels) bool
HasSubsetOf returns true if the input labels are a super set of one labels in a collection or if the tag collection is empty
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
type ProtoSchema ¶
type ProtoSchema struct { // Type refers to the short configuration type name Type string // Plural refers to the short plural configuration name Plural 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 }
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
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" // ProtocolMongo declares that the port carries mongoDB traffic ProtocolMongo Protocol = "Mongo" // ProtocolRedis declares that the port carries redis traffic ProtocolRedis Protocol = "Redis" )
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"` // ServiceAccounts specifies the service accounts that run the service. ServiceAccounts []string `json:"serviceaccounts,omitempty"` // LoadBalancingDisabled indicates that no load balancing should be done for this service. LoadBalancingDisabled bool `json:"-"` }
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
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, error) // GetService retrieves a service by host name if it exists GetService(hostname string) (*Service, error) // Instances retrieves instances for a service and its ports that match // any of the supplied labels. 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), Labels(foo=bar) // --> NetworkEndpoint(172.16.0.2:8888), Service(catalog.myservice.com), Labels(foo=bar) // --> NetworkEndpoint(172.16.0.3:8888), Service(catalog.myservice.com), Labels(kitty=cat) // --> NetworkEndpoint(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) -> // --> NetworkEndpoint(172.16.0.1:8888), Service(catalog.myservice.com), Labels(foo=bar) // --> NetworkEndpoint(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. Instances(hostname string, ports []string, labels LabelsCollection) ([]*ServiceInstance, error) // HostInstances lists service instances for a given set of IPv4 addresses. HostInstances(addrs map[string]bool) ([]*ServiceInstance, error) // ManagementPorts lists set of management ports associated with an IPv4 address. // These management ports are typically used by the platform for out of band management // tasks such as health checks, etc. In a scenario where the proxy functions in the // transparent mode (traps all traffic to and from the service instance IP address), // the configuration generated for the proxy will not manipulate traffic destined for // the management ports ManagementPorts(addr string) PortList }
ServiceDiscovery enumerates Istio service instances.
type ServiceInstance ¶
type ServiceInstance struct { Endpoint NetworkEndpoint `json:"endpoint,omitempty"` Service *Service `json:"service,omitempty"` Labels Labels `json:"labels,omitempty"` AvailabilityZone string `json:"az,omitempty"` ServiceAccount string `json:"serviceaccount,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.
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
--> NetworkEndpoint(172.16.0.1:8888), Service(catalog.myservice.com), Labels(foo=bar) --> NetworkEndpoint(172.16.0.2:8888), Service(catalog.myservice.com), Labels(foo=bar) --> NetworkEndpoint(172.16.0.3:8888), Service(catalog.myservice.com), Labels(kitty=cat) --> NetworkEndpoint(172.16.0.4:8888), Service(catalog.myservice.com), Labels(kitty=cat)
func (*ServiceInstance) Validate ¶
func (instance *ServiceInstance) Validate() error
Validate ensures that the service instance is well-defined