How to Install Knative CLI on a Vultr Cloud Server

Updated on November 12, 2023
How to Install Knative CLI on a Vultr Cloud Server header image

Introduction

Knative CLI (kn) is a terminal based tool that allows you to deploy and manage Knative services in a Kubernetes Cluster without creating YAML files. It offers a user friendly command line interface and uses existing Kubectl configurations to connect to a Kubernetes cluster. Follow the steps in this article to install Knative CLI on a Vultr Cloud Server.

Prerequisites

Before you begin:

Install Knative CLI

To install the Knative CLI tool on your server, you can either use a release binary file or Go. To install the latest version, it's recommended to use the Golang method while the release binary file allows you to implement a specific version on your choice. Depending on your choice, install Knative CLI as described in the steps below.

Install Knative CLI using the Latest Release Binary File

  1. Download the latest Knative CLI latest release file

     $ wget https://github.com/knative/client/releases/download/knative-v1.11.0/kn-linux-amd64

    The above command downloads version v1.11.0, visit the Knative Client releases page to verify the latest version to install on your server

  2. Move the downloaded kn-linux-amd64 binary file to the /usr/local/bin/ directory and rename it to kn to enable it as a system wide command

     $ sudo mv kn-linux-amd64 /usr/local/bin/kn
  3. Enable execution privileges on the kn binary file

     $ sudo chmod +x /usr/local/bin/kn
  4. Switch to your user home directory

     $ cd
  5. Verify the installed Knative CLI version

     $ kn version

    Your output should look like the one below:

     Version:      v20231007-local-807181fb
     Build Date:   2023-10-07 18:06:36
     Git Revision: 807181fb
     Supported APIs:
     * Serving
       - serving.knative.dev/v1 (knative-serving v0.38.1-0.20230921205527-0d73dfe0f295)
     * Eventing
       - sources.knative.dev/v1 (knative-eventing v0.38.1-0.20230921080814-ceecbb01e116)
       - eventing.knative.dev/v1 (knative-eventing v0.38.1-0.20230921080814-ceecbb01e116)

    You have installed the Knative CLI tool using the official binary release file. Run kn --help to view the list of commands you can run using the tool

Install Knative CLI using Go

  1. Install the Golang package on your server

    Ubuntu/Debian Systems:

     $ sudo apt install golang

    CentOS/RockyLinux/AlmaLinux/RHEL Systems:

     $ sudo dnf install golang
  2. Verify the installed Go version

     $ go version

    Output:

     go version go1.20.3 linux/amd64
  3. Clone the Knative Client repository

     $ git clone https://github.com/knative/client.git
  4. Switch to the new client directory

     $ cd client
  5. List files and verify that Knative files are available in the directory

     $ ls

    Output:

     CHANGELOG.adoc  CODE-OF-CONDUCT.md  CONTRIBUTING.md  DEVELOPMENT.md  go.mod  hack  LICENSE  OWNERS_ALIASES  README.md  third_party  vendor
     cmd             config              conventions      docs            go.sum  lib   OWNERS   pkg             test       tools
  6. Build a new executable binary file

     $ hack/build.sh -f

    Output:

     šŸš§ Compile
  7. A new kn binary file is added to your directory. Move the file to your system path /usr/local/bin/ to activate it as a system-wide command

     $ sudo mv kn /usr/local/bin/
  8. Switch to your user home directory

     $ cd
  9. Verify the installed Knative CLI version

     $ kn version

    Your output should look like the one below:

     Version:      v20231007-local-807181fb
     Build Date:   2023-10-07 18:06:36
     Git Revision: 807181fb
     Supported APIs:
     * Serving
       - serving.knative.dev/v1 (knative-serving v0.38.1-0.20230921205527-0d73dfe0f295)
     * Eventing
       - sources.knative.dev/v1 (knative-eventing v0.38.1-0.20230921080814-ceecbb01e116)
       - eventing.knative.dev/v1 (knative-eventing v0.38.1-0.20230921080814-ceecbb01e116)

Install Knative CLI on a Vultr Windows Server

To install the Knative CLI tool on a windows server instead of a Linux server, download the latest release file and install it on your system as described in the steps below.

  • Deploy a Windows Server on Vultr
  • Using RDP, access the server as an administrative user
  1. Start a new web browser session, and visit the Knative Client releases page

     https://github.com/knative/client/releases/
  2. Click the latest release. For example v1.11.0 to view the release files

  3. Scroll to the Assets section and click to download the kn-windows-amd64.exe file

    Download the latest Knative CLI Windows Release File

  4. When the download process is complete, open a new File Explorer window and navigate to the Downloads folder

  5. Find the kn-windows-amd64.exe file, right-click, and select Rename from the list

    Rename the Knative CLI download file on Windows

  6. Rename the file to kn and press Enter to save the new filename

  7. Navigate to the Windows start menu, expand the Windows System group and click Command Prompt to start a new command line session

  8. In the Windows Command prompt window, enter the following command and press Enter to switch to the C:/ drive directory

     > cd C:/
  9. Create a new folder Knative in the C:/ location

     > mkdir Knative
  10. Move the downloaded Knative kn.exe release file from your Downloads directory to the new Knative directory

    > move C:\Users\Administrator\Downloads\kn.exe C:\Knative
  11. View files in the Knative directory

    > dir

    Output:

    Directory of C:\Knative
    
    10/07/2023  06:57 PM    <DIR>          .
    10/07/2023  06:29 PM        72,081,920 kn.exe
                   1 File(s)     72,081,920 bytes
                   1 Dir(s)  55,225,864,192 bytes free

    Verify that the kn.exe file is available in the directory

  12. Add the Knative folder to your Windows system commands path

    > setx PATH "%PATH%;C:\Knative" /M
  13. Close your Windows Command Prompt and open it again to start a new session

  14. View the system paths and verify that the Knative directory is available on the list

    > PATH

    Your output should look like the one below:

    C:\Knative; C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;
  15. Run the kn command and verify the installed Knative CLI version

    > kn version

    Output:

    Version:      v20231007-local-807181fb
    Build Date:   2023-10-07 18:06:36
    Git Revision: 807181fb
    Supported APIs:
    * Serving
      - serving.knative.dev/v1 (knative-serving v0.38.1-0.20230921205527-0d73dfe0f295)
    * Eventing
      - sources.knative.dev/v1 (knative-eventing v0.38.1-0.20230921080814-ceecbb01e116)
      - eventing.knative.dev/v1 (knative-eventing v0.38.1-0.20230921080814-ceecbb01e116)

You have installed the Knative CLI tool on your Windows Server. You can use the tool in any directory within your Windows command prompt session. To view a list of available commands, add the --help option to the kn command

Test the Knative CLI Tool

To verify that the Knative CLI tool is working correctly on your server, view the list of available commands and create a new service as described below.

  1. Verify that your Kubectl configuration is connected to a Kubernetes Cluster

     $ kubectl get nodes
  2. View the list of available Knative CLI commands

     $ kn --help

    Output:

     Serving Commands:
     service      Manage Knative services
     revision     Manage service revisions
     route        List and describe service routes
     domain       Manage domain mappings
     container    Manage service's containers (experimental)
    
     Eventing Commands:
     source       Manage event sources
     broker       Manage message brokers
     trigger      Manage event triggers
     channel      Manage event channels
     subscription Manage event subscriptions
     eventtype    Manage eventtypes
    
     Other Commands:
     plugin       Manage kn plugins
     secret       Manage secrets
     completion   Output shell completion code
     version      Show the version of this client
    
    
     Use "kn <command> --help" for more information about a given command.
     Use "kn options" for a list of global command-line options (applies to all commands).
  3. Create a new Knative Service using a Docker image. Replace hello-world with your desired image

     $ kn service create sample-service --image hello-world
  4. Describe the service to view detailed information on its status

     $ kn service describe sample-service

Conclusion

You have installed the Knative CLI tool on a Vultr Cloud Server. When deployed on your server, the tool uses your Kubectl configurations to connect to your cluster and create serverless applications. For mroe information about Knative CLI, visit the official documentation page.

Next Steps

To implement more Knative solutions, visit the following resources: