kube

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIClient = NewClient(Config{})

Functions

func Annotations

func Annotations() map[string]string

Annotations stores the meta data of the pod and other important information "leaseLockName": the name of the lease lock resource "leaseLockNamespace": the namespace of the lease lock resource "region": the region of the pod

func GetNodeName

func GetNodeName() string

func GetPodID

func GetPodID() string

func GetPodName

func GetPodName() string

func GetPodNamespace

func GetPodNamespace() string

func Labels

func Labels() map[string]string

func LocalIP

func LocalIP() (ip string)

func Map2Json

func Map2Json(m map[string]string) string

Map2Json

 m := map[string]string{
		"app": "redis-t",
	} -> `{"app":"redis-t"}`

func Map2Str

func Map2Str(m map[string]string) string

Map2Str

 m := map[string]string{
		"app": "redis-t",
	} -> "app=redis-t"

func Runtime

func Runtime() map[string]string

func SimplifyService

func SimplifyService(service *v1.Service) *v1.Service

SimplifyService returns a simplified service.

Types

type Client

type Client struct {
	KubeConfig string

	KubeClient *clientset.Clientset
}

func NewClient

func NewClient(cfg Config) *Client

func NewClientWithClients

func NewClientWithClients(client *clientset.Clientset) *Client

NewClientWithClients TODO: consider using a clientset if already have a clientset instance

func (*Client) CreateIfNotExistService

func (c *Client) CreateIfNotExistService(namespace string, service *v1.Service) error

func (*Client) GetPod

func (c *Client) GetPod(namespace, name string) (*v1.Pod, error)

func (*Client) GetPodLabels

func (c *Client) GetPodLabels(namespace, name string) (map[string]string, error)

func (*Client) GetPodsByFieldSelector

func (c *Client) GetPodsByFieldSelector(namespace string, fieldSelector map[string]string) ([]v1.Pod, error)

func (*Client) GetPodsBySelector

func (c *Client) GetPodsBySelector(namespace string, selector map[string]string) ([]v1.Pod, error)

func (*Client) GetPodsIPsBySelector

func (c *Client) GetPodsIPsBySelector(namespace string, selector map[string]string) ([]string, error)

func (*Client) GetService

func (c *Client) GetService(namespace, name string) (*v1.Service, error)

func (*Client) GetServiceLabels

func (c *Client) GetServiceLabels(namespace, name string) (map[string]string, error)

GetServiceLabels returns labels of a kubernetes service.

func (*Client) GetServiceSelector

func (c *Client) GetServiceSelector(namespace, name string) (map[string]string, error)

GetServiceSelector returns selector of a kubernetes service.

func (*Client) PatchPodLabels

func (c *Client) PatchPodLabels(namespace, name string, label map[string]string) error

func (*Client) PatchServiceLabels

func (c *Client) PatchServiceLabels(namespace, name string, labels map[string]string) error

PatchServiceLabels by default uses strategic merge patch. if label k v does ont exist, it will add. if k v exist, it will update.

func (*Client) PatchServiceSelector

func (c *Client) PatchServiceSelector(namespace, name string, selector map[string]string) error

PatchServiceSelector by default uses MergePatchType patch.

type Config

type Config struct {
	KubeConfig string `json:"kubeconfig"`
}

func (*Config) String

func (c *Config) String() string

String is used to print the config, for debugging.

Jump to

Keyboard shortcuts

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