go-micro: github.com/micro/go-micro/util/kubernetes/client Index | Files

package client

import "github.com/micro/go-micro/util/kubernetes/client"

Package client provides an implementation of a restricted subset of kubernetes API client


Package Files

client.go options.go templates.go types.go util.go watch.go


var (

    // ErrReadNamespace is returned when the names could not be read from service account
    ErrReadNamespace = errors.New("Could not read namespace from service account secret")
    // DefaultImage is default micro image
    DefaultImage = "micro/go-micro"

func CertPoolFromFile Uses

func CertPoolFromFile(filename string) (*x509.CertPool, error)

CertPoolFromFile returns an x509.CertPool containing the certificates in the given PEM-encoded file. Returns an error if the file could not be read, a certificate could not be parsed, or if the file does not contain any certificates

func CertsFromPEM Uses

func CertsFromPEM(pemCerts []byte) ([]*x509.Certificate, error)

CertsFromPEM returns the x509.Certificates contained in the given PEM-encoded byte array Returns an error if a certificate could not be parsed, or if the data does not contain any certificates

func Format Uses

func Format(v string) string

Format is used to format a string value into a k8s valid name

func NewClusterClient Uses

func NewClusterClient() *client

NewClusterClient creates a Kubernetes client for use from within a k8s pod.

func NewLocalClient Uses

func NewLocalClient(hosts ...string) *client

NewLocalClient returns a client that can be used with `kubectl proxy`

type Client Uses

type Client interface {
    // Create creates new API resource
    Create(*Resource) error
    // Get queries API resrouces
    Get(*Resource, map[string]string) error
    // Update patches existing API object
    Update(*Resource) error
    // Delete deletes API resource
    Delete(*Resource) error
    // List lists API resources
    List(*Resource) error
    // Log gets log for a pod
    Log(*Resource, ...LogOption) (io.ReadCloser, error)
    // Watch for events
    Watch(*Resource, ...WatchOption) (Watcher, error)

Kubernetes client

type Container Uses

type Container struct {
    Name    string          `json:"name"`
    Image   string          `json:"image"`
    Env     []EnvVar        `json:"env,omitempty"`
    Command []string        `json:"command,omitempty"`
    Args    []string        `json:"args,omitempty"`
    Ports   []ContainerPort `json:"ports,omitempty"`

Container defined container runtime values

type ContainerPort Uses

type ContainerPort struct {
    Name          string `json:"name,omitempty"`
    HostPort      int    `json:"hostPort,omitempty"`
    ContainerPort int    `json:"containerPort"`
    Protocol      string `json:"protocol,omitempty"`


type Deployment Uses

type Deployment struct {
    Metadata *Metadata         `json:"metadata"`
    Spec     *DeploymentSpec   `json:"spec,omitempty"`
    Status   *DeploymentStatus `json:"status,omitempty"`

Deployment is Kubernetes deployment

func NewDeployment Uses

func NewDeployment(name, version, typ string) *Deployment

NewService returns default micro kubernetes deployment definition

type DeploymentCondition Uses

type DeploymentCondition struct {
    Type    string `json:"type"`
    Reason  string `json:"reason,omitempty"`
    Message string `json:"message,omitempty"`

DeploymentCondition describes the state of deployment

type DeploymentList Uses

type DeploymentList struct {
    Items []Deployment `json:"items"`


type DeploymentSpec Uses

type DeploymentSpec struct {
    Replicas int            `json:"replicas,omitempty"`
    Selector *LabelSelector `json:"selector"`
    Template *Template      `json:"template,omitempty"`

DeploymentSpec defines micro deployment spec

type DeploymentStatus Uses

type DeploymentStatus struct {
    Replicas            int                   `json:"replicas,omitempty"`
    UpdatedReplicas     int                   `json:"updatedReplicas,omitempty"`
    ReadyReplicas       int                   `json:"readyReplicas,omitempty"`
    AvailableReplicas   int                   `json:"availableReplicas,omitempty"`
    UnavailableReplicas int                   `json:"unavailableReplicas,omitempty"`
    Conditions          []DeploymentCondition `json:"conditions,omitempty"`

DeploymentStatus is returned when querying deployment

type EnvVar Uses

type EnvVar struct {
    Name  string `json:"name"`
    Value string `json:"value,omitempty"`

EnvVar is environment variable

type Event Uses

type Event struct {
    Type   EventType       `json:"type"`
    Object json.RawMessage `json:"object"`

Event represents a single event to a watched resource.

type EventType Uses

type EventType string

EventType defines the possible types of events.

const (
    // EventTypes used
    Added    EventType = "ADDED"
    Modified EventType = "MODIFIED"
    Deleted  EventType = "DELETED"
    Error    EventType = "ERROR"

type LabelSelector Uses

type LabelSelector struct {
    MatchLabels map[string]string `json:"matchLabels,omitempty"`

LabelSelector is a label query over a set of resources NOTE: we do not support MatchExpressions at the moment

type LoadBalancerIngress Uses

type LoadBalancerIngress struct {
    IP       string `json:"ip,omitempty"`
    Hostname string `json:"hostname,omitempty"`

type LoadBalancerStatus Uses

type LoadBalancerStatus struct {
    Ingress []LoadBalancerIngress `json:"ingress,omitempty"`

type LogOption Uses

type LogOption func(*LogOptions)

func LogParams Uses

func LogParams(p map[string]string) LogOption

LogParams provides additional params for logs

type LogOptions Uses

type LogOptions struct {
    Params map[string]string

type Metadata Uses

type Metadata struct {
    Name        string            `json:"name,omitempty"`
    Namespace   string            `json:"namespace,omitempty"`
    Version     string            `json:"version,omitempty"`
    Labels      map[string]string `json:"labels,omitempty"`
    Annotations map[string]string `json:"annotations,omitempty"`

Metadata defines api object metadata

type Pod Uses

type Pod struct {
    Metadata *Metadata  `json:"metadata"`
    Spec     *PodSpec   `json:"spec,omitempty"`
    Status   *PodStatus `json:"status"`

Pod is the top level item for a pod

type PodList Uses

type PodList struct {
    Items []Pod `json:"items"`


type PodSpec Uses

type PodSpec struct {
    Containers []Container `json:"containers"`

PodSpec is a pod

type PodStatus Uses

type PodStatus struct {
    PodIP string `json:"podIP"`
    Phase string `json:"phase"`


type Resource Uses

type Resource struct {
    Name  string
    Kind  string
    Value interface{}

Resource is API resource

type Service Uses

type Service struct {
    Metadata *Metadata      `json:"metadata"`
    Spec     *ServiceSpec   `json:"spec,omitempty"`
    Status   *ServiceStatus `json:"status,omitempty"`

Service is kubernetes service

func NewService Uses

func NewService(name, version, typ string) *Service

NewService returns default micro kubernetes service definition

type ServiceList Uses

type ServiceList struct {
    Items []Service `json:"items"`


type ServicePort Uses

type ServicePort struct {
    Name     string `json:"name,omitempty"`
    Port     int    `json:"port"`
    Protocol string `json:"protocol,omitempty"`

ServicePort configures service ports

type ServiceSpec Uses

type ServiceSpec struct {
    Type     string            `json:"type,omitempty"`
    Selector map[string]string `json:"selector,omitempty"`
    Ports    []ServicePort     `json:"ports,omitempty"`

ServiceSpec provides service configuration

type ServiceStatus Uses

type ServiceStatus struct {
    LoadBalancer LoadBalancerStatus `json:"loadBalancer,omitempty"`


type Template Uses

type Template struct {
    Metadata *Metadata `json:"metadata,omitempty"`
    PodSpec  *PodSpec  `json:"spec,omitempty"`

Template is micro deployment template

type WatchOption Uses

type WatchOption func(*WatchOptions)

func WatchParams Uses

func WatchParams(p map[string]string) WatchOption

WatchParams used for watch params

type WatchOptions Uses

type WatchOptions struct {
    Params map[string]string

type Watcher Uses

type Watcher interface {
    // A channel of events
    Chan() <-chan Event
    // Stop the watcher

Watcher is used to watch for events

Package client imports 18 packages (graph) and is imported by 9 packages. Updated 2020-02-13. Refresh now. Tools for package owners.