k8s

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: MPL-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Package k8s generated by go-bindata.// sources: resources/config-map.template resources/crd-cluster.json resources/crd-resource.json resources/crd.template resources/generic.template resources/headless-service.template resources/kind-cluster.template resources/kind-resource.template resources/mock-crd.template resources/mock.template resources/pod.template resources/srv-cluster-role-binding.json resources/srv-cluster-role.json resources/srv-deployment.json.template resources/srv-service-account.json resources/volume-claim.template

Index

Constants

View Source
const (
	PodPhasePending   = "Pending"
	PodPhaseRunning   = "Running"
	PodPhaseFailed    = "Failed"
	PodPhaseSucceeded = "Succeeded"
)

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("nonexistent") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func DecodeClusterSpec added in v0.1.3

func DecodeClusterSpec(item *Item) (*any.Any, error)

func DecodeItem added in v0.1.3

func DecodeItem(item *Item) (*any.Any, error)

func DecodeResourceSpec added in v0.1.3

func DecodeResourceSpec(item *Item) (*any.Any, error)

func GetDefaultKubeConfigPath

func GetDefaultKubeConfigPath() (string, error)

GetDefaultKubeConfigPath returns the default location for the kube path

func InCluster

func InCluster() bool

InCluster returns whether we are running inside a Kubernetes pod

func MarshalPod

func MarshalPod(i *proto.Instance) ([]byte, error)

MarshalPod marshals a pod

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func RunTmpl2

func RunTmpl2(name string, obj interface{}) ([]byte, error)

Types

type APIGroup added in v0.1.3

type APIGroup struct {
	Name string
}

type APIGroupList added in v0.1.3

type APIGroupList struct {
	Groups []*APIGroup
}

type APIResource added in v0.1.3

type APIResource struct {
	Name string
}

type APIResourceList added in v0.1.3

type APIResourceList struct {
	Resources []*APIResource
}

type Config

type Config struct {
	Host        string
	TLSConfig   *tls.Config
	BearerToken string
}

Config is the configuration for KubeClient

func GetConfig

func GetConfig() (*Config, error)

func InClusterConfig

func InClusterConfig() (*Config, error)

InClusterConfig returns the auth from inside the pod

type Event added in v0.1.3

type Event struct {
	Metadata  *Metadata
	Reason    string
	Regarding *EventRegarding
	Note      string
	Type      string
}

func (*Event) GetMetadata added in v0.1.3

func (e *Event) GetMetadata() *Metadata

type EventRegarding added in v0.1.3

type EventRegarding struct {
	Kind string
}

type Item

type Item struct {
	Metadata *Metadata
	Kind     string
	Spec     map[string]interface{}
	Data     map[string]interface{}
}

func (*Item) Name added in v0.1.3

func (i *Item) Name() string

func (*Item) ResourceVersion added in v0.1.3

func (i *Item) ResourceVersion() string

type KubeClient

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

KubeClient is a kubernetes client

func NewKubeClient

func NewKubeClient(config *Config) *KubeClient

NewKubeClient creates a new KubeClient

func (*KubeClient) Delete

func (c *KubeClient) Delete(path string, obj []byte) ([]byte, error)

func (*KubeClient) Exec

func (c *KubeClient) Exec(pod, container string, path string, cmdArgs ...string) ([]byte, error)

func (*KubeClient) Get

func (c *KubeClient) Get(path string) ([]byte, error)

func (*KubeClient) GetFull added in v0.1.3

func (c *KubeClient) GetFull(url string, out interface{}) ([]byte, error)

func (*KubeClient) HTTPReq

func (c *KubeClient) HTTPReq(method string, path string, obj []byte) ([]byte, error)

func (*KubeClient) HTTPReqWithResponse

func (c *KubeClient) HTTPReqWithResponse(method string, path string, obj []byte) (*http.Response, error)

HTTPReqWithResponse is a generic method to make http requests that returns the response object

func (*KubeClient) Post

func (c *KubeClient) Post(path string, obj []byte) ([]byte, error)

func (*KubeClient) Put

func (c *KubeClient) Put(path string, obj []byte) ([]byte, error)

func (*KubeClient) Watch added in v0.1.3

func (c *KubeClient) Watch(path string) (*http.Response, error)

type KubeConfig

type KubeConfig struct {
	Host     string
	CertFile string
	KeyFile  string
	CAFile   string
}

KubeConfig is the kubeconfig to connect with the K8s apiserver

func NewKubeConfig

func NewKubeConfig(path string, context string) (*KubeConfig, error)

NewKubeConfig loads the kube config from a given path

func (*KubeConfig) GetTLSConfig

func (k *KubeConfig) GetTLSConfig() (*tls.Config, error)

GetTLSConfig returns the tls.Config for this kubeconfig

func (*KubeConfig) ToConfig

func (k *KubeConfig) ToConfig() (*Config, error)

type Metadata

type Metadata struct {
	Name            string
	ResourceVersion string            `json:"resourceVersion"`
	UID             string            `json:"uid"`
	Labels          map[string]string `json:"labels"`
	Generation      int               `json:"generation"`
	Annotations     map[string]string `json:"annotations"`
	SelfLink        string            `json:"selfLink"`
}

type PodItem added in v0.1.3

type PodItem struct {
	Metadata *Metadata

	Status struct {
		Phase string
		PodIP string

		Conditions []struct {
			Type   string
			Status string
		}
		ContainerStatuses []struct {
			State struct {
				Terminated struct {
					ExitCode int
					Reason   string
					Message  string
				}
				Waiting struct {
					Reason string
				}
				Running struct {
					StartedAt string
				}
			}
		}
	}
}

func (*PodItem) ExitResult added in v0.1.3

func (p *PodItem) ExitResult() (*proto.Instance_ExitResult, error)

func (*PodItem) Name added in v0.1.3

func (i *PodItem) Name() string

func (*PodItem) ResourceVersion added in v0.1.3

func (p *PodItem) ResourceVersion() string

type Provider

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

Provider is a Provider implementation for kubernetes.

func K8sFactory

func K8sFactory(logger hclog.Logger, c map[string]interface{}) (*Provider, error)

func (*Provider) Exec

func (p *Provider) Exec(handler string, path string, cmdArgs ...string) (string, error)

Exec implements the Provider interface

func (*Provider) Name added in v0.1.3

func (p *Provider) Name() string

func (*Provider) Resources added in v0.1.3

func (p *Provider) Resources() operator.ProviderResources

func (*Provider) Setup

func (p *Provider) Setup(cplane operator.ControlPlane) error

func (*Provider) Start

func (p *Provider) Start() error

Start starts the kubernetes provider

func (*Provider) Stop

func (p *Provider) Stop() error

Stop stops the kubernetes provider

type WatchEntry added in v0.1.3

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

type WatchEvent added in v0.1.1

type WatchEvent struct {
	Type   string
	Object interface{}
	Raw    []byte
}

type Watcher added in v0.1.1

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

func NewWatcher added in v0.1.3

func NewWatcher(logger hclog.Logger, client *KubeClient, path string, obj itemObj) (*Watcher, error)

func (*Watcher) ForEach added in v0.1.3

func (w *Watcher) ForEach(handler func(task *WatchEntry, i interface{}))

func (*Watcher) Get added in v0.1.3

func (w *Watcher) Get(path string) (*listResponse, error)

func (*Watcher) IsClosed added in v0.1.3

func (w *Watcher) IsClosed() bool

func (*Watcher) Run added in v0.1.3

func (w *Watcher) Run(stopCh chan struct{})

func (*Watcher) WithLimit added in v0.1.3

func (w *Watcher) WithLimit(l int) *Watcher

func (*Watcher) WithList added in v0.1.3

func (w *Watcher) WithList(list bool) *Watcher

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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