Documentation
¶
Overview ¶
Package kubectl provides a kubectl client implementation.
This package wraps kubectl command functionality and provides client methods for executing kubectl operations programmatically, including apply, create, delete, get, describe, and other standard kubectl commands.
Index ¶
- Variables
- func ExecuteSafely(ctx context.Context, cmd *cobra.Command) error
- type Client
- func (c *Client) CreateApplyCommand(kubeConfigPath string) *cobra.Command
- func (c *Client) CreateClusterInfoCommand(kubeConfigPath string) *cobra.Command
- func (c *Client) CreateClusterRoleBindingCmd() (*cobra.Command, error)
- func (c *Client) CreateClusterRoleCmd() (*cobra.Command, error)
- func (c *Client) CreateConfigMapCmd() (*cobra.Command, error)
- func (c *Client) CreateCreateCommand(kubeConfigPath string) *cobra.Command
- func (c *Client) CreateCronJobCmd() (*cobra.Command, error)
- func (c *Client) CreateDeleteCommand(kubeConfigPath string) *cobra.Command
- func (c *Client) CreateDeploymentCmd() (*cobra.Command, error)
- func (c *Client) CreateDescribeCommand(kubeConfigPath string) *cobra.Command
- func (c *Client) CreateEditCommand(kubeConfigPath string) *cobra.Command
- func (c *Client) CreateExecCommand(kubeConfigPath string) *cobra.Command
- func (c *Client) CreateExplainCommand(kubeConfigPath string) *cobra.Command
- func (c *Client) CreateExposeCommand(kubeConfigPath string) *cobra.Command
- func (c *Client) CreateGetCommand(kubeConfigPath string) *cobra.Command
- func (c *Client) CreateIngressCmd() (*cobra.Command, error)
- func (c *Client) CreateJobCmd() (*cobra.Command, error)
- func (c *Client) CreateLogsCommand(kubeConfigPath string) *cobra.Command
- func (c *Client) CreateNamespaceCmd() (*cobra.Command, error)
- func (c *Client) CreatePodDisruptionBudgetCmd() (*cobra.Command, error)
- func (c *Client) CreatePriorityClassCmd() (*cobra.Command, error)
- func (c *Client) CreateQuotaCmd() (*cobra.Command, error)
- func (c *Client) CreateRoleBindingCmd() (*cobra.Command, error)
- func (c *Client) CreateRoleCmd() (*cobra.Command, error)
- func (c *Client) CreateRolloutCommand(kubeConfigPath string) *cobra.Command
- func (c *Client) CreateScaleCommand(kubeConfigPath string) *cobra.Command
- func (c *Client) CreateSecretCmd() (*cobra.Command, error)
- func (c *Client) CreateServiceAccountCmd() (*cobra.Command, error)
- func (c *Client) CreateServiceCmd() (*cobra.Command, error)
- func (c *Client) CreateWaitCommand(kubeConfigPath string) *cobra.Command
Constants ¶
This section is empty.
Variables ¶
var ( // ErrResourceCommandNotFound is returned when a kubectl create subcommand is not found. ErrResourceCommandNotFound = errors.New("kubectl create command not found for resource type") // ErrNoRunFunction is returned when a kubectl command has neither RunE nor Run function. ErrNoRunFunction = errors.New("no run function found for kubectl create command") )
Functions ¶
func ExecuteSafely ¶ added in v5.89.3
ExecuteSafely runs a kubectl cobra command without allowing os.Exit.
kubectl commands use cmdutil.CheckErr in their Run handlers, which calls os.Exit(1) on any error. This function overrides that behavior using cmdutil.BehaviorOnFatal so errors are returned instead of terminating the process. This is essential when KSail calls kubectl commands internally (backup, restore, watch) and needs to handle errors gracefully.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps kubectl command functionality.
func NewClient ¶
func NewClient(streams genericiooptions.IOStreams) *Client
NewClient creates a new kubectl client instance.
func NewClientWithStdio ¶
func NewClientWithStdio() *Client
NewClientWithStdio returns a kubectl client wired to the default stdio streams.
func (*Client) CreateApplyCommand ¶
CreateApplyCommand creates a kubectl apply command with all its flags and behavior.
func (*Client) CreateClusterInfoCommand ¶
CreateClusterInfoCommand wires kubectl's cluster-info with minimal guarding.
func (*Client) CreateClusterRoleBindingCmd ¶
CreateClusterRoleBindingCmd creates a ClusterRoleBinding manifest generator command using the client's IO streams.
func (*Client) CreateClusterRoleCmd ¶
CreateClusterRoleCmd creates a ClusterRole manifest generator command using the client's IO streams.
func (*Client) CreateConfigMapCmd ¶
CreateConfigMapCmd creates a ConfigMap manifest generator command using the client's IO streams.
func (*Client) CreateCreateCommand ¶
CreateCreateCommand creates a kubectl create command with all its flags and behavior.
func (*Client) CreateCronJobCmd ¶
CreateCronJobCmd creates a CronJob manifest generator command using the client's IO streams.
func (*Client) CreateDeleteCommand ¶
CreateDeleteCommand creates a kubectl delete command with all its flags and behavior.
func (*Client) CreateDeploymentCmd ¶
CreateDeploymentCmd creates a Deployment manifest generator command using the client's IO streams.
func (*Client) CreateDescribeCommand ¶
CreateDescribeCommand creates a kubectl describe command with all its flags and behavior.
func (*Client) CreateEditCommand ¶
CreateEditCommand creates a kubectl edit command with all its flags and behavior.
func (*Client) CreateExecCommand ¶
CreateExecCommand creates a kubectl exec command with all its flags and behavior.
func (*Client) CreateExplainCommand ¶
CreateExplainCommand creates a kubectl explain command with all its flags and behavior.
func (*Client) CreateExposeCommand ¶
CreateExposeCommand creates a kubectl expose command with all its flags and behavior.
func (*Client) CreateGetCommand ¶
CreateGetCommand creates a kubectl get command with all its flags and behavior.
func (*Client) CreateIngressCmd ¶
CreateIngressCmd creates an Ingress manifest generator command using the client's IO streams.
func (*Client) CreateJobCmd ¶
CreateJobCmd creates a Job manifest generator command using the client's IO streams.
func (*Client) CreateLogsCommand ¶
CreateLogsCommand creates a kubectl logs command with all its flags and behavior.
func (*Client) CreateNamespaceCmd ¶
CreateNamespaceCmd creates a Namespace manifest generator command using the client's IO streams.
func (*Client) CreatePodDisruptionBudgetCmd ¶
CreatePodDisruptionBudgetCmd creates a PodDisruptionBudget manifest generator command using the client's IO streams.
func (*Client) CreatePriorityClassCmd ¶
CreatePriorityClassCmd creates a PriorityClass manifest generator command using the client's IO streams.
func (*Client) CreateQuotaCmd ¶
CreateQuotaCmd creates a ResourceQuota manifest generator command using the client's IO streams.
func (*Client) CreateRoleBindingCmd ¶
CreateRoleBindingCmd creates a RoleBinding manifest generator command using the client's IO streams.
func (*Client) CreateRoleCmd ¶
CreateRoleCmd creates a Role manifest generator command using the client's IO streams.
func (*Client) CreateRolloutCommand ¶
CreateRolloutCommand creates a kubectl rollout command with all its flags and behavior.
func (*Client) CreateScaleCommand ¶
CreateScaleCommand creates a kubectl scale command with all its flags and behavior.
func (*Client) CreateSecretCmd ¶
CreateSecretCmd creates a Secret manifest generator command using the client's IO streams.
func (*Client) CreateServiceAccountCmd ¶
CreateServiceAccountCmd creates a ServiceAccount manifest generator command using the client's IO streams.
func (*Client) CreateServiceCmd ¶
CreateServiceCmd creates a Service manifest generator command using the client's IO streams.