kubectl

package
v0.0.0-...-2bcb20d Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Namespace = "kube-system"
	JobName   = "kubectl"
)

Variables

This section is empty.

Functions

func Command

func Command(client *rancher.Client, yamlContent *management.ImportClusterYamlInput, clusterID string, command []string, logBufferSize string) (string, error)

Command executes a given command on a Kubernetes pod within a specified cluster using the Rancher Management API and kubectl. It optionally sets up an init container to populate a configuration file if yamlContent is provided. The function returns the job's logs upon completion. The clusterID identifies the target cluster, and command specifies the command to execute, which must not be empty. The logBufferSize defines the size for log output buffering (e.g., "64KB", "8MB", "1GB"); if empty, the default size is used. An invalid logBufferSize format returns an error. The function returns "StatusOK" and the execution logs if successful, or an error detailing the failure.

Parameters: - client: Pointer to a rancher.Client used to interact with the Rancher Management API. - yamlContent: Optional *management.ImportClusterYamlInput to set up an init container for configuration. If nil, no init container is set up. - clusterID: String identifying the target cluster. - command: Slice of strings representing the command to execute. Must not be empty. - logBufferSize: String representing the log buffer size (e.g., "64KB"). If empty, defaults to the system default size.

Returns: - A string containing the logs of the executed job. - An error if the command is empty, if there is an issue with setting up the job, or if log retrieval fails.

func CreateJobAndRunKubectlCommands

func CreateJobAndRunKubectlCommands(clusterID, jobname string, job *batchv1.Job, client *rancher.Client) error

CreateJobAndRunKubectlCommands is a helper to create a job and run the kubectl commands in the pods of the Job. It then returns errors or nil from the job.

Types

This section is empty.

Jump to

Keyboard shortcuts

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