call_kubectl {AzureContainers} | R Documentation |
Call the Kubernetes commandline tool, kubectl
Description
Call the Kubernetes commandline tool, kubectl
Usage
call_kubectl(cmd = "", config = NULL, ...,
echo = getOption("azure_containers_tool_echo", TRUE))
Arguments
cmd |
The kubectl command line to execute. This should be a vector of individual kubectl arguments, but can also be a single commandline string. See below. |
config |
The pathname of the cluster config file, if required. |
... |
Other arguments to pass to processx::run. |
echo |
Whether to echo the output of the command to the console. |
Details
This function calls the kubectl
binary, which must be located in your search path. AzureContainers will search for the binary at package startup, and print a warning if it is not found.
The kubectl command should be specified as a vector of the individual arguments, which is what processx::run
expects. If a single string is passed, for convenience and back-compatibility reasons call_docker_compose
will split it into arguments for you. This is prone to error, for example if you are working with pathnames that contain spaces, so it's strongly recommended to pass a vector of arguments as a general practice.
Value
A list with the following components:
-
status
: The exit status of the kubectl tool. If this isNA
, then the process was killed and had no exit status. -
stdout
: The standard output of the command, in a character scalar. -
stderr
: The standard error of the command, in a character scalar. -
timeout
: Whether the process was killed because of a timeout. -
cmdline
: The command line.
The first four components are from processx::run
; AzureContainers adds the last to make it easier to construct scripts that can be run outside R.
See Also
processx::run, call_docker, call_helm
Kubectl command line reference
Examples
## Not run:
# without any args, prints the kubectl help screen
call_kubectl()
# append "--help" to get help for a command
call_kubectl(c("create", "--help"))
# deploy a service from a yaml file
call_kubectl(c("create", "-f", "deployment.yaml"))
# get deployment and service status
call_kubectl(c("get", "deployment"))
call_kubectl(c("get", "service"))
## End(Not run)