Vela CLI Docker Image

    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 .

    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 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.

    1. docker run --rm -it -v ~/.kube:/root/.kube oamdev/vela-cli <command>
    • docker run --rm -it -v ~/.kube:/root/.kube oamdev/vela-cli – The equivalent of the vela executable. Each time you run this command, Docker spins up a container of your downloaded oamdev/vela-cli image, and executes your vela command. By default, the Docker image uses the latest version of the KubeVela CLI.

      For example, to call the vela version command in Docker, you run the following.

      1. $ docker run --rm -it -v ~/.kube:/root/.kube oamdev/vela-cli version
      2. CLI Version: master
      3. Core Version:
      4. GitRevision: git-1d823780
      5. GolangVersion: 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 vela port-forward commands.

    • -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.

    To shorten the Docker vela command, we suggest you use your operating system’s ability to create a symbolic link (symlink) or 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.

    1. $ vela version

    With the help of vela CLI image, you can integrate with Kubernetes API. For example, we can use Kubernetes Job for installing addon:

    1. apiVersion: batch/v1
    2. kind: Job
    3. metadata:
    4. name: install-addon
    5. labels:
    6. app: vela-cli
    7. spec:
    8. ttlSecondsAfterFinished: 0
    9. template:
    10. metadata:
    11. name: install-addon
    12. labels:
    13. app: vela-cli
    14. spec:
    15. containers:
    16. - name: install
    17. image: oamdev/vela-cli:latest
    18. imagePullPolicy: IfNotPresent
    19. - addon
    20. - enable
    21. - velaux
    22. serviceAccountName: kubevela-vela-core

    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.

    1. Apply the above yaml file:
    1. Check pods the job is running:
    1. $ kubectl get pods -n vela-system -l app=vela-cli
    2. NAMESPACE NAME READY STATUS RESTARTS AGE
    3. vela-system install-addon-zg6lx 1/1 Running 0 4s
    1. Check the logs:
    1. $ kubectl -n vela-system logs -f install-addon-zg6lx
    2. I0525 05:47:25.788947 1 apply.go:107] "creating object" name="component-uischema-task" resource="/v1, Kind=ConfigMap"
    3. ...snip...
    4. To check the initialized admin user name and password by:
    5. vela logs -n vela-system --name apiserver addon-velaux | grep "initialized admin username"
    6. To open the dashboard directly by port-forward:
    7. vela port-forward -n vela-system addon-velaux 9082:80
    8. Select "Cluster: local | Namespace: vela-system | Kind: Service | Name: velaux" from the prompt.