Documentation
¶
Index ¶
Constants ¶
View Source
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" )
Variables ¶
This section is empty.
Functions ¶
func IsExportableService ¶
func IsExportableService(service *v1.Service) bool
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(es *ExportedService) (bool, error)
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(*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"`
ServicePerCluster bool `json:"-"`
// an optional URI Path for the HealthCheck
HealthCheckPath string `json:"health_check_path"`
// HealthCheckPort is a port for the Health Check. Defaults to the NodePort
HealthCheckPort int32 `json:"health_check_port"`
// TCP / HTTP
BackendProtocol string `json:"backend_protocol"`
// Enable Proxy protocol on the backend
ProxyProtocol bool `json:"proxy_protocol"`
// LoadBalancerClass can be used to target the service at a specific load
// balancer (e.g. "internal", "public"
LoadBalancerClass string `json:"load_balancer_class"`
// the port the load balancer should listen on
LoadBalancerListenPort int32 `json:"load_balancer_listen_port"`
CustomAttrs map[string]interface{} `json:"custom_attrs"`
}
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) ([]*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)
type InformerConfig ¶
type InformerConfig struct {
ClientSet kubernetes.Interface
ListerWatcher cache.ListerWatcher
ResyncPeriod time.Duration
}
func NewInformerConfig ¶
func NewInformerConfig() (*InformerConfig, error)
type NodeInformerConfig ¶
type NodeInformerConfig struct {
ClientSet kubernetes.Interface
ResyncPeriod time.Duration
}
func NewNodeInformerConfig ¶
func NewNodeInformerConfig() (*NodeInformerConfig, error)
type NodeWatcher ¶
type NodeWatcher struct {
// contains filtered or unexported fields
}
func NewNodeWatcher ¶
func NewNodeWatcher(config *NodeInformerConfig, target ExportTarget, nodeSelector string) *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) *ServiceWatcher
func (*ServiceWatcher) Run ¶
func (sw *ServiceWatcher) Run() error
func (*ServiceWatcher) Stop ¶
func (sw *ServiceWatcher) Stop()
func (*ServiceWatcher) String ¶
func (sw *ServiceWatcher) String() string
Click to show internal directories.
Click to hide internal directories.