kubernetes

package
v0.12.0-snapshot.1 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2018 License: Apache-2.0 Imports: 31 Imported by: 156

Documentation

Index

Constants

View Source
const (
	// Counter constant for MetricType
	Counter = "counter"
	// Histogram constant for MetricType
	Histogram = "histogram"
)

Variables

This section is empty.

Functions

func ConfigClient

func ConfigClient() (*rest.Config, error)

ConfigClient return a client with the correct configuration Returns configuration if Kiali is in Cluster when InCluster is true Returns configuration if Kiali is not int Cluster when InCluster is false It returns an error on any problem

func FilterByHost

func FilterByHost(host, serviceName, namespace string) bool

func FilterByRoute added in v0.6.0

func FilterByRoute(spec map[string]interface{}, protocols []string, service string, namespace string, serviceEntries map[string]struct{}) bool

func FilterByRouteAndSubset added in v0.6.0

func FilterByRouteAndSubset(spec map[string]interface{}, protocols []string, service string, namespace string, subsets []string) bool

func FilterPodsForController added in v0.9.0

func FilterPodsForController(controllerName string, controllerType string, allPods []v1.Pod) []v1.Pod

func FilterPodsForEndpoints added in v0.8.0

func FilterPodsForEndpoints(endpoints *v1.Endpoints, unfiltered []v1.Pod) []v1.Pod

FilterPodsForEndpoints performs a second pass was selector may return too many data This case happens when a "nil" selector (such as one of default/kubernetes service) is used

func FilterPodsForSelector added in v0.9.0

func FilterPodsForSelector(selector labels.Selector, allPods []v1.Pod) []v1.Pod

func FilterPodsForService

func FilterPodsForService(s *v1.Service, allPods []v1.Pod) []v1.Pod

FilterPodsForService returns a subpart of pod list filtered according service selector

func FilterServicesForSelector added in v0.9.0

func FilterServicesForSelector(selector labels.Selector, allServices []v1.Service) []v1.Service

func GatewayNames added in v0.7.0

func GatewayNames(gateways []IstioObject) map[string]struct{}

GatewayNames extracts the gateway names for easier matching

func GetDestinationRulesSubsets

func GetDestinationRulesSubsets(destinationRules []IstioObject, serviceName, version string) []string

GetDestinationRulesSubsets returns an array of subset names where a specific version is defined for a given service

func NewNotFound added in v0.7.0

func NewNotFound(name, group, resource string) error

NewNotFound is a helper method to create a NotFound error similar as used by the kubernetes client. This method helps upper layers to send a explicit NotFound error without querying the backend.

func ServiceEntryHostnames added in v0.7.0

func ServiceEntryHostnames(serviceEntries []IstioObject) map[string]struct{}

ServiceEntryHostnames returns a list of hostnames defined in the ServiceEntries Specs. Key in the resulting map is the protocol (in lowercase) + hostname exported for test

func ValidateDestinationRulesSubsets added in v0.10.0

func ValidateDestinationRulesSubsets(destinationRules []IstioObject, serviceName string, availableVersions []string) []int

ValidateDestinationRulesSubsets compares availableVersions to the ones found in the subsets definitions and returns indexes of those that were not found

func ValidateVirtualServiceGateways added in v0.7.0

func ValidateVirtualServiceGateways(spec map[string]interface{}, gatewayNames map[string]struct{}) (bool, int)

ValidateVirtualServiceGateways checks all VirtualService gateways (except mesh, which is reserved word) and checks that they're found from the given list of gatewayNames. Also return index of missing gatways to show clearer error path in editor

Types

type GenericIstioObject added in v0.11.0

type GenericIstioObject struct {
	meta_v1.TypeMeta   `json:",inline"`
	meta_v1.ObjectMeta `json:"metadata"`
	Spec               map[string]interface{} `json:"spec"`
}

GenericIstioObject is a type to test Istio types defined by Istio as a Kubernetes extension.

func (*GenericIstioObject) DeepCopy added in v0.11.0

func (in *GenericIstioObject) DeepCopy() *GenericIstioObject

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericIstioObject.

func (*GenericIstioObject) DeepCopyInto added in v0.11.0

func (in *GenericIstioObject) DeepCopyInto(out *GenericIstioObject)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*GenericIstioObject) DeepCopyIstioObject added in v0.11.0

func (in *GenericIstioObject) DeepCopyIstioObject() IstioObject

DeepCopyIstioObject is an autogenerated deepcopy function, copying the receiver, creating a new IstioObject.

func (*GenericIstioObject) DeepCopyObject added in v0.11.0

func (in *GenericIstioObject) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*GenericIstioObject) GetObjectMeta added in v0.11.0

func (in *GenericIstioObject) GetObjectMeta() meta_v1.ObjectMeta

GetObjectMeta from a wrapper

func (*GenericIstioObject) GetSpec added in v0.11.0

func (in *GenericIstioObject) GetSpec() map[string]interface{}

GetSpec from a wrapper

func (*GenericIstioObject) SetObjectMeta added in v0.11.0

func (in *GenericIstioObject) SetObjectMeta(metadata meta_v1.ObjectMeta)

SetObjectMeta for a wrapper

func (*GenericIstioObject) SetSpec added in v0.11.0

func (in *GenericIstioObject) SetSpec(spec map[string]interface{})

SetSpec for a wrapper

type GenericIstioObjectList added in v0.11.0

type GenericIstioObjectList struct {
	meta_v1.TypeMeta `json:",inline"`
	meta_v1.ListMeta `json:"metadata"`
	Items            []GenericIstioObject `json:"items"`
}

GenericIstioObjectList is the generic Kubernetes API list wrapper

func (*GenericIstioObjectList) DeepCopy added in v0.11.0

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericIstioObjectList.

func (*GenericIstioObjectList) DeepCopyInto added in v0.11.0

func (in *GenericIstioObjectList) DeepCopyInto(out *GenericIstioObjectList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*GenericIstioObjectList) DeepCopyObject added in v0.11.0

func (in *GenericIstioObjectList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*GenericIstioObjectList) GetItems added in v0.11.0

func (in *GenericIstioObjectList) GetItems() []IstioObject

GetItems from a wrapper

type IstioClient

type IstioClient struct {
	IstioClientInterface
	// contains filtered or unexported fields
}

IstioClient is the client struct for Kubernetes and Istio APIs It hides the way it queries each API

func NewClient

func NewClient() (*IstioClient, error)

NewClient creates a new client to the Kubernetes and Istio APIs.

func NewClientFromConfig added in v0.9.0

func NewClientFromConfig(config *rest.Config) (*IstioClient, error)

NewClientFromConfig creates a new client to the Kubernetes and Istio APIs. It takes the assumption that Istio is deployed into the cluster. It hides the access to Kubernetes/Openshift credentials. It hides the low level use of the API of Kubernetes and Istio, it should be considered as an implementation detail. It returns an error on any problem.

func (*IstioClient) DeleteIstioObject added in v0.9.1

func (in *IstioClient) DeleteIstioObject(api, namespace, resourceType, name string) error

DeleteIstioObject deletes an Istio object from either config api or networking api

func (*IstioClient) GetAdapter added in v0.11.0

func (in *IstioClient) GetAdapter(namespace, adapterType, adapterName string) (IstioObject, error)

func (*IstioClient) GetAdapters added in v0.11.0

func (in *IstioClient) GetAdapters(namespace string) ([]IstioObject, error)

func (*IstioClient) GetCronJobs added in v0.9.0

func (in *IstioClient) GetCronJobs(namespace string) ([]batch_v1beta1.CronJob, error)

func (*IstioClient) GetDeployment added in v0.6.0

func (in *IstioClient) GetDeployment(namespace, deploymentName string) (*v1beta1.Deployment, error)

GetDeployment returns the definition of a specific deployment. It returns an error on any problem.

func (*IstioClient) GetDeploymentConfig added in v0.9.0

func (in *IstioClient) GetDeploymentConfig(namespace, deploymentconfigName string) (*osappsv1.DeploymentConfig, error)

GetDeployment returns the definition of a specific deployment. It returns an error on any problem.

func (*IstioClient) GetDeploymentConfigs added in v0.9.0

func (in *IstioClient) GetDeploymentConfigs(namespace string) ([]osappsv1.DeploymentConfig, error)

GetDeployments returns an array of deployments for a given namespace and a set of labels. An empty labelSelector will fetch all Deployments for a namespace. It returns an error on any problem.

func (*IstioClient) GetDeployments

func (in *IstioClient) GetDeployments(namespace string) ([]v1beta1.Deployment, error)

GetDeployments returns an array of deployments for a given namespace and a set of labels. It returns an error on any problem.

func (*IstioClient) GetDestinationRule

func (in *IstioClient) GetDestinationRule(namespace string, destinationrule string) (IstioObject, error)

func (*IstioClient) GetDestinationRules

func (in *IstioClient) GetDestinationRules(namespace string, serviceName string) ([]IstioObject, error)

GetDestinationRules returns all DestinationRules for a given namespace. If serviceName param is provided it will filter all DestinationRules having a host defined on a particular service. It returns an error on any problem.

func (*IstioClient) GetEndpoints added in v0.8.0

func (in *IstioClient) GetEndpoints(namespace, serviceName string) (*v1.Endpoints, error)

GetEndpoints return the list of endpoint of a specific service. It returns an error on any problem.

func (*IstioClient) GetGateway

func (in *IstioClient) GetGateway(namespace string, gateway string) (IstioObject, error)

func (*IstioClient) GetGateways

func (in *IstioClient) GetGateways(namespace string) ([]IstioObject, error)

GetGateways return all Gateways for a given namespace. It returns an error on any problem.

func (*IstioClient) GetIstioConfigApi added in v0.9.0

func (client *IstioClient) GetIstioConfigApi() *rest.RESTClient

GetIstioConfigApi returns the istio config rest client

func (*IstioClient) GetIstioDetails

func (in *IstioClient) GetIstioDetails(namespace string, serviceName string) (*IstioDetails, error)

GetIstioDetails returns Istio details for a given namespace, on this version it collects the VirtualServices and DestinationRules defined for a namespace. If serviceName param is provided, it filters all the Istio objects pointing to a particular service. It returns an error on any problem.

func (*IstioClient) GetIstioNetworkingApi added in v0.9.0

func (client *IstioClient) GetIstioNetworkingApi() *rest.RESTClient

GetIstioNetworkingApi returns the istio config rest client

func (*IstioClient) GetIstioRule added in v0.11.0

func (in *IstioClient) GetIstioRule(namespace string, istiorule string) (IstioObject, error)

func (*IstioClient) GetIstioRules

func (in *IstioClient) GetIstioRules(namespace string) ([]IstioObject, error)

GetIstioRules returns a list of mixer rules for a given namespace.

func (*IstioClient) GetJobs added in v0.9.0

func (in *IstioClient) GetJobs(namespace string) ([]batch_v1.Job, error)

func (*IstioClient) GetK8sApi added in v0.9.0

func (client *IstioClient) GetK8sApi() *kube.Clientset

GetK8sApi returns the clientset referencing all K8s rest clients

func (*IstioClient) GetNamespace added in v0.9.1

func (in *IstioClient) GetNamespace(namespace string) (*v1.Namespace, error)

GetNamespace fetches and returns the specified namespace definition from the cluster

func (*IstioClient) GetNamespaces

func (in *IstioClient) GetNamespaces() ([]v1.Namespace, error)

GetNamespaces returns a list of all namespaces of the cluster. It returns a list of all namespaces of the cluster. It returns an error on any problem.

func (*IstioClient) GetPods

func (in *IstioClient) GetPods(namespace, labelSelector string) ([]v1.Pod, error)

GetPods returns the pods definitions for a given set of labels. An empty labelSelector will fetch all pods found per a namespace. It returns an error on any problem.

func (*IstioClient) GetProject added in v0.9.1

func (in *IstioClient) GetProject(name string) (*osv1.Project, error)

GetProject fetches and returns the definition of the project with the specified name by querying the cluster API. GetProject will fail if the underlying cluster is not Openshift.

func (*IstioClient) GetProjects added in v0.8.0

func (in *IstioClient) GetProjects() ([]osv1.Project, error)

func (*IstioClient) GetQuotaSpec added in v0.5.0

func (in *IstioClient) GetQuotaSpec(namespace string, quotaSpecName string) (IstioObject, error)

func (*IstioClient) GetQuotaSpecBinding added in v0.5.0

func (in *IstioClient) GetQuotaSpecBinding(namespace string, quotaSpecBindingName string) (IstioObject, error)

func (*IstioClient) GetQuotaSpecBindings added in v0.5.0

func (in *IstioClient) GetQuotaSpecBindings(namespace string) ([]IstioObject, error)

GetQuotaSpecBindings returns all QuotaSpecBindings objects for a given namespace. It returns an error on any problem.

func (*IstioClient) GetQuotaSpecs added in v0.5.0

func (in *IstioClient) GetQuotaSpecs(namespace string) ([]IstioObject, error)

GetQuotaSpecs returns all QuotaSpecs objects for a given namespace. It returns an error on any problem.

func (*IstioClient) GetReplicaSets added in v0.9.0

func (in *IstioClient) GetReplicaSets(namespace string) ([]v1beta2.ReplicaSet, error)

func (*IstioClient) GetReplicationControllers added in v0.9.0

func (in *IstioClient) GetReplicationControllers(namespace string) ([]v1.ReplicationController, error)

func (*IstioClient) GetSelfSubjectAccessReview added in v0.9.1

func (in *IstioClient) GetSelfSubjectAccessReview(namespace, api, resourceType string, verbs []string) ([]*auth_v1.SelfSubjectAccessReview, error)

GetSelfSubjectAccessReview provides information on Kiali permissions

func (*IstioClient) GetService

func (in *IstioClient) GetService(namespace, serviceName string) (*v1.Service, error)

GetService returns the definition of a specific service. It returns an error on any problem.

func (*IstioClient) GetServiceEntries added in v0.5.0

func (in *IstioClient) GetServiceEntries(namespace string) ([]IstioObject, error)

GetServiceEntries return all ServiceEntry objects for a given namespace. It returns an error on any problem.

func (*IstioClient) GetServiceEntry added in v0.5.0

func (in *IstioClient) GetServiceEntry(namespace string, serviceEntryName string) (IstioObject, error)

func (*IstioClient) GetServices

func (in *IstioClient) GetServices(namespace string, selectorLabels map[string]string) ([]v1.Service, error)

GetServices returns a list of services for a given namespace. If selectorLabels is defined the list of services is filtered for those that matches Services selector labels. It returns an error on any problem.

func (*IstioClient) GetStatefulSet added in v0.9.0

func (in *IstioClient) GetStatefulSet(namespace string, statefulsetName string) (*v1beta2.StatefulSet, error)

func (*IstioClient) GetStatefulSets added in v0.9.0

func (in *IstioClient) GetStatefulSets(namespace string) ([]v1beta2.StatefulSet, error)

func (*IstioClient) GetTemplate added in v0.11.0

func (in *IstioClient) GetTemplate(namespace, templateType, templateName string) (IstioObject, error)

func (*IstioClient) GetTemplates added in v0.11.0

func (in *IstioClient) GetTemplates(namespace string) ([]IstioObject, error)

func (*IstioClient) GetVirtualService

func (in *IstioClient) GetVirtualService(namespace string, virtualservice string) (IstioObject, error)

func (*IstioClient) GetVirtualServices

func (in *IstioClient) GetVirtualServices(namespace string, serviceName string) ([]IstioObject, error)

GetVirtualServices return all VirtualServices for a given namespace. If serviceName param is provided it will filter all VirtualServices having a host defined on a particular service. It returns an error on any problem.

func (*IstioClient) IsOpenShift added in v0.8.0

func (in *IstioClient) IsOpenShift() bool

func (*IstioClient) Stop added in v0.9.1

func (in *IstioClient) Stop()

func (*IstioClient) UpdateIstioObject added in v0.12.0

func (in *IstioClient) UpdateIstioObject(api, namespace, resourceType, name, jsonPatch string) (IstioObject, error)

UpdateIstioObject updates an Istio object from either config api or networking api

type IstioClientInterface

type IstioClientInterface interface {
	DeleteIstioObject(api, namespace, resourceType, name string) error
	GetAdapter(namespace, adapterType, adapterName string) (IstioObject, error)
	GetAdapters(namespace string) ([]IstioObject, error)
	GetCronJobs(namespace string) ([]batch_v1beta1.CronJob, error)
	GetDeployment(namespace string, deploymentName string) (*v1beta1.Deployment, error)
	GetDeployments(namespace string) ([]v1beta1.Deployment, error)
	GetDeploymentConfig(namespace string, deploymentconfigName string) (*osappsv1.DeploymentConfig, error)
	GetDeploymentConfigs(namespace string) ([]osappsv1.DeploymentConfig, error)
	GetDestinationRule(namespace string, destinationrule string) (IstioObject, error)
	GetDestinationRules(namespace string, serviceName string) ([]IstioObject, error)
	GetEndpoints(namespace string, serviceName string) (*v1.Endpoints, error)
	GetGateway(namespace string, gateway string) (IstioObject, error)
	GetGateways(namespace string) ([]IstioObject, error)
	GetIstioDetails(namespace string, serviceName string) (*IstioDetails, error)
	GetIstioRule(namespace string, istiorule string) (IstioObject, error)
	GetIstioRules(namespace string) ([]IstioObject, error)
	GetJobs(namespace string) ([]batch_v1.Job, error)
	GetNamespace(namespace string) (*v1.Namespace, error)
	GetNamespaces() ([]v1.Namespace, error)
	GetPods(namespace, labelSelector string) ([]v1.Pod, error)
	GetProject(project string) (*osv1.Project, error)
	GetProjects() ([]osv1.Project, error)
	GetQuotaSpec(namespace string, quotaSpecName string) (IstioObject, error)
	GetQuotaSpecs(namespace string) ([]IstioObject, error)
	GetQuotaSpecBinding(namespace string, quotaSpecBindingName string) (IstioObject, error)
	GetQuotaSpecBindings(namespace string) ([]IstioObject, error)
	GetReplicationControllers(namespace string) ([]v1.ReplicationController, error)
	GetReplicaSets(namespace string) ([]v1beta2.ReplicaSet, error)
	GetSelfSubjectAccessReview(namespace, api, resourceType string, verbs []string) ([]*auth_v1.SelfSubjectAccessReview, error)
	GetService(namespace string, serviceName string) (*v1.Service, error)
	GetServices(namespace string, selectorLabels map[string]string) ([]v1.Service, error)
	GetServiceEntries(namespace string) ([]IstioObject, error)
	GetServiceEntry(namespace string, serviceEntryName string) (IstioObject, error)
	GetStatefulSet(namespace string, statefulsetName string) (*v1beta2.StatefulSet, error)
	GetStatefulSets(namespace string) ([]v1beta2.StatefulSet, error)
	GetTemplate(namespace, templateType, templateName string) (IstioObject, error)
	GetTemplates(namespace string) ([]IstioObject, error)
	GetVirtualService(namespace string, virtualservice string) (IstioObject, error)
	GetVirtualServices(namespace string, serviceName string) ([]IstioObject, error)
	IsOpenShift() bool
	Stop()
	UpdateIstioObject(api, namespace, resourteType, name, jsonPatch string) (IstioObject, error)
}

IstioClientInterface for mocks (only mocked function are necessary here)

type IstioDetails

type IstioDetails struct {
	VirtualServices  []IstioObject `json:"virtualservices"`
	DestinationRules []IstioObject `json:"destinationrules"`
	ServiceEntries   []IstioObject `json:"serviceentries"`
	Gateways         []IstioObject `json:"gateways"`
}

IstioDetails is a wrapper to group all Istio objects related to a Service. Used to fetch all Istio information in a single operation instead to invoke individual APIs per each group.

type IstioObject

type IstioObject interface {
	runtime.Object
	GetSpec() map[string]interface{}
	SetSpec(map[string]interface{})
	GetObjectMeta() meta_v1.ObjectMeta
	SetObjectMeta(meta_v1.ObjectMeta)
	DeepCopyIstioObject() IstioObject
}

IstioObject is a k8s wrapper interface for config objects. Taken from istio.io

type IstioObjectList

type IstioObjectList interface {
	runtime.Object
	GetItems() []IstioObject
}

IstioObjectList is a k8s wrapper interface for list config objects. Taken from istio.io

type KialiMonitoringClient added in v0.12.0

type KialiMonitoringClient struct {
	KialiMonitoringInterface
	// contains filtered or unexported fields
}

KialiMonitoringClient is the client struct for Kiali Monitoring API over Kubernetes API to get MonitoringDashboards

func NewKialiMonitoringClient added in v0.12.0

func NewKialiMonitoringClient() (*KialiMonitoringClient, error)

NewKialiMonitoringClient creates a new client able to fetch Kiali Monitoring API.

func (*KialiMonitoringClient) GetDashboard added in v0.12.0

func (in *KialiMonitoringClient) GetDashboard(namespace string, name string) (*MonitoringDashboard, error)

GetDashboard returns a MonitoringDashboard for the given name

type KialiMonitoringInterface added in v0.12.0

type KialiMonitoringInterface interface {
	GetDashboard(namespace string, name string) (*MonitoringDashboard, error)
}

KialiMonitoringInterface for mocks (only mocked function are necessary here)

type MonitoringDashboard added in v0.12.0

type MonitoringDashboard struct {
	Spec MonitoringDashboardSpec
}

type MonitoringDashboardAggregation added in v0.12.0

type MonitoringDashboardAggregation struct {
	Label       string
	DisplayName string
}

type MonitoringDashboardChart added in v0.12.0

type MonitoringDashboardChart struct {
	Name         string
	Unit         string
	Spans        int
	MetricName   string
	MetricType   string // MetricType is either "counter" or "histogram"
	Aggregations []MonitoringDashboardAggregation
}

type MonitoringDashboardSpec added in v0.12.0

type MonitoringDashboardSpec struct {
	Title  string
	Charts []MonitoringDashboardChart
}

type ServiceDetails

type ServiceDetails struct {
	Service     *v1.Service                                `json:"service"`
	Endpoints   *v1.Endpoints                              `json:"endpoints"`
	Deployments *v1beta1.DeploymentList                    `json:"deployments"`
	Autoscalers *autoscalingV1.HorizontalPodAutoscalerList `json:"autoscalers"`
	Pods        []v1.Pod                                   `json:"pods"`
}

ServiceDetails is a wrapper to group full Service description, Endpoints and Pods. Used to fetch all details in a single operation instead to invoke individual APIs per each group.

type ServiceList

type ServiceList struct {
	Services    *v1.ServiceList
	Pods        *v1.PodList
	Deployments *v1beta1.DeploymentList
}

ServiceList holds list of services, pods and deployments

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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