The kn admin
is a plugin of Knative client and it is designed to help administrators and operators better manage a Knative platform installation with kn CLI.
This plugin’s main objective is to make administration and operation workflows easier, for instance by making it easy to accomplish
tasks such as feature flags enablement or disablement with one command, instead of many manual steps like modifying ConfigMaps or yaml files.
You can download latest binaries from the Releases page.
Here are two ways to run kn admin
:
-
You can run it standalone, just put it on your system path, and make sure it is executable.
-
You can install it as a plugin of
kn
client to run:-
Following the document to install
kn client
if you don’t have it. -
Copy
kn admin
binary to~/.config/kn/plugins/
folder and make sure its filename iskn-admin
. -
Run
kn plugin list
to assure thekn-admin
plugin is installed successfully.
-
After the plugin is installed, you can use kn admin
to run its related subcommands.
A plugin of kn client to manage Knative for administrators. For example: kn admin domain set - to set Knative route domain kn admin private-registry enable - to enable deployment from the private registry kn admin autoscaling update - to manage autoscaling config Usage: kn admin [command] Available Commands: autoscaling Manage autoscaling config domain Manage route domain help Help about any command registry Manage registry version Prints the plugin version Flags: --config string config file (default is $HOME/.config/kn/plugins/admin.yaml) -h, --help help for kn admin -t, --toggle Help message for toggle Use "kn admin [command] --help" for more information about a command.
Set default route domain or route domain for Service with selectors. For example: kn admin domain set - to set Knative route domain Usage: kn admin domain [flags] kn admin domain [command] Available Commands: set set route domain unset unset route domain Flags: -h, --help help for domain Global Flags: --config string config file (default is $HOME/.config/kn/plugins/admin.yaml) Use "admin domain [command] --help" for more information about a command.
Manage registry used by Knative service deployment Usage: kn admin registry [command] Available Commands: add Add registry with credentials help Help about any command list List registry settings remove Remove registry settings Flags: -h, --help help for registry Global Flags: --config string config file (default is $HOME/.config/kn/plugins/admin.yaml) Use "kn admin registry [command] --help" for more information about a command.
Manage autoscaling provided by Knative Pod Autoscaler (KPA). For example: kn admin autoscaling update - to manage autoscaling config Usage: kn admin autoscaling [command] Available Commands: update update autoscaling config Flags: -h, --help help for autoscaling Global Flags: --config string config file (default is $HOME/.config/kn/plugins/admin.yaml) Use "kn admin autoscaling [command] --help" for more information about a command.
Enable Knative Serving components profiling and download profiling data Usage: kn admin profiling [flags] Aliases: profiling, prof Examples: # To enable Knative Serving profiling kn admin profiling --enable # To download heap profiling data of autoscaler kn admin profiling --target autoscaler --heap # To download 2 minutes execution trace data of networking-istio kn admin profiling --target networking-istio --trace 2m # To download go routing block and memory allocations data of activator and save them to /tmp kn admin profiling --target activator --block --mem-allocs --save-to /tmp # To download all available profiling data for specified pod activator-5979f56548 kn admin profiling --target activator-5979f56548 --all Flags: --all Download all available profiling data --block Download go routine blocking data --cpu string Download cpu profiling data, you can specify a profiling data duration with 's' for second(s), 'm' for minute(s) and 'h' for hour(s), e.g: '1m' for one minute (default "5s") --disable Disable Knative Serving profiling --enable Enable Knative Serving profiling --goroutine Download stack traces of all current goroutines data --heap Download heap profiling data -h, --help help for profiling --mem-allocs Download memory allocations data --mutex Download holders of contended mutexes data -s, --save-to string The path to save the downloaded profiling data, if not speicifed, the data will be saved in current working folder -t, --target string The profiling target. It can be a Knative Serving component name or a specific pod name, e.g: 'activator' or 'activator-586d468c99-w59cm' --thread-create Download stack traces that led to the creation of new OS threads data --trace string Download execution trace data, you can specify a trace data duration with 's' for second(s), 'm' for minute(s) and 'h' for hour(s), e.g: '1m' for one minute (default "5s") Global Flags: --config string config file (default is $HOME/.config/kn/plugins/admin.yaml)
$ kn admin domain set --custom-domain mydomain.com Set Knative route domain mydomain.com
$ kn admin domain set --custom-domain test.com --selector app=v1 Set Knative route domain test.com with selector [app=v1]
$ kn-admin domain unset --custom-domain mydomain.com Unset Knative route domain mydomain.com
$ kn admin registry add \ --secret=[SECRET_NAME] \ --server=[REGISTRY_SERVER_URL] \ --email=[REGISTRY_EMAIL] \ --username=[REGISTRY_USER] \ --password=[REGISTRY_PASSWORD] \ --namespace=[NAMESPACE] \ --serviceaccount=[SERVICE_ACCOUNT]
$ kn admin registry list \ --namespace=[NAMESPACE] \ --serviceaccount=[SERVICE_ACCOUNT]
$ kn admin registry remove \ --username=[REGISTRY_USER] \ --server=[REGISTRY_SERVER_URL] \ --namespace=[NAMESPACE] \ --serviceaccount=[SERVICE_ACCOUNT]
$ kn admin autoscaling update --scale-to-zero Updated Knative autoscaling config enable-scale-to-zero: true
$ kn admin profiling --enable Knative Serving profiling is enabled
$ kn admin profiling --target activator --cpu 5s --save-to /tmp Starting to download profiling data for pod activator-586d468c99-w59cm... Saving 5 second(s) cpu profiling data to /tmp/activator-586d468c99-w59cm_cpu_5s_20200725165758 Forwarding from 127.0.0.1:18008 -> 8008 Forwarding from [::1]:18008 -> 8008 Handling connection for 18008
After you get the profiling data file, you need to use pprof to open it.