Documentation ¶
Index ¶
- Constants
- func IsExportableService(service *v1.Service) bool
- func NewClientSet() (kubernetes.Interface, error)
- type ConsulTarget
- type ConsulTargetConfig
- type ExportTarget
- type ExportedNode
- type ExportedService
- type InformerConfig
- type KeyOp
- type NodeConfiguration
- type NodeInformerConfig
- type NodeWatcher
- type ServiceWatcher
Constants ¶
const ( // ServiceAnnotationExported is a boolean that determines whether or not to // export the service. Its value is not stored anywhere in the // ExportedService, but it is used in IsExportable() ServiceAnnotationExported = "kube-service-exporter.github.com/exported" // ServiceAnnotationLoadBalancerProxyProtocol is the annotation used on the // service to signal that the proxy protocol should be enabled. Set to // "*" to indicate that all backends should support Proxy Protocol. ServiceAnnotationProxyProtocol = "kube-service-exporter.github.com/load-balancer-proxy-protocol" // The load balancer class is the target load balancer to apply that the // service should be a member of. Examples might be "internal" or "public" ServiceAnnotationLoadBalancerClass = "kube-service-exporter.github.com/load-balancer-class" // ServiceAnnotationLoadBalancerBEProtocol is the annotation used on the service // to specify the protocol spoken by the backend (pod) behind a listener. // Options are `http` or `tcp` for HTTP backends or TCP backends ServiceAnnotationLoadBalancerBEProtocol = "kube-service-exporter.github.com/load-balancer-backend-protocol" // The port the load balancer should listen on for requests routed to this service ServiceAnnotationLoadBalancerListenPort = "kube-service-exporter.github.com/load-balancer-listen-port" // A path for an HTTP Health check. ServiceAnnotationLoadBalancerHealthCheckPath = "kube-service-exporter.github.com/load-balancer-health-check-path" // The port for a the Health check. If unset, defaults to the NodePort. ServiceAnnotationLoadBalancerHealthCheckPort = "kube-service-exporter.github.com/load-balancer-health-check-port" // If set and set to "false" this will create a separate service // *per cluster id*, useful for applications that should not be // load balanced across multiple clusters. ServiceAnnotationLoadBalancerServicePerCluster = "kube-service-exporter.github.com/load-balancer-service-per-cluster" ServiceAnnotationLoadBalancerDNSName = "kube-service-exporter.github.com/load-balancer-dns-name" // CustomAttrs is like a "junk drawer" - clients can put arbitrary json objects in the annotation, and // we'll parse it and make that object available in the consul payload under `.custom_attrs` ServiceAnnotationCustomAttrs = "kube-service-exporter.github.com/custom-attrs" // IdPrefix allows the service to define a string with which to prefix the // Id, allowing control over the sort order of two or more services ServiceAnnotationIdPrefix = "kube-service-exporter.github.com/id-prefix" // ServiceAnnotationIngressServiceName/Namespace specifies a different Service with ports that will be used // for cases such as an Ingress Controller where this Service is not the same as the Service that // is exposed to the Load Balancer. In this case, the Service that is exposed to the Load Balancer // should be annotated with this annotation, and the value should be the name of the Namespace/Service that // is actually being load balanced. ServiceAnnotationIngressServiceNamespace = "kube-service-exporter.github.com/ingress-service-namespace" ServiceAnnotationIngressServiceName = "kube-service-exporter.github.com/ingress-service-name" ServiceAnnotationIngressServicePortName = "kube-service-exporter.github.com/ingress-service-port-name" )
const ( AddOp operation = iota UpdateOp DeleteOp )
Variables ¶
This section is empty.
Functions ¶
func IsExportableService ¶
IsExportableService returns true if:
- the target Service has the kube-service-exporter.github.com/exported annotation set to a value which evalutes to a boolean (e.g. "true", "1")
AND - is a type: LoadBalancer or type: NodePort Service.
func NewClientSet ¶
func NewClientSet() (kubernetes.Interface, error)
Types ¶
type ConsulTarget ¶
type ConsulTarget struct {
// contains filtered or unexported fields
}
func NewConsulTarget ¶
func NewConsulTarget(cfg ConsulTargetConfig) (*ConsulTarget, error)
func (*ConsulTarget) Create ¶
func (t *ConsulTarget) Create(es *ExportedService) (bool, error)
func (*ConsulTarget) Delete ¶
func (t *ConsulTarget) Delete(es *ExportedService) (bool, error)
func (*ConsulTarget) Update ¶
func (t *ConsulTarget) Update(old *ExportedService, new *ExportedService) (bool, error)
Update will update the representation of the ExportedService in Consul, cleaning up old keys if the old key differs from the new key. returns true when the key was created, false otherwise
func (*ConsulTarget) WriteNodes ¶
func (t *ConsulTarget) WriteNodes(nodes []*v1.Node) error
type ConsulTargetConfig ¶
type ConsulTargetConfig struct { ConsulConfig *capi.Config KvPrefix string // ServicesKeyTmpl is the go template used for each service. Defaults to // services/{{ .Id() }} // Can be used to namespace keys for better lookup efficiency, e.g. // services/{{ .LoadBalancerClass }}/{{ .Id() }} ServicesKeyTmpl string ClusterId string Elector leader.LeaderElector // ServicesEnabled defines whether or not to store services as Consul Services // in addition to in KV metadata. This option requires kube-service-exporter // to be deployed as a DaemonSet ServicesEnabled bool }
type ExportTarget ¶
type ExportTarget interface { Create(*ExportedService) (bool, error) Update(old *ExportedService, new *ExportedService) (bool, error) Delete(*ExportedService) (bool, error) WriteNodes([]*v1.Node) error }
type ExportedNode ¶
type ExportedService ¶
type ExportedService struct { ClusterId string `json:"ClusterName"` Namespace string `json:"-"` Name string `json:"-"` // The unique Name for the NodePort. If no name, defaults to the Port PortName string `json:"-"` // The Port on which the Service is reachable Port int32 `json:"port"` DNSName string `json:"dns_name,omitempty"` ServicePerCluster bool `json:"service_per_cluster,omitempty"` // an optional URI Path for the HealthCheck HealthCheckPath string `json:"health_check_path,omitempty"` // HealthCheckPort is a port for the Health Check. Defaults to the NodePort HealthCheckPort int32 `json:"health_check_port,omitempty"` // TCP / HTTP BackendProtocol string `json:"backend_protocol,omitempty"` // Enable Proxy protocol on the backend ProxyProtocol bool `json:"proxy_protocol,omitempty"` // LoadBalancerClass can be used to target the service at a specific load // balancer (e.g. "internal", "public" LoadBalancerClass string `json:"load_balancer_class,omitempty"` // the port the load balancer should listen on LoadBalancerListenPort int32 `json:"load_balancer_listen_port,omitempty"` IngressSNI string `json:"ingress_sni,omitempty"` CustomAttrs map[string]interface{} `json:"custom_attrs"` // An optional prefix to be added to the generated ExportedService id IdPrefix string `json:"-"` // Version is a version specifier that can be used to force the Hash function // to change and thus rewrite the service metadata. This is useful in cases // where the JSON serialization of the object changes, but not the struct // itself. Version int `json:"-"` // contains filtered or unexported fields }
func NewExportedService ¶
func NewExportedService(service *v1.Service, clusterId string, portIdx int) (*ExportedService, error)
NewExportedService takes in a v1.Service and an index into the v1.Service.Ports array and returns an ExportedService.
func NewExportedServicesFromKubeService ¶
func NewExportedServicesFromKubeService(service *v1.Service, clusterId string, indexer cache.Indexer) ([]*ExportedService, error)
NewExportedServicesFromKubeService returns a slice of ExportedServices, one for each v1.Service Port.
func (*ExportedService) Hash ¶
func (es *ExportedService) Hash() (string, error)
func (*ExportedService) Id ¶
func (es *ExportedService) Id() string
An Id for the Service, which allows cross-cluster grouped services If two services share the same Id on different clusters, the Service will be namespaced based on the Tag below, so it can be differentiated.
func (*ExportedService) MarshalJSON ¶
func (es *ExportedService) MarshalJSON() ([]byte, error)
func (*ExportedService) MergeIngressService ¶ added in v0.1.12
func (es *ExportedService) MergeIngressService(svc *v1.Service, explicitHCPort bool) bool
MergeIngressService merges in Service information from the specified Ingress Service and port name. This is useful for cases where the service is exposed to a load balancer via an ingress controller or intermediate load balancer. Returns true if the port was found and merged in, false otherwise.
type InformerConfig ¶
type InformerConfig struct { ClientSet kubernetes.Interface ListerWatcher cache.ListerWatcher ResyncPeriod time.Duration }
func NewInformerConfig ¶
func NewInformerConfig(resyncPeriod int) (*InformerConfig, error)
type NodeConfiguration ¶ added in v0.2.0
type NodeInformerConfig ¶
type NodeInformerConfig struct { ClientSet kubernetes.Interface ResyncPeriod time.Duration }
func NewNodeInformerConfig ¶
func NewNodeInformerConfig() (*NodeInformerConfig, error)
type NodeWatcher ¶
type NodeWatcher struct { NodeConfiguration // contains filtered or unexported fields }
func NewNodeWatcher ¶
func NewNodeWatcher(nic *NodeInformerConfig, nc NodeConfiguration, target ExportTarget) *NodeWatcher
func (*NodeWatcher) Run ¶
func (nw *NodeWatcher) Run() error
func (*NodeWatcher) Stop ¶
func (nw *NodeWatcher) Stop()
func (*NodeWatcher) String ¶
func (sw *NodeWatcher) String() string
type ServiceWatcher ¶
type ServiceWatcher struct {
// contains filtered or unexported fields
}
func NewServiceWatcher ¶
func NewServiceWatcher(config *InformerConfig, namespaces []string, clusterId string, target ExportTarget, metrics queue.Metrics) *ServiceWatcher
func (*ServiceWatcher) Run ¶
func (sw *ServiceWatcher) Run() error
func (*ServiceWatcher) Stop ¶
func (sw *ServiceWatcher) Stop()
func (*ServiceWatcher) String ¶
func (sw *ServiceWatcher) String() string