This topic describes how to run, version control, and configure the Vela CLI on Docker. For more information on how to use Docker, see Docker's documentation.
Official Docker images provide isolation, portability, and security that KubeVela Community directly supports and maintains. This enables you to use the KubeVela CLI in a container-based environment without having to manage the installation yourself.
You must have Docker installed. For installation instructions, see the Docker website.
To verify your installation of Docker, run the following command and confirm there is an output.
The official KubeVela CLI Docker image is hosted on DockerHub in the
oamdev/vela-cli repository. The first time you use the docker run command, the latest Docker image is downloaded to your computer. Each subsequent use of the docker run command runs from your local copy.
To run the KubeVela CLI Docker image, use the
docker run command.
This is how the command functions:
docker run --rm -it -v ~/.kube:/root/.kube oamdev/vela-cli– The equivalent of the
velaexecutable. Each time you run this command, Docker spins up a container of your downloaded
oamdev/vela-cliimage, and executes your
velacommand. By default, the Docker image uses the latest version of the KubeVela CLI.
For example, to call the
vela versioncommand in Docker, you run the following.$ docker run --rm -it -v ~/.kube:/root/.kube oamdev/vela-cli versionCLI Version: masterCore Version:GitRevision: git-1d823780GolangVersion: go1.17.10
--rm– Specifies to clean up the container after the command exits.
-it– Specifies to open a pseudo-TTY with stdin. This enables you to provide input to the KubeVela CLI while it's running in a container, for example, by using the
-v ~/.kube:/root/.kube- Specifies the kube config in your environment and mount it into the container. Vela CLI requires a Kubernetes environment for running.
For more information about the docker run command, see the Docker reference guide.
To shorten the Docker
vela command, we suggest you use your operating system's ability to create a symbolic link (symlink) or alias in Linux and macOS, or doskey in Windows. To set the
vela alias, you can run one of the following commands.
After setting your alias, you can run the Vela CLI from within a Docker container as if it's installed on your host system.
With the help of vela CLI image, you can integrate with Kubernetes API. For example, we can use Kubernetes Job for installing addon:
There're some prerequisites:
- the service account should have enough privileges to access addon and install it, the easiest way is to use the same one with the vela-core just like the example.
- the namespace should align with your service account.
You can change the args to install other addons or execute other commands, they share the same mechanism.
The work flow could like below:
- Apply the above yaml file:
- Check pods the job is running:
- Check the logs: