client/docs
Roland Huß b916a5b3ed
Add grouping for help message + streamlined help messages (#887)
* Add grouping for help message + streamlined help messages

The top-level looks like

kn is the command line interface for managing Knative Serving and Eventing objects

 Find more information about Knative at: https://knative.dev

Serving Commands:
  service     Manage Knative services
  revision    Manage service revisions
  route       List and show service routes

Eventing Commands:
  source      Manage event sources
  trigger     Manage event triggers

Other Commands:
  plugin      Manage kn plugins
  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).

The following changes have been applied:

* Add CommandGroups for grouping commands together
* Add flexible templating for the help messages
* Moved global options to an own command ('kn options', much like 'kubectl options')
* Aligned wording and typography of help messages

These features has been highly inspired by kubectl grouping & help templating but has been considerably been stripped down to the needs of kn.

Signed-off-by: Roland Huß <roland@ro14nd.de>

* chore: Add missing file

* Update pkg/templates/command_groups.go

Co-authored-by: Matt Moore <mattmoor@vmware.com>

* chore: Add some test for error messages

* fix formatting

* chore: Add test

* moar tests

* Update pkg/kn/commands/completion/completion.go

Co-authored-by: Navid Shaikh <nshaikh@redhat.com>

* Update pkg/kn/commands/source/apiserver/delete.go

Co-authored-by: Navid Shaikh <nshaikh@redhat.com>

* Update pkg/kn/commands/service/list.go

Co-authored-by: Navid Shaikh <nshaikh@redhat.com>

* Update pkg/kn/commands/route/route.go

Co-authored-by: Navid Shaikh <nshaikh@redhat.com>

* Update pkg/kn/commands/revision/delete.go

Co-authored-by: Navid Shaikh <nshaikh@redhat.com>

* Update pkg/kn/commands/plugin/plugin.go

Co-authored-by: Navid Shaikh <nshaikh@redhat.com>

* Update pkg/kn/commands/service/delete.go

Co-authored-by: Navid Shaikh <nshaikh@redhat.com>

* Update pkg/kn/commands/revision/delete.go

Co-authored-by: Navid Shaikh <nshaikh@redhat.com>

* Update pkg/kn/commands/service/delete.go

Co-authored-by: Navid Shaikh <nshaikh@redhat.com>

* regen docs

* chore: Update conventions doc

* Move some direct configuration of rootcmd to NewRootCommand()

* Moved CaptureOutput to "test" package for reuse

Co-authored-by: Matt Moore <mattmoor@vmware.com>
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
2020-06-18 00:06:25 -07:00
..
cmd Add grouping for help message + streamlined help messages (#887) 2020-06-18 00:06:25 -07:00
dev Refactor main flow and introduce explicit plugin and config handling (#877) 2020-06-15 09:15:24 -07:00
operations docs: Update kn service create examples with real image (#862) 2020-05-27 17:21:59 -07:00
plugins Fix plugin execution for Windows (#738) 2020-03-20 09:22:07 -07:00
traffic Format markdown (#710) 2020-03-09 09:19:28 -07:00
workflows Format markdown (#710) 2020-03-09 09:19:28 -07:00
DEVELOPMENT.md Format markdown (#710) 2020-03-09 09:19:28 -07:00
README.md Format markdown (#710) 2020-03-09 09:19:28 -07:00

README.md

kn

kn is the Knative command line interface (CLI).

Getting Started

Installing kn

You can grab the latest nightly binary executable for:

Put it on your system path, and make sure it's executable.

Alternatively, check out the client repository, and type:

go install ./cmd/kn

To use the kn container image:

  • Nightly: gcr.io/knative-nightly/knative.dev/client/cmd/kn
  • Latest release: gcr.io/knative-releases/knative.dev/client/cmd/kn

Connecting to your cluster

You'll need a kubectl-style config file to connect to your cluster.

  • Starting minikube writes this file (or gives you an appropriate context in an existing config file)
  • Instructions for Google GKE
  • Instructions for Amazon EKS
  • Instructions for IBM IKS
  • Instructions for Red Hat OpenShift
  • Or contact your cluster administrator

kn will pick up your kubectl config file in the default location of $HOME/.kube/config. You can specify an alternate kubeconfig connection file with --kubeconfig, or the env var $KUBECONFIG, for any command.

Kn Config

There are a set of configuration parameters you can setup to better customize kn. For example, you can specify where your kn plugins are located and how they are found, and you can specify the prefix for your addressable sink objects. The kn configuration file is meant to capture these configuration options. Let's explore this file's location, and the options you are able to change with it.

Location

The default location kn looks for config is under the home directory of the user at $HOME/.config/kn/config.yaml. It is not created for you as part of the kn installation. You can create this file elsewhere and use the --config flag to specify its path.

Options

Below are the options you can specify in the kn config file.

  1. pluginsDir which is the same as the persistent flag --plugins-dir and specifies the kn plugins directory. It defaults to: ~/.config/kn/plugins. By using the persistent flag (when you issue a command) or by specifying the value in the kn config, a user can select which directory to find kn plugins. It can be any directory that is visible to the user.

  2. lookupPluginsInPath which is the same as the persistent flag --lookup-plugins-in-path and specficies if kn should look for plugins anywhere in the specified PATH environment variable. This is a boolean configuration option and the default value is false.

  3. sink defines your prefix to refer to Kubernetes addressable resources. To configure a sink prefix, define following in the config file:

    1. prefix: Prefix you want to describe your sink as. service or svc (serving.knative.dev/v1) and broker (eventing.knative.dev/v1alpha1) are predefined prefixes in kn. These predefined prefixes can be overridden by values in configuration file.
    2. group: The APIGroup of Kubernetes resource.
    3. version: The version of Kubernetes resources.
    4. resource: The plural name of Kubernetes resources (for example: services).

For example, the following kn config will look for kn plugins in the user's PATH and also execute plugin in ~/kn/.config/plugins. It also defines a sink prefix myprefix which refers to brokers in eventing.knative.dev/v1alpha1. With this configuration, you can use myprefix:default to describe a Broker default in kn command line.

cat ~/.config/kn/config.yaml
lookupPluginsInPath: true
pluginsdir: ~/.config/kn/plugins
sink:
- prefix: myprefix
  group: eventing.knative.dev
  version: v1alpha1
  resource: brokers

Commands

Plugins

Kn supports plugins, which allow you to extend the functionality of your kn installation with custom commands as well as shared commands that are not part of the core distribution of kn. See the plugins documentation for more information.

More information on kn: