k8sapi

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Podname   string
	Namespace string
	CACert    []byte
	Token     string

	HttpClient *http.Client
	// contains filtered or unexported fields
}

Client minimal client for the kubernetes API

func NewClient

func NewClient() (*Client, error)

NewClient create new api client

func (*Client) SetCurrentPodLabel

func (c *Client) SetCurrentPodLabel(ctx context.Context, label, value string) error

SetCurrentPodLabel set the label for the current pod in the current namespace (requires patch on pods resource)

func (*Client) SetPodLabel

func (c *Client) SetPodLabel(ctx context.Context, namespace, podname, label, value string) error

SetPodLabel sets the label and value for the pod of the given namespace (requires patch on pods resource in the given namespace)

func (*Client) SimpleRequest

func (c *Client) SimpleRequest(ctx context.Context, method, url string, requestObj, responseObj interface{}) error

SimpleRequest send a simple http request to kubernetes with the passed method, url and requestObj, decoding the result into responseObj

type Config

type Config struct {
	Host          string `env:"KUBERNETES_SERVICE_HOST" envDefault:"localhost"`
	Port          int    `env:"KUBERNETES_PORT_443_TCP_PORT" envDefault:"433"`
	NamespaceFile string `env:"KUBERNETES_NAMESPACE_FILE" envDefault:"/run/secrets/kubernetes.io/serviceaccount/namespace"`
	CACertFile    string `env:"KUBERNETES_API_CA_FILE" envDefault:"/run/secrets/kubernetes.io/serviceaccount/ca.crt"`
	TokenFile     string `env:"KUBERNETES_API_TOKEN_FILE" envDefault:"/run/secrets/kubernetes.io/serviceaccount/token"`
}

Config gathers the required kubernetes system configuration to use the kubernetes API

Jump to

Keyboard shortcuts

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