istio: istio.io/istio/pkg/kube Index | Files | Directories

package kube

import "istio.io/istio/pkg/kube"

Index

Package Files

client.go client_config.go client_factory.go portforwarder.go spdy.go util.go

func BuildClientCmd Uses

func BuildClientCmd(kubeconfig, context string) clientcmd.ClientConfig

BuildClientCmd builds a client cmd config from a kubeconfig filepath and context. It overrides the current context with the one provided (empty to use default).

This is a modified version of k8s.io/client-go/tools/clientcmd/BuildConfigFromFlags with the difference that it loads default configs if not running in-cluster.

func BuildClientConfig Uses

func BuildClientConfig(kubeconfig, context string) (*rest.Config, error)

BuildClientConfig builds a client rest config from a kubeconfig filepath and context. It overrides the current context with the one provided (empty to use default).

This is a modified version of k8s.io/client-go/tools/clientcmd/BuildConfigFromFlags with the difference that it loads default configs if not running in-cluster.

func CheckPodReady Uses

func CheckPodReady(pod *kubeApiCore.Pod) error

CheckPodReady returns nil if the given pod and all of its containers are ready.

func CreateClientset Uses

func CreateClientset(kubeconfig, context string, fns ...func(*rest.Config)) (*kubernetes.Clientset, error)

CreateClientset is a helper function that builds a kubernetes Clienset from a kubeconfig filepath. See `BuildClientConfig` for kubeconfig loading rules.

func DefaultRestConfig Uses

func DefaultRestConfig(kubeconfig, configContext string, fns ...func(*rest.Config)) (*rest.Config, error)

DefaultRestConfig returns the rest.Config for the given kube config file and context.

func NewClientConfigForRestConfig Uses

func NewClientConfigForRestConfig(restConfig *rest.Config) clientcmd.ClientConfig

NewClientConfigForRestConfig creates a new k8s clientcmd.ClientConfig from the given rest.Config.

func SetRestDefaults Uses

func SetRestDefaults(config *rest.Config) *rest.Config

SetRestDefaults is a helper function that sets default values for the given rest.Config.

type Client Uses

type Client interface {
    // TODO - stop embedding this, it will conflict with future additions. Use Kube() instead is preferred
    // TODO - add istio/client-go and service-apis
    kubernetes.Interface
    // RESTConfig returns the Kubernetes rest.Config used to configure the clients.
    RESTConfig() *rest.Config

    // Rest returns the raw Kubernetes REST client.
    REST() rest.Interface

    // Ext returns the API extensions client.
    Ext() kubeExtClient.Interface

    // Kube returns the core kube client
    Kube() kubernetes.Interface

    // Dynamic client.
    Dynamic() dynamic.Interface

    // Metadata returns the Metadata kube client.
    Metadata() metadata.Interface

    // Istio returns the Istio kube client.
    Istio() istioclient.Interface

    // ServiceApis returns the service-apis kube client.
    ServiceApis() serviceapisclient.Interface

    // KubeInformer returns an informer for core kube client
    KubeInformer() informers.SharedInformerFactory

    // DynamicInformer returns an informer for dynamic client
    DynamicInformer() dynamicinformer.DynamicSharedInformerFactory

    // MetadataInformer returns an informer for metadata client
    MetadataInformer() metadatainformer.SharedInformerFactory

    // IstioInformer returns an informer for the istio client
    IstioInformer() istioinformer.SharedInformerFactory

    // ServiceApisInformer returns an informer for the service-apis client
    ServiceApisInformer() serviceapisinformer.SharedInformerFactory

    // RunAndWait starts all informers and waits for their caches to sync.
    // Warning: this must be called AFTER .Informer() is called, which will register the informer.
    RunAndWait(stop <-chan struct{})
}

Client is a helper for common Kubernetes client operations. This contains various different kubernetes clients using a shared config. It is expected that all of Istiod can share the same set of clients and informers. Sharing informers is especially important for load on the API server/Istiod itself.

func NewClient Uses

func NewClient(clientConfig clientcmd.ClientConfig) (Client, error)

NewClient creates a Kubernetes client from the given rest config.

func NewFakeClient Uses

func NewFakeClient() Client

type ExtendedClient Uses

type ExtendedClient interface {
    Client
    // Revision of the Istio control plane.
    Revision() string

    // GetKubernetesVersion returns the Kubernetes server version
    GetKubernetesVersion() (*kubeVersion.Info, error)

    // EnvoyDo makes an http request to the Envoy in the specified pod.
    EnvoyDo(ctx context.Context, podName, podNamespace, method, path string, body []byte) ([]byte, error)

    // AllDiscoveryDo makes an http request to each Istio discovery instance.
    AllDiscoveryDo(ctx context.Context, namespace, path string) (map[string][]byte, error)

    // GetIstioVersions gets the version for each Istio control plane component.
    GetIstioVersions(ctx context.Context, namespace string) (*version.MeshInfo, error)

    // PodsForSelector finds pods matching selector.
    PodsForSelector(ctx context.Context, namespace string, labelSelectors ...string) (*v1.PodList, error)

    // GetIstioPods retrieves the pod objects for Istio deployments
    GetIstioPods(ctx context.Context, namespace string, params map[string]string) ([]v1.Pod, error)

    // PodExec takes a command and the pod data to run the command in the specified pod.
    PodExec(podName, podNamespace, container string, command string) (stdout string, stderr string, err error)

    // PodLogs retrieves the logs for the given pod.
    PodLogs(ctx context.Context, podName string, podNamespace string, container string, previousLog bool) (string, error)

    // NewPortForwarder creates a new PortForwarder configured for the given pod. If localPort=0, a port will be
    // dynamically selected. If localAddress is empty, "localhost" is used.
    NewPortForwarder(podName string, ns string, localAddress string, localPort int, podPort int) (PortForwarder, error)

    // ApplyYAMLFiles applies the resources in the given YAML files.
    ApplyYAMLFiles(namespace string, yamlFiles ...string) error

    // ApplyYAMLFilesDryRun performs a dry run for applying the resource in the given YAML files
    ApplyYAMLFilesDryRun(namespace string, yamlFiles ...string) error

    // DeleteYAMLFiles deletes the resources in the given YAML files.
    DeleteYAMLFiles(namespace string, yamlFiles ...string) error

    // DeleteYAMLFilesDryRun performs a dry run for deleting the resources in the given YAML files.
    DeleteYAMLFilesDryRun(namespace string, yamlFiles ...string) error
}

ExtendedClient is an extended client with additional helpers/functionality for Istioctl and testing.

func NewExtendedClient Uses

func NewExtendedClient(clientConfig clientcmd.ClientConfig, revision string) (ExtendedClient, error)

NewExtendedClient creates a Kubernetes client from the given ClientConfig. The "revision" parameter controls the behavior of GetIstioPods, by selecting a specific revision of the control plane.

type PortForwarder Uses

type PortForwarder interface {
    // Run this forwarder.
    Start() error

    // Address returns the local forwarded address. Only valid while the forwarder is running.
    Address() string

    // Close this forwarder and release an resources.
    Close()

    // Block until connection closed (e.g. control-C interrupt)
    WaitForStop()
}

PortForwarder manages the forwarding of a single port.

Directories

PathSynopsis
injectPackage inject implements kube-inject or webhoook autoinject feature to inject sidecar.
secretcontroller

Package kube imports 58 packages (graph) and is imported by 24 packages. Updated 2020-07-02. Refresh now. Tools for package owners.