k8s

package
v1.26.9 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: Apache-2.0 Imports: 15 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 {
	Clientset         *kubernetes.Clientset
	Config            *rest.Config
	ServerVersionInfo *version.Info
}

Client is a simple k8s api client for testing purposes.

func NewClient

func NewClient(context string) (*Client, error)

NewClient returns a k8s api client.

func (Client) ClusterRole

func (c Client) ClusterRole(name string) (*rbacv1.ClusterRole, error)

ClusterRole finds a clusterrole with the given name

func (Client) ClusterRoleBinding

func (c Client) ClusterRoleBinding(name string) (*rbacv1.ClusterRoleBinding, error)

ClusterRoleBinding finds a clusterrolebinding with the given name

func (Client) CreateClusterRoleBinding

func (c Client) CreateClusterRoleBinding(name string, sa *v1.ServiceAccount, cr *rbacv1.ClusterRole) (*rbacv1.ClusterRoleBinding, error)

CreateClusterRoleBinding creates a clusterrolebinding with the given name and links it with the serviceaccount

func (Client) CreateServiceAccount

func (c Client) CreateServiceAccount(namespace, name string) (*v1.ServiceAccount, error)

CreateServiceAccount creates a serviceaccount into the namespace a service account with the given name

func (Client) NodesList

func (c Client) NodesList() (*v1.NodeList, error)

NodesList list nodes.

func (Client) PodExec

func (c Client) PodExec(namespace, podName, containerName string, command ...string) (ReqOutput, error)

PodExec executes a command on a pod container.

func (Client) PodsListByLabels

func (c Client) PodsListByLabels(namespace string, labels []string) (*v1.PodList, error)

PodsListByLabels list pods filtered by labels.

func (Client) ServerVersion

func (c Client) ServerVersion() string

ServerVersion returns the k8s server version.

func (Client) ServiceAccount

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

ServiceAccount finds a serviceaccount into the namespace a service account with the given name

type ReqOutput

type ReqOutput struct {
	Stdout bytes.Buffer
	Stderr bytes.Buffer
}

ReqOutput is the output of a request made to k8s api.

Jump to

Keyboard shortcuts

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