kubernetes

package
v0.11.0-snapshot.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2018 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

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"`
}

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) 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) GetIstioRuleDetails

func (in *IstioClient) GetIstioRuleDetails(namespace string, istiorule string) (*IstioRuleDetails, error)

GetIstioRuleDetails returns the handlers and instances details for a given mixer rule.

func (*IstioClient) GetIstioRules

func (in *IstioClient) GetIstioRules(namespace string) (*IstioRules, 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) 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()

type IstioClientInterface

type IstioClientInterface interface {
	DeleteIstioObject(api, namespace, resourceType, name string) 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)
	GetIstioRules(namespace string) (*IstioRules, error)
	GetIstioRuleDetails(namespace string, istiorule string) (*IstioRuleDetails, 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)
	GetVirtualService(namespace string, virtualservice string) (IstioObject, error)
	GetVirtualServices(namespace string, serviceName string) ([]IstioObject, error)
	IsOpenShift() bool
	Stop()
}

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 IstioRuleAction

type IstioRuleAction struct {
	Handler   IstioObject   `json:"handler"`
	Instances []IstioObject `json:"instances"`
}

IstioRuleAction is a wrapper to group a handler object and a list of instances per a specific action.

type IstioRuleDetails

type IstioRuleDetails struct {
	Rule    IstioObject        `json:"rule"`
	Actions []*IstioRuleAction `json:"actions"`
}

IstioRuleDetails is a wrapper to group a mixer rule with its actions.

type IstioRules

type IstioRules struct {
	Rules []IstioObject `json:"rules"`
}

IstioRules is a wrapper to group all mixer rules related to a Namespace. Rules can have match expressions that may dynamically affect to several services.

type OSRouteClient

type OSRouteClient struct {
	// contains filtered or unexported fields
}

OSRouteClient is the client struct for OpenShift Routes API over Kubernetes It hides the way it queries each API

func NewOSRouteClient

func NewOSRouteClient() (*OSRouteClient, error)

NewOSRouteClient creates a new client able to fetch OpenShift Routes API.

func (*OSRouteClient) GetRoute

func (in *OSRouteClient) GetRoute(namespace string, routeName string) (string, error)

GetRoute returns an OpenShift route URL for the given name

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