A Knative service is the embodiment of a serverless workload. It is generally in the form of a collection of containers running in a group of pods, in the underlying Kubernetes cluster. Each Knative service associates with a collection of revisions, which represent the evolution of that service.
With the Kn CLI a user can list
,
create
,
delete
, and
update
Knative services. The
detail reference of each sub-command under the
service
command shows the options and flags for this
group of commands.
Examples:
# Create a new service from an image
kn service create mysvc --env KEY1=VALUE1 --env KEY2=VALUE2 --image knativesamples/helloworld
You are able to also specify the requests and limits of both CPU and memory when
creating a service. See service create
command
reference for additional details.
# List existing services in the 'default' namespace of your cluster
kn service list
You can also list services from all namespaces or a specific namespace using
flags: --all-namespaces
and --namespace mynamespace
. See
service list
command reference for additional
details.
A Knative revision is a "snapshot" of the specification of a service. For
instance, when a Knative service is created with the environment variable
FOO=bar
a revision is added to the service. Afterwards, when the environment
variable is changed to baz
or additional variables are added, a new revision
is created. When the image that the service is running is changed to a new
digest, a new revision is created.
With the revision
command group you can
list and
describe the current revisions on a service.
Examples:
# Listing a service's revision
kn revision list --service srvc
These are commands that provide some useful information to the user.
- The
kn help
command displays a list of the commands with helpful information. - The
kn version
command will display the current version of thekn
build including date and Git commit revision. - The
kn completion
command will output a BASH completion script forkn
to allow command completions with tabs.
For every kn
command, you can use these common additional flags:
-h
or--help
to display specific help for that command--config string
which specifies thekn
config file (default is $HOME/.kn.yaml)--kubeconfig string
which specifies the kubectl config file (default is $HOME/.kube/config)