Documentation ¶
Overview ¶
Package kube implements the shared and reusable library for Kubernetes
Index ¶
- Constants
- func ConvertProtocol(name string, proto v1.Protocol) model.Protocol
- func CreateInterface(kubeconfig string) (kubernetes.Interface, error)
- func CreateInterfaceFromClusterConfig(clusterConfig *clientcmdapi.Config) (kubernetes.Interface, error)
- func DeRegisterEndpoint(client kubernetes.Interface, namespace string, svcName string, ip string) error
- func KeyFunc(name, namespace string) string
- func RegisterEndpoint(client kubernetes.Interface, namespace string, svcName string, ip string, ...) error
- func ResolveConfig(kubeconfig string) (string, error)
- type ChainHandler
- type Controller
- func (c *Controller) AppendInstanceHandler(f func(*model.ServiceInstance, model.Event)) error
- func (c *Controller) AppendServiceHandler(f func(*model.Service, model.Event)) error
- func (c *Controller) GetIstioServiceAccounts(hostname model.Hostname, ports []string) []string
- func (c *Controller) GetPodAZ(pod *v1.Pod) (string, bool)
- func (c *Controller) GetProxyServiceInstances(proxy *model.Proxy) ([]*model.ServiceInstance, error)
- func (c *Controller) GetService(hostname model.Hostname) (*model.Service, error)
- func (c *Controller) GetServiceAttributes(hostname model.Hostname) (*model.ServiceAttributes, error)
- func (c *Controller) HasSynced() bool
- func (c *Controller) Instances(hostname model.Hostname, ports []string, labelsList model.LabelsCollection) ([]*model.ServiceInstance, error)
- func (c *Controller) InstancesByPort(hostname model.Hostname, reqSvcPort int, labelsList model.LabelsCollection) ([]*model.ServiceInstance, error)
- func (c *Controller) ManagementPorts(addr string) model.PortList
- func (c *Controller) Run(stop <-chan struct{})
- func (c *Controller) Services() ([]*model.Service, error)
- func (c *Controller) WorkloadHealthCheckInfo(addr string) model.ProbeList
- type ControllerOptions
- type Handler
- type NamedPort
- type PodCache
- type Queue
- type Task
Constants ¶
const ( // NodeRegionLabel is the well-known label for kubernetes node region NodeRegionLabel = "failure-domain.beta.kubernetes.io/region" // NodeZoneLabel is the well-known label for kubernetes node zone NodeZoneLabel = "failure-domain.beta.kubernetes.io/zone" // IstioNamespace used by default for Istio cluster-wide installation IstioNamespace = "istio-system" // IstioConfigMap is used by default IstioConfigMap = "istio" // PrometheusScrape is the annotation used by prometheus to determine if service metrics should be scraped (collected) PrometheusScrape = "prometheus.io/scrape" // PrometheusPort is the annotation used to explicitly specify the port to use for scraping metrics PrometheusPort = "prometheus.io/port" // PrometheusPath is the annotation used to specify a path for scraping metrics. Default is "/metrics" PrometheusPath = "prometheus.io/path" // PrometheusPathDefault is the default value for the PrometheusPath annotation PrometheusPathDefault = "/metrics" )
const ( // IngressClassAnnotation is the annotation on ingress resources for the class of controllers // responsible for it IngressClassAnnotation = "kubernetes.io/ingress.class" // KubeServiceAccountsOnVMAnnotation is to specify the K8s service accounts that are allowed to run // this service on the VMs KubeServiceAccountsOnVMAnnotation = "alpha.istio.io/kubernetes-serviceaccounts" // CanonicalServiceAccountsOnVMAnnotation is to specify the non-Kubernetes service accounts that // are allowed to run this service on the VMs CanonicalServiceAccountsOnVMAnnotation = "alpha.istio.io/canonical-serviceaccounts" // IstioURIPrefix is the URI prefix in the Istio service account scheme IstioURIPrefix = "spiffe" )
Variables ¶
This section is empty.
Functions ¶
func ConvertProtocol ¶
ConvertProtocol from k8s protocol and port name
func CreateInterface ¶
func CreateInterface(kubeconfig string) (kubernetes.Interface, error)
CreateInterface is a helper function to create Kubernetes interface from kubeconfig file
func CreateInterfaceFromClusterConfig ¶
func CreateInterfaceFromClusterConfig(clusterConfig *clientcmdapi.Config) (kubernetes.Interface, error)
CreateInterfaceFromClusterConfig is a helper function to create Kubernetes interface from in memory cluster config struct
func DeRegisterEndpoint ¶
func DeRegisterEndpoint(client kubernetes.Interface, namespace string, svcName string, ip string) error
DeRegisterEndpoint registers the endpoint (and the service if it already exists). It creates or updates as needed.
func KeyFunc ¶
KeyFunc is the internal API key function that returns "namespace"/"name" or "name" if "namespace" is empty
func RegisterEndpoint ¶
func RegisterEndpoint(client kubernetes.Interface, namespace string, svcName string, ip string, portsList []NamedPort, labels []string, annotations []string) error
RegisterEndpoint registers the endpoint (and the service if it doesn't already exists). It creates or updates as needed. When creating it adds the optional labels.
func ResolveConfig ¶
ResolveConfig checks whether to use the in-cluster or out-of-cluster config
Types ¶
type ChainHandler ¶
type ChainHandler struct {
// contains filtered or unexported fields
}
ChainHandler applies handlers in a sequence
func (*ChainHandler) Append ¶
func (ch *ChainHandler) Append(h Handler)
Append a handler as the last handler in the chain
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is a collection of synchronized resource watchers Caches are thread-safe
func NewController ¶
func NewController(client kubernetes.Interface, options ControllerOptions) *Controller
NewController creates a new Kubernetes controller
func (*Controller) AppendInstanceHandler ¶
func (c *Controller) AppendInstanceHandler(f func(*model.ServiceInstance, model.Event)) error
AppendInstanceHandler implements a service catalog operation
func (*Controller) AppendServiceHandler ¶
AppendServiceHandler implements a service catalog operation
func (*Controller) GetIstioServiceAccounts ¶
func (c *Controller) GetIstioServiceAccounts(hostname model.Hostname, ports []string) []string
GetIstioServiceAccounts returns the Istio service accounts running a serivce hostname. Each service account is encoded according to the SPIFFE VSID spec. For example, a service account named "bar" in namespace "foo" is encoded as "spiffe://cluster.local/ns/foo/sa/bar".
func (*Controller) GetPodAZ ¶
func (c *Controller) GetPodAZ(pod *v1.Pod) (string, bool)
GetPodAZ retrieves the AZ for a pod.
func (*Controller) GetProxyServiceInstances ¶
func (c *Controller) GetProxyServiceInstances(proxy *model.Proxy) ([]*model.ServiceInstance, error)
GetProxyServiceInstances returns service instances co-located with a given proxy
func (*Controller) GetService ¶
GetService implements a service catalog operation
func (*Controller) GetServiceAttributes ¶
func (c *Controller) GetServiceAttributes(hostname model.Hostname) (*model.ServiceAttributes, error)
GetServiceAttributes returns istio attributes for a service in the registry if it is present
func (*Controller) HasSynced ¶
func (c *Controller) HasSynced() bool
HasSynced returns true after the initial state synchronization
func (*Controller) Instances ¶
func (c *Controller) Instances(hostname model.Hostname, ports []string, labelsList model.LabelsCollection) ([]*model.ServiceInstance, error)
Instances implements a service catalog operation
func (*Controller) InstancesByPort ¶
func (c *Controller) InstancesByPort(hostname model.Hostname, reqSvcPort int, labelsList model.LabelsCollection) ([]*model.ServiceInstance, error)
InstancesByPort implements a service catalog operation
func (*Controller) ManagementPorts ¶
func (c *Controller) ManagementPorts(addr string) model.PortList
ManagementPorts implements a service catalog operation
func (*Controller) Run ¶
func (c *Controller) Run(stop <-chan struct{})
Run all controllers until a signal is received
func (*Controller) Services ¶
func (c *Controller) Services() ([]*model.Service, error)
Services implements a service catalog operation
func (*Controller) WorkloadHealthCheckInfo ¶
func (c *Controller) WorkloadHealthCheckInfo(addr string) model.ProbeList
WorkloadHealthCheckInfo implements a service catalog operation
type ControllerOptions ¶
type ControllerOptions struct { // Namespace the controller watches. If set to meta_v1.NamespaceAll (""), controller watches all namespaces WatchedNamespace string ResyncPeriod time.Duration DomainSuffix string }
ControllerOptions stores the configurable attributes of a Controller.
type NamedPort ¶
NamedPort defines the Port and Name tuple needed for services and endpoints.
func Str2NamedPort ¶
Str2NamedPort parses a proto:port string into a namePort struct.
type PodCache ¶
type PodCache struct {
// contains filtered or unexported fields
}
PodCache is an eventually consistent pod cache TODO: rename the file to 'pod.go' (cache is too generic)