How to Install Knative CLI on a Vultr Cloud Server
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:
Deploy a Linux Server on Vultr
Using SSH, access the server
Create a non-root user with sudo privileges
Switch to the new non-root user account
# su - sysadmin
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
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 serverMove the downloaded
kn-linux-amd64
binary file to the/usr/local/bin/
directory and rename it tokn
to enable it as a system wide command$ sudo mv kn-linux-amd64 /usr/local/bin/kn
Enable execution privileges on the
kn
binary file$ sudo chmod +x /usr/local/bin/kn
Switch to your user home directory
$ cd
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
Install the Golang package on your server
Ubuntu/Debian Systems:
$ sudo apt install golang
CentOS/RockyLinux/AlmaLinux/RHEL Systems:
$ sudo dnf install golang
Verify the installed Go version
$ go version
Output:
go version go1.20.3 linux/amd64
Clone the Knative Client repository
$ git clone https://github.com/knative/client.git
Switch to the new
client
directory$ cd client
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
Build a new executable binary file
$ hack/build.sh -f
Output:
🚧 Compile
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/
Switch to your user home directory
$ cd
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
Start a new web browser session, and visit the Knative Client releases page
https://github.com/knative/client/releases/
Click the latest release. For example
v1.11.0
to view the release filesScroll to the Assets section and click to download the
kn-windows-amd64.exe
fileWhen the download process is complete, open a new File Explorer window and navigate to the Downloads folder
Find the
kn-windows-amd64.exe
file, right-click, and select Rename from the listRename the file to
kn
and press Enter to save the new filenameNavigate to the Windows start menu, expand the Windows System group and click Command Prompt to start a new command line session
In the Windows Command prompt window, enter the following command and press Enter to switch to the
C:/
drive directory> cd C:/
Create a new folder
Knative
in theC:/
location> mkdir Knative
Move the downloaded Knative
kn.exe
release file from your Downloads directory to the newKnative
directory> move C:\Users\Administrator\Downloads\kn.exe C:\Knative
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 directoryAdd the
Knative
folder to your Windows system commands path> setx PATH "%PATH%;C:\Knative" /M
Close your Windows Command Prompt and open it again to start a new session
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;
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.
Verify that your Kubectl configuration is connected to a Kubernetes Cluster
$ kubectl get nodes
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).
Create a new Knative Service using a Docker image. Replace
hello-world
with your desired image$ kn service create sample-service --image hello-world
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: