client

package
v0.0.0-...-7c77b90 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultValidation = false

DefaultValidation default action to validate. If `true` all resources by default will be validated.

Variables

View Source
var (
	// ErrLoggerInternal is returned when an error occurs due to the logger
	ErrLoggerInternal = errors.New("internal logger error")
)

Functions

func PopulateResourceListV1WithDefValues

func PopulateResourceListV1WithDefValues(spec string) (v1.ResourceList, error)

PopulateResourceListV1WithDefValues takes strings of form <resourceName1>=<value1>,<resourceName1>=<value2> and returns ResourceList.

Types

type BuilderOptions

type BuilderOptions struct {
	Unstructured  bool
	Validate      bool
	Namespace     string
	LabelSelector string
	FieldSelector string
	All           bool
	AllNamespaces bool
}

BuilderOptions parameters to create a Resource Builder

func NewBuilderOptions

func NewBuilderOptions() *BuilderOptions

NewBuilderOptions creates a BuilderOptions with the default values for the parameters to create a Resource Builder

type Client

type Client struct {
	Clientset     kubernetes.Interface
	DynamicClient dynamic.Interface
	RestMapper    meta.RESTMapper

	ServerSideApply bool
	// contains filtered or unexported fields
}

Client is a kubernetes client, like `kubectl`

func New

func New(context, kubeconfig string, namespace string) *Client

New creates a kubernetes client

func NewE

func NewE(context, kubeconfig string, ns string) (*Client, error)

NewE creates a kubernetes client, returns an error if fail

func NewKubeFakeClient

func NewKubeFakeClient() (*Client, error)

NewKubeFakeClient returns a fake kube client object

func (*Client) Apply

func (c *Client) Apply(content []byte) error

Apply creates a resource with the given content

func (*Client) ApplyFiles

func (c *Client) ApplyFiles(filenames ...string) error

ApplyFiles create the resource(s) from the given filenames (file, directory or STDIN) or HTTP URLs

func (*Client) ApplyResource

func (c *Client) ApplyResource(r *resource.Result) error

ApplyResource applies the given resource. Create the resources with `ResultForFilenameParam` or `ResultForContent`

func (*Client) Approve

func (c *Client) Approve(name string, sa []byte) error

func (*Client) Create

func (c *Client) Create(content []byte) error

Create creates a resource with the given content

func (*Client) CreateFile

func (c *Client) CreateFile(filenames ...string) error

CreateFile creates a resource with the given content

func (*Client) CreateNamespace

func (c *Client) CreateNamespace(namespace string) error

CreateNamespace creates a namespace with the given name

func (*Client) CreateResource

func (c *Client) CreateResource(r *resource.Result) error

CreateResource creates the given resource. Create the resources with `ResultForFilenameParam` or `ResultForContent`

func (*Client) Delete

func (c *Client) Delete(content []byte) error

Delete creates a resource with the given content

func (*Client) DeleteFiles

func (c *Client) DeleteFiles(filenames ...string) error

DeleteFiles create the resource(s) from the given filenames (file, directory or STDIN) or HTTP URLs

func (*Client) DeleteNamespace

func (c *Client) DeleteNamespace(namespace string) error

DeleteNamespace deletes the namespace with the given name

func (*Client) DeleteResource

func (c *Client) DeleteResource(r *resource.Result) error

DeleteResource applies the given resource. Create the resources with `ResultForFilenameParam` or `ResultForContent`

func (*Client) Get

func (c *Client) Get(gvkRes []byte, namespace string) ([]byte, error)

Get gets the resource from the remote cluster

func (*Client) GetAvailableNodeResources

func (c *Client) GetAvailableNodeResources(ctx context.Context, resName string) (int64, int64, map[string]int64, error)

GetAvailableNodeResources returns the Resource available in the cluster(after dedecting running pods resource requirements)

func (*Client) GetClusterNodes

func (c *Client) GetClusterNodes(ctx context.Context) (*corev1.NodeList, error)

GetClusterNodes lists all the nodes deployed on the cluster

func (*Client) GetMasterNodeIP

func (c *Client) GetMasterNodeIP() (nodeIP string, err error)

GetMasterNodeIP returns the master node IP of the deployed app

func (*Client) GetNodeLabels

func (c *Client) GetNodeLabels(ctx context.Context) (map[string](map[string]string), error)

GetNodeLabels .. Fetch labels published by the K8s node

func (*Client) GetPodList

func (c *Client) GetPodList(ctx context.Context, nodeName string) (*corev1.PodList, error)

GetPodList lists all the pods deployed on the node

func (*Client) GetPodsTotalRequestsAndLimits

func (c *Client) GetPodsTotalRequestsAndLimits(ctx context.Context, podList *corev1.PodList) (map[corev1.ResourceName]resource.Quantity, map[corev1.ResourceName]resource.Quantity, error)

GetPodsTotalRequestsAndLimits ... Get resource total requests/limits (including running instances)

func (*Client) IsReachable

func (c *Client) IsReachable() error

IsReachable tests connectivity to the cluster

func (*Client) NodesReady

func (c *Client) NodesReady() (ready int, total int, err error)

NodesReady returns the number of nodes ready

func (*Client) Replace

func (c *Client) Replace(content []byte) error

Replace creates a resource with the given content

func (*Client) ReplaceFiles

func (c *Client) ReplaceFiles(filenames ...string) error

ReplaceFiles create the resource(s) from the given filenames (file, directory or STDIN) or HTTP URLs

func (*Client) ReplaceResource

func (c *Client) ReplaceResource(r *resource.Result) error

ReplaceResource applies the given resource. Create the resources with `ResultForFilenameParam` or `ResultForContent`

func (*Client) ResultForContent

func (c *Client) ResultForContent(content []byte, opt *BuilderOptions) *Result

ResultForContent returns the builder results for the given content

func (*Client) ResultForFilenameParam

func (c *Client) ResultForFilenameParam(filenames []string, opt *BuilderOptions) *Result

ResultForFilenameParam returns the builder results for the given list of files or URLs

func (*Client) ResultForReader

func (c *Client) ResultForReader(r io.Reader, opt *BuilderOptions) *Result

ResultForReader returns the builder results for the given reader

func (*Client) TagResource

func (c *Client) TagResource(res []byte, label string) ([]byte, error)

TagResource with label

func (*Client) Version

func (c *Client) Version() (string, error)

Version returns the cluster version. It can be used to verify if the cluster is reachable. It will return an error if failed to connect.

type ReadResource

type ReadResource struct {
	Gvk       schema.GroupVersionKind `json:"GVK,omitempty"`
	Name      string                  `json:"name,omitempty"`
	Namespace string                  `json:"namespace,omitempty"`
}

ReadResource is structure used for reading resource

type Result

type Result = resource.Result

Result is an alias for the Kubernetes CLI runtime resource.Result

Jump to

Keyboard shortcuts

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