package kubernetes
import "golang.org/x/build/kubernetes"
Package kubernetes contains a minimal client for the Kubernetes API.
Index ¶
- type Client
- func NewClient(baseURL, namespace string, client *http.Client) (*Client, error)
- func (c *Client) Close() error
- func (c *Client) DeletePod(ctx context.Context, podName string) error
- func (c *Client) DialPod(ctx context.Context, podName string, port int) (net.Conn, error)
- func (c *Client) DialService(ctx context.Context, serviceName string) (net.Conn, error)
- func (c *Client) DialServicePort(ctx context.Context, serviceName, portName string) (net.Conn, error)
- func (c *Client) GetNodes(ctx context.Context) ([]api.Node, error)
- func (c *Client) GetPods(ctx context.Context) ([]api.Pod, error)
- func (c *Client) GetServiceEndpoints(ctx context.Context, serviceName, portName string) ([]Endpoint, error)
- func (c *Client) GetServices(ctx context.Context) ([]api.Service, error)
- func (c *Client) PodLog(ctx context.Context, podName string) (string, error)
- func (c *Client) PodStatus(ctx context.Context, podName string) (*api.PodStatus, error)
- func (c *Client) RunLongLivedPod(ctx context.Context, pod *api.Pod) (*api.PodStatus, error)
- type Endpoint
- type PodStatusResult
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for the Kubernetes master.
func NewClient ¶
NewClient returns a new Kubernetes client. The provided host is an url (scheme://hostname[:port]) of a Kubernetes master without any path. The provided client is an authorized http.Client used to perform requests to the Kubernetes API master.
func (*Client) Close ¶
Close closes any idle HTTP connections still connected to the Kubernetes master.
func (*Client) DeletePod ¶
DeletePod deletes the specified Kubernetes pod.
func (*Client) DialPod ¶
func (*Client) DialService ¶
DialService connects to the named service. The service must have only one port. For multi-port services, use DialServicePort.
func (*Client) DialServicePort ¶
func (c *Client) DialServicePort(ctx context.Context, serviceName, portName string) (net.Conn, error)
DialServicePort connects to the named port on the named service. If portName is the empty string, the service must have exactly 1 port.
func (*Client) GetNodes ¶
GetNodes returns the list of nodes that comprise the Kubernetes cluster
func (*Client) GetPods ¶
GetPods returns all pods in the cluster, regardless of status.
func (*Client) GetServiceEndpoints ¶
func (c *Client) GetServiceEndpoints(ctx context.Context, serviceName, portName string) ([]Endpoint, error)
GetServiceEndpoints returns the endpoints for the named service. If portName is non-empty, only endpoints matching that port name are returned.
func (*Client) GetServices ¶
GetServices returns all services in the cluster, regardless of status.
func (*Client) PodLog ¶
PodLog retrieves the container log for the first container in the pod.
func (*Client) PodStatus ¶
Retrieve the status of a pod synchronously from the Kube API server.
func (*Client) RunLongLivedPod ¶
RunLongLivedPod creates a new pod resource in the default pod namespace with the given pod API specification. It assumes the pod runs a long-lived server (i.e. if the container exit quickly, even with success, then that is an error).
It returns the pod status once it has entered the Running phase. An error is returned if the pod can not be created, or if ctx.Done is closed.
type Endpoint ¶
type Endpoint struct { IP string Port int PortName string Protocol string // "TCP" or "UDP"; never empty }
Endpoint represents a service endpoint address.
type PodStatusResult ¶
PodStatusResult wraps an api.PodStatus and error.
Source Files ¶
client.go dialer.go
Directories ¶
Path | Synopsis |
---|---|
kubernetes/api | Package api contains the Kubernetes v1 API types. |
kubernetes/gke | Package gke contains code for interacting with Google Container Engine (GKE), the hosted version of Kubernetes on Google Cloud Platform. |
- Version
- v0.0.0-20250421191922-3619c213cff3 (latest)
- Published
- Apr 21, 2025
- Platform
- darwin/amd64
- Imports
- 17 packages
- Last checked
- 1 second ago –
Tools for package owners.