
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-amd64The 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-amd64binary file to the/usr/local/bin/directory and rename it toknto enable it as a system wide command$ sudo mv kn-linux-amd64 /usr/local/bin/knEnable execution privileges on the
knbinary file$ sudo chmod +x /usr/local/bin/knSwitch to your user home directory
$ cdVerify the installed Knative CLI version
$ kn versionYour 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 --helpto 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 golangCentOS/RockyLinux/AlmaLinux/RHEL Systems:
$ sudo dnf install golangVerify the installed Go version
$ go versionOutput:
go version go1.20.3 linux/amd64Clone the Knative Client repository
$ git clone https://github.com/knative/client.gitSwitch to the new
clientdirectory$ cd clientList files and verify that Knative files are available in the directory
$ lsOutput:
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 toolsBuild a new executable binary file
$ hack/build.sh -fOutput:
đźš§ CompileA new
knbinary 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
$ cdVerify the installed Knative CLI version
$ kn versionYour 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.0to view the release filesScroll to the Assets section and click to download the
kn-windows-amd64.exefile
When the download process is complete, open a new File Explorer window and navigate to the Downloads folder
Find the
kn-windows-amd64.exefile, right-click, and select Rename from the list
Rename the file to
knand 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
Knativein theC:/location> mkdir KnativeMove the downloaded Knative
kn.exerelease file from your Downloads directory to the newKnativedirectory> move C:\Users\Administrator\Downloads\kn.exe C:\KnativeView files in the
Knativedirectory> dirOutput:
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 freeVerify that the
kn.exefile is available in the directoryAdd the
Knativefolder to your Windows system commands path> setx PATH "%PATH%;C:\Knative" /MClose your Windows Command Prompt and open it again to start a new session
View the system paths and verify that the
Knativedirectory is available on the list> PATHYour 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
kncommand and verify the installed Knative CLI version> kn versionOutput:
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 nodesView the list of available Knative CLI commands
$ kn --helpOutput:
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-worldwith your desired image$ kn service create sample-service --image hello-worldDescribe 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: