kubernetes

package
v1.89.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 59 Imported by: 156

Documentation

Index

Constants

View Source
const (
	ComponentHealthy     = "Healthy"
	ComponentNotFound    = "NotFound"
	ComponentNotReady    = "NotReady"
	ComponentUnhealthy   = "Unhealthy"
	ComponentUnreachable = "Unreachable"
)
View Source
const (
	// Kubernetes Controllers
	ConfigMapType             = "ConfigMap"
	CronJobType               = "CronJob"
	DaemonSetType             = "DaemonSet"
	DeploymentType            = "Deployment"
	DeploymentConfigType      = "DeploymentConfig"
	EndpointsType             = "Endpoints"
	JobType                   = "Job"
	PodType                   = "Pod"
	ReplicationControllerType = "ReplicationController"
	ReplicaSetType            = "ReplicaSet"
	ServiceType               = "Service"
	StatefulSetType           = "StatefulSet"

	DestinationRules    = "destinationrules"
	DestinationRuleType = "DestinationRule"

	Gateways    = "gateways"
	GatewayType = "Gateway"

	EnvoyFilters    = "envoyfilters"
	EnvoyFilterType = "EnvoyFilter"

	Sidecars    = "sidecars"
	SidecarType = "Sidecar"

	ServiceEntries   = "serviceentries"
	ServiceEntryType = "ServiceEntry"

	VirtualServices    = "virtualservices"
	VirtualServiceType = "VirtualService"

	WorkloadEntries   = "workloadentries"
	WorkloadEntryType = "WorkloadEntry"

	WorkloadGroups    = "workloadgroups"
	WorkloadGroupType = "WorkloadGroup"

	WasmPlugins    = "wasmplugins"
	WasmPluginType = "WasmPlugin"

	Telemetries   = "telemetries"
	TelemetryType = "Telemetry"

	K8sGateways    = "k8sgateways"
	K8sGatewayType = "K8sGateway"
	// K8sActualGatewayType There is a naming conflict between Istio and K8s Gateways, keeping here an actual type to show in YAML editor
	K8sActualGatewayType = "Gateway"
	K8sActualGateways    = "gateways"

	K8sGatewayClasses       = "k8sgatewayclasses"
	K8sGatewayClassType     = "GatewayClass"
	K8sActualGatewayClasses = "gatewayclasses"

	K8sGRPCRoutes          = "k8sgrpcroutes"
	K8sGRPCRouteType       = "K8sGRPCRoute"
	K8sActualGRPCRouteType = "GRPCRoute"
	K8sActualGRPCRoutes    = "grpcroutes"

	K8sHTTPRoutes    = "k8shttproutes"
	K8sHTTPRouteType = "K8sHTTPRoute"
	// K8sActualHTTPRouteType There is a naming conflict between Istio and K8s Gateways, keeping here an actual type to show in YAML editor
	K8sActualHTTPRouteType = "HTTPRoute"
	K8sActualHTTPRoutes    = "httproutes"

	K8sReferenceGrants          = "k8sreferencegrants"
	K8sReferenceGrantType       = "K8sReferenceGrant"
	K8sActualReferenceGrantType = "ReferenceGrant"
	K8sActualReferenceGrants    = "referencegrants"

	K8sTCPRoutes          = "k8stcproutes"
	K8sTCPRouteType       = "K8sTCPRoute"
	K8sActualTCPRouteType = "TCPRoute"
	K8sActualTCPRoutes    = "tcproutes"

	K8sTLSRoutes          = "k8stlsroutes"
	K8sTLSRouteType       = "K8sTLSRoute"
	K8sActualTLSRouteType = "TLSRoute"
	K8sActualTLSRoutes    = "tlsroutes"

	// Authorization PeerAuthentications
	AuthorizationPolicies     = "authorizationpolicies"
	AuthorizationPoliciesType = "AuthorizationPolicy"

	// Peer Authentications
	PeerAuthentications     = "peerauthentications"
	PeerAuthenticationsType = "PeerAuthentication"

	// Request Authentications
	RequestAuthentications     = "requestauthentications"
	RequestAuthenticationsType = "RequestAuthentication"
)

Variables

View Source
var (
	KialiTokenForHomeCluster     string
	KialiTokenFileForHomeCluster string
)
View Source
var (
	NetworkingGroupVersionV1Alpha3 = schema.GroupVersion{
		Group:   "networking.istio.io",
		Version: "v1alpha3",
	}
	ApiNetworkingVersionV1Alpha3 = NetworkingGroupVersionV1Alpha3.Group + "/" + NetworkingGroupVersionV1Alpha3.Version

	NetworkingGroupVersionV1 = schema.GroupVersion{
		Group:   "networking.istio.io",
		Version: "v1",
	}
	ApiNetworkingVersionV1 = NetworkingGroupVersionV1.Group + "/" + NetworkingGroupVersionV1.Version

	K8sNetworkingGroupVersionV1Alpha2 = schema.GroupVersion{
		Group:   "gateway.networking.k8s.io",
		Version: "v1alpha2",
	}
	K8sApiNetworkingVersionV1Alpha2 = K8sNetworkingGroupVersionV1Alpha2.Group + "/" + K8sNetworkingGroupVersionV1Alpha2.Version

	K8sNetworkingGroupVersionV1Beta1 = schema.GroupVersion{
		Group:   "gateway.networking.k8s.io",
		Version: "v1beta1",
	}
	K8sApiNetworkingVersionV1Beta1 = K8sNetworkingGroupVersionV1Beta1.Group + "/" + K8sNetworkingGroupVersionV1Beta1.Version

	K8sNetworkingGroupVersionV1 = schema.GroupVersion{
		Group:   "gateway.networking.k8s.io",
		Version: "v1",
	}
	K8sApiNetworkingVersionV1 = K8sNetworkingGroupVersionV1.Group + "/" + K8sNetworkingGroupVersionV1.Version

	SecurityGroupVersionV1 = schema.GroupVersion{
		Group:   "security.istio.io",
		Version: "v1",
	}
	ApiSecurityVersionV1 = SecurityGroupVersionV1.Group + "/" + SecurityGroupVersionV1.Version

	ExtensionGroupVersionV1Alpha1 = schema.GroupVersion{
		Group:   "extensions.istio.io",
		Version: "v1alpha1",
	}
	ApiExtensionV1Alpha1 = ExtensionGroupVersionV1Alpha1.Group + "/" + ExtensionGroupVersionV1Alpha1.Version

	TelemetryGroupV1 = schema.GroupVersion{
		Group:   "telemetry.istio.io",
		Version: "v1",
	}
	ApiTelemetryV1 = TelemetryGroupV1.Group + "/" + TelemetryGroupV1.Version

	PluralType = map[string]string{

		Gateways:         GatewayType,
		VirtualServices:  VirtualServiceType,
		DestinationRules: DestinationRuleType,
		ServiceEntries:   ServiceEntryType,
		Sidecars:         SidecarType,
		WorkloadEntries:  WorkloadEntryType,
		WorkloadGroups:   WorkloadGroupType,
		EnvoyFilters:     EnvoyFilterType,
		WasmPlugins:      WasmPluginType,
		Telemetries:      TelemetryType,

		K8sGateways:        K8sGatewayType,
		K8sGRPCRoutes:      K8sGRPCRouteType,
		K8sHTTPRoutes:      K8sHTTPRouteType,
		K8sReferenceGrants: K8sReferenceGrantType,
		K8sTCPRoutes:       K8sTCPRouteType,
		K8sTLSRoutes:       K8sTLSRouteType,

		AuthorizationPolicies:  AuthorizationPoliciesType,
		PeerAuthentications:    PeerAuthenticationsType,
		RequestAuthentications: RequestAuthenticationsType,
	}

	ResourceTypesToAPI = map[string]string{
		DestinationRules: NetworkingGroupVersionV1.Group,
		EnvoyFilters:     NetworkingGroupVersionV1Alpha3.Group,
		Gateways:         NetworkingGroupVersionV1.Group,
		ServiceEntries:   NetworkingGroupVersionV1.Group,
		Sidecars:         NetworkingGroupVersionV1.Group,
		VirtualServices:  NetworkingGroupVersionV1.Group,
		WorkloadEntries:  NetworkingGroupVersionV1.Group,
		WorkloadGroups:   NetworkingGroupVersionV1.Group,
		WasmPlugins:      ExtensionGroupVersionV1Alpha1.Group,
		Telemetries:      TelemetryGroupV1.Group,

		K8sGateways:        K8sNetworkingGroupVersionV1.Group,
		K8sGRPCRoutes:      K8sNetworkingGroupVersionV1.Group,
		K8sHTTPRoutes:      K8sNetworkingGroupVersionV1.Group,
		K8sReferenceGrants: K8sNetworkingGroupVersionV1.Group,
		K8sTCPRoutes:       K8sNetworkingGroupVersionV1Alpha2.Group,
		K8sTLSRoutes:       K8sNetworkingGroupVersionV1Alpha2.Group,

		AuthorizationPolicies:  SecurityGroupVersionV1.Group,
		PeerAuthentications:    SecurityGroupVersionV1.Group,
		RequestAuthentications: SecurityGroupVersionV1.Group,
	}
)
View Source
var DefaultServiceAccountPath = "/var/run/secrets/kubernetes.io/serviceaccount/token"
View Source
var RemoteClusterSecretsDir = "/kiali-remote-cluster-secrets"

Defines where the files are located that contain the remote cluster secrets

Functions

func ClusterNameFromIstiod added in v1.87.0

func ClusterNameFromIstiod(conf config.Config, k8s ClientInterface) (string, error)

ClusterNameFromIstiod attempts to resolve the cluster info of the "home" cluster where kiali is running by inspecting the istiod deployment. Assumes that the istiod deployment is in the same cluster as the kiali pod.

func DestinationRuleHasMTLSEnabled added in v1.31.0

func DestinationRuleHasMTLSEnabled(destinationRule *networking_v1.DestinationRule) (bool, string)

func DestinationRuleHasMTLSEnabledForHost added in v0.16.0

func DestinationRuleHasMTLSEnabledForHost(expectedHost string, destinationRule *networking_v1.DestinationRule) (bool, string)

func DestinationRuleHasMeshWideMTLSEnabled added in v0.16.0

func DestinationRuleHasMeshWideMTLSEnabled(destinationRule *networking_v1.DestinationRule) (bool, string)

func DestinationRuleHasNamespaceWideMTLSEnabled added in v0.16.0

func DestinationRuleHasNamespaceWideMTLSEnabled(namespace string, destinationRule *networking_v1.DestinationRule) (bool, string)

func EnvVarIsTrue added in v1.87.0

func EnvVarIsTrue(key string, env core_v1.EnvVar) bool

EnvVarIsTrue tests if both the key is set and the value is true. Only use this when env.Value is a boolean string e.g. "true" or "false".

func FilterAuthorizationPoliciesBySelector added in v1.44.0

func FilterAuthorizationPoliciesBySelector(workloadSelector string, authorizationpolicies []*security_v1.AuthorizationPolicy) []*security_v1.AuthorizationPolicy

func FilterAutogeneratedDestinationRules added in v1.65.1

func FilterAutogeneratedDestinationRules(destinationRules []*networking_v1.DestinationRule) []*networking_v1.DestinationRule

func FilterAutogeneratedGateways added in v1.55.0

func FilterAutogeneratedGateways(gateways []*networking_v1.Gateway) []*networking_v1.Gateway

func FilterAutogeneratedVirtualServices added in v1.55.0

func FilterAutogeneratedVirtualServices(vss []*networking_v1.VirtualService) []*networking_v1.VirtualService

func FilterByHost

func FilterByHost(host, hostNamespace, serviceName, svcNamespace string) bool

FilterByHost returns true if a (host, hostNamespace) combination is making reference to a (serviceName, svcNamespace) combination. Presumably, the host is part of the definition of some Istio Resource. Thus, it can take the form of "host", "host.namespace" or "host.namespace.svc", or the FQDN "host.namespace.svc.<identity_domain_suffix>". For the cases where the host argument takes the simplistic form of only "host", you need to provide the hostNamespace argument, which should be set to the namespace of the involved Istio Resource. For the other cases, it is safe to omit it. The other arguments are always mandatory.

func FilterByNamespace added in v1.82.0

func FilterByNamespace[T runtime.Object](objects []T, namespace string) []T

FilterByNamespaces filters a list of runtime.Objects by the provided namespaces. If the object's namespace is not in the provided list of namespaces, the object is filtered out.

func FilterByNamespaceNames added in v1.87.0

func FilterByNamespaceNames[T runtime.Object](objects []T, namespaceNames []string) []T

FilterByNamespaceNames filters a list of runtime.Objects by the provided namespace names. If the object's namespace is not in the provided list of namespaces, the object is filtered out.

func FilterByRegistryService added in v1.44.0

func FilterByRegistryService(namespace string, hostname string, registryService *RegistryService) bool

func FilterDestinationRulesByHostname added in v1.44.0

func FilterDestinationRulesByHostname(allDr []*networking_v1.DestinationRule, hostname string) []*networking_v1.DestinationRule

func FilterDestinationRulesByService added in v1.44.0

func FilterDestinationRulesByService(allDr []*networking_v1.DestinationRule, namespace string, serviceName string) []*networking_v1.DestinationRule

func FilterEnvoyFiltersBySelector added in v1.44.0

func FilterEnvoyFiltersBySelector(workloadSelector string, envoyfilters []*networking_v1alpha3.EnvoyFilter) []*networking_v1alpha3.EnvoyFilter

func FilterGatewaysBySelector added in v1.44.0

func FilterGatewaysBySelector(workloadSelector string, gateways []*networking_v1.Gateway) []*networking_v1.Gateway

func FilterGatewaysByVirtualServices added in v1.44.0

func FilterGatewaysByVirtualServices(allGws []*networking_v1.Gateway, allVs []*networking_v1.VirtualService) []*networking_v1.Gateway

func FilterK8sGRPCRoutesByService added in v1.87.0

func FilterK8sGRPCRoutesByService(allRoutes []*k8s_networking_v1.GRPCRoute, referenceGrants []*k8s_networking_v1beta1.ReferenceGrant, namespace string, serviceName string) []*k8s_networking_v1.GRPCRoute

func FilterK8sGatewaysByRoutes added in v1.87.0

func FilterK8sGatewaysByRoutes(allGws []*k8s_networking_v1.Gateway, httpRoutes []*k8s_networking_v1.HTTPRoute, grpcRoutes []*k8s_networking_v1.GRPCRoute) []*k8s_networking_v1.Gateway

func FilterK8sHTTPRoutesByService added in v1.60.0

func FilterK8sHTTPRoutesByService(allRoutes []*k8s_networking_v1.HTTPRoute, referenceGrants []*k8s_networking_v1beta1.ReferenceGrant, namespace string, serviceName string) []*k8s_networking_v1.HTTPRoute

func FilterPeerAuthenticationsBySelector added in v1.44.0

func FilterPeerAuthenticationsBySelector(workloadSelector string, peerauthentications []*security_v1.PeerAuthentication) []*security_v1.PeerAuthentication

func FilterPodsByController added in v1.44.0

func FilterPodsByController(controllerName string, controllerType string, allPods []core_v1.Pod) []core_v1.Pod

func FilterPodsByEndpoints added in v1.44.0

func FilterPodsByEndpoints(endpoints *core_v1.Endpoints, unfiltered []core_v1.Pod) []core_v1.Pod

FilterPodsByEndpoints 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 FilterPodsBySelector added in v1.44.0

func FilterPodsBySelector(selector labels.Selector, allPods []core_v1.Pod) []core_v1.Pod

func FilterPodsByService added in v1.44.0

func FilterPodsByService(s *core_v1.Service, allPods []core_v1.Pod) []core_v1.Pod

FilterPodsByService returns a subpart of pod list filtered according service selector

func FilterRequestAuthenticationsBySelector added in v1.44.0

func FilterRequestAuthenticationsBySelector(workloadSelector string, requestauthentications []*security_v1.RequestAuthentication) []*security_v1.RequestAuthentication

func FilterServiceEntriesByHostname added in v1.44.0

func FilterServiceEntriesByHostname(serviceEntries []*networking_v1.ServiceEntry, hostname string) []*networking_v1.ServiceEntry

func FilterServicesByLabels added in v1.34.1

func FilterServicesByLabels(selector labels.Selector, allServices []core_v1.Service) []core_v1.Service

func FilterSidecarsBySelector added in v1.44.0

func FilterSidecarsBySelector(workloadSelector string, sidecars []*networking_v1.Sidecar) []*networking_v1.Sidecar

func FilterVirtualServiceByRoute added in v1.44.0

func FilterVirtualServiceByRoute(vs *networking_v1.VirtualService, service string, namespace string) bool

func FilterVirtualServicesByHostname added in v1.44.0

func FilterVirtualServicesByHostname(allVs []*networking_v1.VirtualService, hostname string) []*networking_v1.VirtualService

func FilterVirtualServicesByService added in v1.44.0

func FilterVirtualServicesByService(allVs []*networking_v1.VirtualService, namespace string, serviceName string) []*networking_v1.VirtualService

func GatewayAPIClasses added in v1.74.0

func GatewayAPIClasses(ambientEnabled bool) []config.GatewayAPIClass

func GatewayNames added in v0.7.0

func GatewayNames(gateways []*networking_v1.Gateway) map[string]struct{}

GatewayNames extracts the gateway names for easier matching

func GetKialiTokenForHomeCluster added in v1.64.0

func GetKialiTokenForHomeCluster() (string, string, error)

GetKialiTokenForHomeCluster returns the Kiali SA token to be used to communicate with the local data plane k8s api endpoint and the token file.

func GetPatchType added in v1.64.0

func GetPatchType(patchType string) types.PatchType

func GetRemoteClusterInfos added in v1.64.0

func GetRemoteClusterInfos() (map[string]RemoteClusterInfo, error)

GetRemoteClusterInfos loads remote cluster secrets that contain information about other remote mesh clusters. The returned map is keyed on cluster name.

func GetRemoteSecret added in v1.23.0

func GetRemoteSecret(path string) (*api.Config, error)

func HasMatchingReferenceGrant added in v1.79.0

func HasMatchingReferenceGrant(fromNamespace string, toNamespace string, fromKind string, toKind string, referenceGrants []*k8s_networking_v1beta1.ReferenceGrant) bool

HasMatchingReferenceGrant returns true when the From matches to given fromNamespace and fromKind and To matched given toNamespace and toKind.

func HasMatchingRegistryService added in v1.44.0

func HasMatchingRegistryService(namespace string, host string, registryServices []*RegistryService) bool

HasMatchingRegistryService returns true when the FDQN of the host (from given namespace) param matches with one registry service of the registryServices param.

func HasMatchingServiceEntries added in v1.15.0

func HasMatchingServiceEntries(service string, serviceEntries map[string][]string) bool

func HasMatchingServices added in v1.15.0

func HasMatchingServices(service string, services []core_v1.Service) bool

func HasMatchingVirtualServices added in v1.22.1

func HasMatchingVirtualServices(host Host, virtualServices []*networking_v1.VirtualService) bool

func HasMatchingWorkloads added in v1.15.0

func HasMatchingWorkloads(service string, workloadList []labels.Set) bool

func HostWithinWildcardHost added in v1.22.1

func HostWithinWildcardHost(subdomain, wildcardDomain string) bool

func IsAutogenerated added in v1.55.0

func IsAutogenerated(name string) bool

func K8sGatewayNames added in v1.63.0

func K8sGatewayNames(gateways []*k8s_networking_v1.Gateway) map[string]k8s_networking_v1.Gateway

K8sGatewayNames extracts the gateway names for easier matching

func MatchPortAppProtocolWithValidProtocols added in v1.44.0

func MatchPortAppProtocolWithValidProtocols(appProtocol *string) bool

func MatchPortNameRule added in v0.19.0

func MatchPortNameRule(portName, protocol string) bool

func MatchPortNameWithValidProtocols added in v0.19.0

func MatchPortNameWithValidProtocols(portName string) bool

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 NewTestingClientFactory added in v1.72.0

func NewTestingClientFactory(t *testing.T) *clientFactory

NewTestingClientFactory creates a client factory and a temporary token file. Without this token file, the client factory will try to read the token from the default path at /var/run/secrets/... which probably doesn't exist and we probably don't want to use it even if it does. This sets globals so it is NOT safe to use in parallel tests. It really should just be used for internal client factory tests since it has side effects with globals and local files/env vars. If you need a test client factory outside this package, use the mock implementation.

func ParseTwoPartHost added in v1.15.0

func ParseTwoPartHost(host Host) (string, string)

func PeerAuthnHasMTLSEnabled added in v1.18.1

func PeerAuthnHasMTLSEnabled(peerAuthn *security_v1.PeerAuthentication) (bool, string)

func PeerAuthnHasStrictMTLS added in v1.18.1

func PeerAuthnHasStrictMTLS(peerAuthn *security_v1.PeerAuthentication) bool

func PeerAuthnMTLSMode added in v1.31.0

func PeerAuthnMTLSMode(peerAuthn *security_v1.PeerAuthentication) (bool, string)

func ReadFile added in v1.59.0

func ReadFile(t *testing.T, path string) []byte

ReadFile reads a file's contents and calls t.Fatal if any error occurs.

func ServiceEntryHostnames added in v0.7.0

func ServiceEntryHostnames(serviceEntries []*networking_v1.ServiceEntry) map[string][]string

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 SetConfig added in v1.72.0

func SetConfig(t *testing.T, newConfig config.Config)

SetConfig sets the global config for a test and restores it after the test.

func ToRuntimeObjects added in v1.78.0

func ToRuntimeObjects[T runtime.Object](objs []T) []runtime.Object

ToRuntimeObjects takes a slice of something that implements runtime.Object and returns a new slice of the objects as the interface runtime.Object(s). Useful for testing where the fake client accepts variadic args and you first need to convert to a slice of the interface like:

namespaces := []*corev1.Namespace{ns} client := FakeClient(namespaces...)

This only works if you first use this function to convert the slice.

func ValidatePort added in v0.15.0

func ValidatePort(portDef *api_networking_v1.Port) bool

ValidatePort parses the Istio Port definition and validates the naming scheme

func ValidateServicePort added in v1.66.2

func ValidateServicePort(portDef *api_networking_v1.ServicePort) bool

ValidateServicePort parses the Istio Port definition and validates the naming scheme

Types

type ClientFactory added in v0.16.0

type ClientFactory interface {
	GetClient(authInfo *api.AuthInfo, cluster string) (ClientInterface, error)
	GetClients(authInfos map[string]*api.AuthInfo) (map[string]ClientInterface, error)
	GetSAClient(cluster string) ClientInterface
	GetSAClients() map[string]ClientInterface
	GetSAHomeClusterClient() ClientInterface
}

ClientFactory interface for the clientFactory object

func GetClientFactory added in v0.17.0

func GetClientFactory() (ClientFactory, error)

GetClientFactory returns the client factory. Creates a new one if necessary

func NewClientFactory added in v0.16.0

func NewClientFactory(ctx context.Context, conf kialiConfig.Config) (ClientFactory, error)

NewClientFactory creates a new client factory that can be transitory. Callers should close the ctx when done with the client factory. Does not set the global ClientFactory. You should probably use GetClientFactory instead of this method unless you temporaily need to create a client like when Kiali sets the cluster id.

type ClientInterface added in v1.20.0

type ClientInterface interface {
	GetServerVersion() (*version.Info, error)
	GetToken() string
	IsOpenShift() bool
	IsExpGatewayAPI() bool
	IsGatewayAPI() bool
	IsIstioAPI() bool
	// ClusterInfo returns some information about the cluster this client is connected to.
	// This gets set when the client is first created.
	ClusterInfo() ClusterInfo
	K8SClientInterface
	IstioClientInterface
	OSClientInterface
}

ClientInterface for mocks (only mocked function are necessary here)

type ClusterDump added in v1.28.0

type ClusterDump struct {
	DynamicClusters []EnvoyClusterWrapper `mapstructure:"dynamic_active_clusters"`
	StaticClusters  []EnvoyClusterWrapper `mapstructure:"static_clusters"`
}

type ClusterInfo added in v1.72.0

type ClusterInfo struct {
	// ClientConfig is the rest.Config is used to create clients for the various APIs.
	ClientConfig *rest.Config

	// Name is the name of the cluster this client is connected to.
	Name string

	// SecretName is the name of the secret that contains the credentials for this cluster.
	SecretName string
}

ClusterInfo is basically a rest.Config with a few extra fields that are useful to Kiali.

type ComponentStatus added in v1.59.0

type ComponentStatus struct {
	// Cluster where this component is deployed.
	// Can be unknown or external for external services.
	Cluster string `json:"-"`

	// Namespace where the component is deployed.
	// This field is ignored when marshalling to JSON.
	Namespace string `json:"-"`

	// The workload name of the Istio component.
	//
	// example: istio-ingressgateway
	// required: true
	Name string `json:"name"`

	// The status of an Istio component.
	//
	// example:  Not Found
	// required: true
	Status string `json:"status"`

	// When true, the component is necessary for Istio to function. Otherwise, it is an addon.
	//
	// example:  true
	// required: true
	IsCore bool `json:"is_core"`
}

type ConfigDump added in v1.28.0

type ConfigDump struct {
	Configs []interface{} `json:"configs"`
}

Root of ConfigDump

func (*ConfigDump) GetClusters added in v1.28.0

func (cd *ConfigDump) GetClusters() (*ClusterDump, error)

func (*ConfigDump) GetConfig added in v1.28.0

func (cd *ConfigDump) GetConfig(objectType string) map[string]interface{}

func (*ConfigDump) GetListeners added in v1.28.0

func (cd *ConfigDump) GetListeners() (*ListenerDump, error)

func (*ConfigDump) GetRoutes added in v1.28.0

func (cd *ConfigDump) GetRoutes() (*RouteDump, error)

type DynamicListener added in v1.28.0

type DynamicListener struct {
	Name        string         `mapstructure:"name"`
	ActiveState StaticListener `mapstructure:"active_state"`
}

type EnvoyCluster added in v1.28.0

type EnvoyCluster struct {
	Name     string         `mapstructure:"name"`
	Type     string         `mapstructure:"type"`
	Metadata *EnvoyMetadata `mapstructure:"metadata,omitempty"`
}

type EnvoyClusterWrapper added in v1.28.0

type EnvoyClusterWrapper struct {
	Cluster EnvoyCluster `mapstructure:"cluster"`
}

type EnvoyFilterChain added in v1.28.0

type EnvoyFilterChain struct {
	Filters          []EnvoyListenerFilter `mapstructure:"filters"`
	FilterChainMatch *FilterChainMatch     `mapstructure:"filter_chain_match"`
}

type EnvoyListener added in v1.28.0

type EnvoyListener struct {
	Address struct {
		SocketAddress struct {
			Address   string  `mapstructure:"address"`
			PortValue float64 `mapstructure:"port_value"`
		} `mapstructure:"socket_address"`
	} `mapstructure:"address"`
	FilterChains       []EnvoyFilterChain `mapstructure:"filter_chains,omitempty"`
	DefaultFilterChain *EnvoyFilterChain  `mapstructure:"default_filter_chain,omitempty"`
}

type EnvoyListenerFilter added in v1.28.0

type EnvoyListenerFilter struct {
	Name        string `mapstructure:"name"`
	TypedConfig struct {
		Type        string       `mapstructure:"@type"`
		Cluster     string       `mapstructure:"cluster"`
		RouteConfig *RouteConfig `mapstructure:"route_config,omitempty"`
		Rds         *struct {
			RouteConfigName string `mapstructure:"route_config_name"`
		} `mapstructure:"rds,omitempty"`
	} `mapstructure:"typed_config"`
}

type EnvoyMetadata added in v1.28.0

type EnvoyMetadata struct {
	FilterMetadata *struct {
		Istio *struct {
			Config string `mapstructure:"config,omitempty"`
		} `mapstructure:"istio,omitempty"`
	} `mapstructure:"filter_metadata,omitempty"`
}

type EnvoyRouteConfig added in v1.28.0

type EnvoyRouteConfig struct {
	RouteConfig *RouteConfig `mapstructure:"route_config,omitempty"`
}

type FilterChainMatch added in v1.28.0

type FilterChainMatch struct {
	ApplicationProtocols []string `mapstructure:"application_protocols,omitempty"`
	TransportProtocol    string   `mapstructure:"transport_protocol,omitempty"`
	ServerNames          []string `mapstructure:"server_names,omitempty"`
	DestinationPort      *int32   `mapstructure:"destination_port,omitempty"`
	PrefixRanges         []struct {
		AddressPrefix string `mapstructure:"address_prefix"`
		PrefixLen     int    `mapstructure:"prefix_len"`
	} `mapstructure:"prefix_ranges"`
}

type Host added in v0.15.0

type Host struct {
	Service   string `json:"service"`
	Namespace string `json:"namespace"`
	Cluster   string `json:"cluster"`
	// CompleteInput is true when Service, Namespace and Cluster fields are present.
	// It is true for simple service names and FQDN services.
	// It is false for service.namespace format and service entries.
	CompleteInput bool `json:"complete_input"`
}

Host represents the FQDN format for Istio hostnames

func GetHost added in v1.12.0

func GetHost(hostName, namespace string, clusterNamespaces []string) Host

GetHost parses hostName and returns a Host struct. It considers Namespaces in the cluster to be more accurate when deciding if the hostName is a ServiceEntry or a service.namespace host definition.

func ParseGatewayAsHost added in v1.19.0

func ParseGatewayAsHost(gateway, currentNamespace string) Host

func ParseHost added in v0.15.0

func ParseHost(hostName, namespace string) Host

ParseHost takes as an input a hostname (simple or full FQDN), namespace and clusterName and returns a parsed Host struct

func (Host) IsWildcard added in v1.40.0

func (h Host) IsWildcard() bool

func (Host) String added in v0.15.0

func (h Host) String() string

String outputs a full FQDN version of the Host

type IstioClientInterface

type IstioClientInterface interface {
	Istio() istio.Interface
	// GatewayAPI returns the gateway-api kube client.
	GatewayAPI() gatewayapiclient.Interface

	GetConfigDump(namespace, podName string) (*ConfigDump, error)
	SetProxyLogLevel(namespace, podName, level string) error
}

type IstioComponentStatus added in v1.59.0

type IstioComponentStatus []ComponentStatus

func (*IstioComponentStatus) Merge added in v1.59.0

type IstioService added in v1.44.0

type IstioService struct {
	Attributes struct {
		// ServiceRegistry values:
		// Kubernetes: 	is a service registry backed by k8s API server
		// External: 	is a service registry for externally provided ServiceEntries
		// Federation:  special case when registry is provided from a federated environment
		ServiceRegistry string            `json:"ServiceRegistry,omitempty"`
		Name            string            `json:"Name,omitempty"`
		Namespace       string            `json:"Namespace,omitempty"`
		Labels          map[string]string `json:"Labels,omitempty"`
		// ExportTo key values:
		// ".":		Private implies namespace local config
		// "*":		Public implies config is visible to all
		// "~":		None implies service is visible to no one. Used for services only
		ExportTo       map[string]struct{} `json:"ExportTo,omitempty"`
		LabelSelectors map[string]string   `json:"LabelSelectors,omitempty"`
	} `json:"Attributes,omitempty"`
	Ports []struct {
		Name     string `json:"name,omitempty"`
		Port     int    `json:"port"`
		Protocol string `json:"protocol,omitempty"`
	} `json:"ports"`
	Hostname string `json:"hostname"`
	// ClusterVIPs defined in Istio 1.11.x
	ClusterVIPs11 map[string]string `json:"cluster-vips,omitempty"`
	// ClusterVIPs defined in Istio 1.12.x
	ClusterVIPs12 struct {
		Addresses map[string][]string `json:"Addresses,omitempty"`
	} `json:"clusterVIPs,omitempty"`
}

Mapped from https://github.com/istio/istio/blob/master/pilot/pkg/model/service.go It's a helper to fetch the /debug/registryz results before to parse it to the Kiali's Service model Not all fields from /debug/registryz are mapped, only those needed by Kiali There may be differences between Istio 1.11.x and 1.12.x to be addressed case by case in the mapping

type K8SClient added in v1.20.0

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

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

func NewClient

func NewClient(
	kubeClient kube.Interface,
	istioClient istio.Interface,
	gatewayapiClient gatewayapiclient.Interface,
	osAppsClient osappsclient.Interface,
	projectClient projectclient.Interface,
	routeClient routeclient.Interface,
	userClient userclient.Interface,
	oAuthClient oauthclient.Interface,
) *K8SClient

NewClient is just used for testing purposes.

func (*K8SClient) ClusterInfo added in v1.72.0

func (client *K8SClient) ClusterInfo() ClusterInfo

func (*K8SClient) DeleteOAuthToken added in v1.84.0

func (in *K8SClient) DeleteOAuthToken(ctx context.Context, token string) error

func (*K8SClient) ForwardGetRequest added in v1.38.1

func (in *K8SClient) ForwardGetRequest(namespace, podName string, destinationPort int, path string) ([]byte, error)

func (*K8SClient) GatewayAPI added in v1.57.0

func (in *K8SClient) GatewayAPI() gatewayapiclient.Interface

func (*K8SClient) GetClusterServicesByLabels added in v1.34.1

func (in *K8SClient) GetClusterServicesByLabels(labelsSelector string) ([]core_v1.Service, error)

GetClusterServicesByLabels fetches and returns all services in the whole cluster that match the optional labelSelector. This is using the cluster-wide call to fetch the services. The client will need to be created with an account that has cluster-wide privileges to list services.

func (*K8SClient) GetConfigDump added in v1.28.0

func (in *K8SClient) GetConfigDump(namespace, podName string) (*ConfigDump, error)

func (*K8SClient) GetConfigMap added in v1.20.0

func (in *K8SClient) GetConfigMap(namespace, name string) (*core_v1.ConfigMap, error)

GetConfigMap fetches and returns the specified ConfigMap definition from the cluster

func (*K8SClient) GetCronJobs added in v1.20.0

func (in *K8SClient) GetCronJobs(namespace string) ([]batch_v1.CronJob, error)

func (*K8SClient) GetDeployment added in v1.20.0

func (in *K8SClient) GetDeployment(namespace, name string) (*apps_v1.Deployment, error)

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

func (*K8SClient) GetDeploymentConfig added in v1.20.0

func (in *K8SClient) GetDeploymentConfig(ctx context.Context, namespace string, name string) (*osapps_v1.DeploymentConfig, error)

func (*K8SClient) GetDeploymentConfigs added in v1.20.0

func (in *K8SClient) GetDeploymentConfigs(ctx context.Context, namespace string) ([]osapps_v1.DeploymentConfig, error)

func (*K8SClient) GetDeployments added in v1.20.0

func (in *K8SClient) GetDeployments(namespace string, opts meta_v1.ListOptions) ([]apps_v1.Deployment, error)

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

func (*K8SClient) GetJobs added in v1.20.0

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

func (*K8SClient) GetNamespace added in v1.20.0

func (in *K8SClient) GetNamespace(namespace string) (*core_v1.Namespace, error)

GetNamespace fetches and returns the specified namespace definition from the cluster

func (*K8SClient) GetNamespaces added in v1.20.0

func (in *K8SClient) GetNamespaces(labelSelector string) ([]core_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 (*K8SClient) GetOAuthClient added in v1.84.0

func (in *K8SClient) GetOAuthClient(ctx context.Context, name string) (*osoauth_v1.OAuthClient, error)

func (*K8SClient) GetPod added in v1.20.0

func (in *K8SClient) GetPod(namespace, name string) (*core_v1.Pod, error)

GetPod returns the pod definitions for a given pod name. It returns an error on any problem.

func (*K8SClient) GetProject added in v1.20.0

func (in *K8SClient) GetProject(ctx context.Context, name string) (*osproject_v1.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 (*K8SClient) GetProjects added in v1.20.0

func (in *K8SClient) GetProjects(ctx context.Context, labelSelector string) ([]osproject_v1.Project, error)

func (*K8SClient) GetReplicationControllers added in v1.20.0

func (in *K8SClient) GetReplicationControllers(namespace string) ([]core_v1.ReplicationController, error)

func (*K8SClient) GetRoute added in v1.20.0

func (in *K8SClient) GetRoute(ctx context.Context, namespace string, name string) (*osroutes_v1.Route, error)

func (*K8SClient) GetSecret added in v1.40.0

func (in *K8SClient) GetSecret(namespace, name string) (*core_v1.Secret, error)

GetSecret fetches and returns the specified Secret definition from the cluster

func (*K8SClient) GetSelfSubjectAccessReview added in v1.20.0

func (in *K8SClient) GetSelfSubjectAccessReview(ctx context.Context, namespace, api, resourceType string, verbs []string) ([]*auth_v1.SelfSubjectAccessReview, error)

GetSelfSubjectAccessReview provides information on Kiali permissions

func (*K8SClient) GetServerVersion added in v1.20.0

func (in *K8SClient) GetServerVersion() (*version.Info, error)

GetServerVersion fetches and returns information about the version Kubernetes that is running

func (*K8SClient) GetToken added in v1.20.0

func (client *K8SClient) GetToken() string

GetToken returns the BearerToken used from the config

func (*K8SClient) GetTokenSubject added in v1.29.0

func (in *K8SClient) GetTokenSubject(authInfo *api.AuthInfo) (string, error)

GetTokenSubject returns the subject of the authInfo using the TokenReview api

func (*K8SClient) GetUser added in v1.84.0

func (in *K8SClient) GetUser(ctx context.Context, name string) (*osuser_v1.User, error)

func (*K8SClient) IsExpGatewayAPI added in v1.79.0

func (in *K8SClient) IsExpGatewayAPI() bool

func (*K8SClient) IsGatewayAPI added in v1.57.0

func (in *K8SClient) IsGatewayAPI() bool

func (*K8SClient) IsIstioAPI added in v1.66.0

func (in *K8SClient) IsIstioAPI() bool

Is IstioAPI checks whether Istio API is installed or not

func (*K8SClient) IsOpenShift added in v1.20.0

func (in *K8SClient) IsOpenShift() bool

func (*K8SClient) Istio added in v1.42.0

func (in *K8SClient) Istio() istio.Interface

func (*K8SClient) Kube added in v1.64.0

func (in *K8SClient) Kube() kubernetes.Interface

func (*K8SClient) SetProxyLogLevel added in v1.41.0

func (in *K8SClient) SetProxyLogLevel(namespace, pod, level string) error

func (*K8SClient) StreamPodLogs added in v1.53.0

func (in *K8SClient) StreamPodLogs(namespace, name string, opts *core_v1.PodLogOptions) (io.ReadCloser, error)

StreamPodLogs opens a connection to progressively fetch the logs of a pod. Callers must make sure to properly close the returned io.ReadCloser. It returns an error on any problem.

func (*K8SClient) UpdateNamespace added in v1.22.1

func (in *K8SClient) UpdateNamespace(namespace string, jsonPatch string) (*core_v1.Namespace, error)

func (*K8SClient) UpdateProject added in v1.22.1

func (in *K8SClient) UpdateProject(ctx context.Context, project string, jsonPatch string) (*osproject_v1.Project, error)

func (*K8SClient) UpdateService added in v1.30.0

func (in *K8SClient) UpdateService(namespace string, name string, jsonPatch string, patchType string) error

func (*K8SClient) UpdateWorkload added in v1.22.0

func (in *K8SClient) UpdateWorkload(namespace string, workloadName string, workloadType string, jsonPatch string, patchType string) error

type K8SClientInterface added in v1.20.0

type K8SClientInterface interface {
	// Kube returns the underlying kubernetes client.
	Kube() kubernetes.Interface

	GetConfigMap(namespace, name string) (*core_v1.ConfigMap, error)
	GetCronJobs(namespace string) ([]batch_v1.CronJob, error)
	GetDeployment(namespace string, name string) (*apps_v1.Deployment, error)
	GetDeployments(namespace string, opts meta_v1.ListOptions) ([]apps_v1.Deployment, error)
	GetJobs(namespace string) ([]batch_v1.Job, error)
	GetNamespace(namespace string) (*core_v1.Namespace, error)
	GetNamespaces(labelSelector string) ([]core_v1.Namespace, error)
	GetPod(namespace, name string) (*core_v1.Pod, error)
	GetReplicationControllers(namespace string) ([]core_v1.ReplicationController, error)
	GetSecret(namespace, name string) (*core_v1.Secret, error)
	GetSelfSubjectAccessReview(ctx context.Context, namespace, api, resourceType string, verbs []string) ([]*auth_v1.SelfSubjectAccessReview, error)
	GetTokenSubject(authInfo *api.AuthInfo) (string, error)
	ForwardGetRequest(namespace, podName string, destinationPort int, path string) ([]byte, error)
	StreamPodLogs(namespace, name string, opts *core_v1.PodLogOptions) (io.ReadCloser, error)
	UpdateNamespace(namespace string, jsonPatch string) (*core_v1.Namespace, error)
	UpdateService(namespace string, name string, jsonPatch string, patchType string) error
	UpdateWorkload(namespace string, name string, workloadType string, jsonPatch string, patchType string) error
}

type ListenerDump added in v1.28.0

type ListenerDump struct {
	DynamicListeners []DynamicListener `mapstructure:"dynamic_listeners"`
	StaticListeners  []StaticListener  `mapstructure:"static_listeners"`
}

type MTLSDetails added in v0.15.0

type MTLSDetails struct {
	DestinationRules        []*networking_v1.DestinationRule  `json:"destinationrules"`
	MeshPeerAuthentications []*security_v1.PeerAuthentication `json:"meshpeerauthentications"`
	PeerAuthentications     []*security_v1.PeerAuthentication `json:"peerauthentications"`
	EnabledAutoMtls         bool                              `json:"enabledautomtls"`
}

MTLSDetails is a wrapper to group all Istio objects related to non-local mTLS configurations

type OSClientInterface added in v1.20.0

type OSClientInterface interface {
	DeleteOAuthToken(ctx context.Context, token string) error
	GetDeploymentConfig(ctx context.Context, namespace string, name string) (*osapps_v1.DeploymentConfig, error)
	GetDeploymentConfigs(ctx context.Context, namespace string) ([]osapps_v1.DeploymentConfig, error)
	GetOAuthClient(ctx context.Context, name string) (*osoauth_v1.OAuthClient, error)
	GetProject(ctx context.Context, project string) (*osproject_v1.Project, error)
	GetProjects(ctx context.Context, labelSelector string) ([]osproject_v1.Project, error)
	GetRoute(ctx context.Context, namespace string, name string) (*osroutes_v1.Route, error)
	GetUser(ctx context.Context, name string) (*osuser_v1.User, error)
	UpdateProject(ctx context.Context, project string, jsonPatch string) (*osproject_v1.Project, error)
}

type PodLogs added in v0.18.0

type PodLogs struct {
	Logs string `json:"logs,omitempty"`
}

type ProxyStatus added in v1.25.0

type ProxyStatus struct {
	Pilot string
	SyncStatus
}

type RBACDetails added in v0.17.0

type RBACDetails struct {
	AuthorizationPolicies []*security_v1.AuthorizationPolicy `json:"authorizationpolicies"`
}

RBACDetails is a wrapper for objects related to Istio RBAC (Role Based Access Control)

type RegistryService added in v1.35.0

type RegistryService struct {
	Pilot string
	IstioService
}

func FilterRegistryServicesBySelector added in v1.45.0

func FilterRegistryServicesBySelector(selector labels.Selector, namespace string, registryServices []*RegistryService) []*RegistryService

func FilterRegistryServicesByServices added in v1.44.0

func FilterRegistryServicesByServices(registryServices []*RegistryService, services []core_v1.Service) []*RegistryService

Filter Istio registry that are not persent as kubernetes services

type RegistryStatus added in v1.35.0

type RegistryStatus struct {
	Services []*RegistryService
}

type RemoteClusterInfo added in v1.64.0

type RemoteClusterInfo struct {
	// Config contains information necessary to connect to the remote cluster
	Config clientcmd.ClientConfig
	// SecretFile is the absolute file location of the secret as found on the file system
	SecretFile string
	// SecretName is the name of the secret where the data about this cluster was found
	SecretName string
}

RemoteClusterInfo is data that identifies a cluster particpating in the mesh. Multi-cluster meshes have multiple RemoteClusterInfos. Information obtained for a RemoteClusterInfo comes from remote cluster secrets.

type RouteConfig added in v1.28.0

type RouteConfig struct {
	Name         string              `mapstructure:"name"`
	VirtualHosts []VirtualHostFilter `mapstructure:"virtual_hosts,omitempty"`
}

type RouteDump added in v1.28.0

type RouteDump struct {
	DynamicRouteConfigs []EnvoyRouteConfig `mapstructure:"dynamic_route_configs"`
	StaticRouteConfigs  []EnvoyRouteConfig `mapstructure:"static_route_configs"`
}

type StaticListener added in v1.28.0

type StaticListener struct {
	LastUpdated string        `mapstructure:"last_updated"`
	VersionInfo string        `mapstructure:"version_info"`
	Listener    EnvoyListener `mapstructure:"listener"`
}

type SyncStatus added in v1.25.0

type SyncStatus struct {
	ClusterID     string `json:"cluster_id,omitempty"`
	ProxyID       string `json:"proxy,omitempty"`
	ProxyVersion  string `json:"proxy_version,omitempty"`
	IstioVersion  string `json:"istio_version,omitempty"`
	ClusterSent   string `json:"cluster_sent,omitempty"`
	ClusterAcked  string `json:"cluster_acked,omitempty"`
	ListenerSent  string `json:"listener_sent,omitempty"`
	ListenerAcked string `json:"listener_acked,omitempty"`
	RouteSent     string `json:"route_sent,omitempty"`
	RouteAcked    string `json:"route_acked,omitempty"`
	EndpointSent  string `json:"endpoint_sent,omitempty"`
	EndpointAcked string `json:"endpoint_acked,omitempty"`
}

SyncStatus is the synchronization status between Pilot and a given Envoy

type VirtualHostFilter added in v1.28.0

type VirtualHostFilter struct {
	Domains []string `mapstructure:"domains,omitempty"`
	Name    string   `mapstructure:"name,omitempty"`
	Routes  []struct {
		Name     string                 `mapstructure:"name"`
		Match    map[string]interface{} `mapstructure:"match"`
		Metadata *EnvoyMetadata         `mapstructure:"metadata,omitempty"`
		Route    *struct {
			Cluster string `mapstructure:"cluster,omitempty"`
		} `mapstructure:"route,omitempty"`
	} `mapstructure:"routes,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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