text
stringlengths 1
1k
| id
int64 0
8.58k
|
---|---|
Editing is done with the API version used to fetch the resource. To edit using a specific API
version, fully-qualify the resource, version, and group.
The default format is YAML. To edit in JSON, specify "-o json".
The flag --windows-line-endings can be used to force Windows line endings, otherwise the
default for your operating system will be used.
In the event an error occurs while updating, a temporary file will be created on disk that
contains your unapplied changes. The most common error when updating a resource is another
editor changing the resource on the server. When this occurs, you will have to apply your
changes to the newer version of the resource, or update your temporary saved copy to include
the latest resource version.
kubectl edit (RESOURCE/NAME | -f FILENAME)
Examples
# Edit the service named 'registry'
kubectl edit svc/registry
# Use an alternative editor
KUBE_EDITOR="nano" kubectl edit svc/registry
# Edit the job 'myjob' in JSON using the v1 API for | 6,700 |
mat
kubectl edit job.v1.batch/myjob -o json
# Edit the deployment 'mydeployment' in YAML and save the modified config in its annotation
kubectl edit deployment/mydeployment -o yaml --save-config
# Edit the 'status' subresource for the 'mydeployment' deployment
kubectl edit deployment mydeployment --subresource='status'
Options
--allow-missing-template-keys Default: true
If true, ignore any errors in templates when a field or map key is missing in the template. Only
applies to golang and jsonpath output formats.
--field-manager string Default: "kubectl-edit"
Name of the manager used to track field ownership.
-f, --filename strings
Filename, directory, or URL to files to use to edit the resource
-h, --help
help for edi | 6,701 |
-k, --kustomize string
Process the kustomization directory. This flag can't be used together with -f or -R.
-o, --output string
Output format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile,
jsonpath, jsonpath-as-json, jsonpath-file).
--output-patch
Output the patch if the resource is edited.
-R, --recursive
Process the directory used in -f, --filename recursively. Useful when you want to manage
related manifests organized within the same directory.
--save-config
If true, the configuration of current object will be saved in its annotation. Otherwise, the
annotation will be unchanged. This flag is useful when you want to perform kubectl apply on
this object in the future.
--show-managed-fields
If true, keep the managedFields when printing objects in JSON or YAML format.
--subresource string
If specified, edit will operate on the subresource of the requested object. Must be one of
[status]. This flag is beta and may change in the future.
--template strin | 6,702 |
g
Template string or path to template file to use when -o=go-template, -o=go-template-file. The
template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
--validate string[="strict"] Default: "strict"
Must be one of: strict (or true), warn, ignore (or false).
"true" or "strict" will use a schema to validate the input and fail the request if invalid. It will
perform server side validation if ServerSideFieldValidation is enabled on the api-server, but
will fall back to less reliable client-side validation if not.
"warn" will warn about unknown or duplicate fields without blocking the request if server-
side field validation is enabled on the API server, and behave as "ignore" otherwise.
"false" or "ignore" will not perform any schema validation, silently dropping any unknown or
duplicate fields.
--windows-line-ending | 6,703 |
Defaults to the line ending native to your platform.
--as string
Username to impersonate for the operation. User could be a regular user or a service account
in a namespace.
--as-group strings
Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--as-uid string
UID to impersonate for the operation.
--azure-container-registry-config string
Path to the file containing Azure container registry configuration information.
--cache-dir string Default: "$HOME/.kube/cache"
Default cache directory
--certificate-authority string
Path to a cert file for the certificate authority
--client-certificate string
Path to a client certificate file for TLS
--client-key string
Path to a client key file for TLS
--cloud-provider-gce-l7lb-src-cidrs cidrs Default: 130.211.0.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L7 LB traffic proxy & health checks
--cloud-provider-gce-lb-src-cidrs cidrs Default:
130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.1 | 6,704 |
91.0.0/16
CIDRs opened in GCE firewall for L4 LB traffic proxy & health checks
--cluster string
The name of the kubeconfig cluster to use
--context strin | 6,705 |
The name of the kubeconfig context to use
--default-not-ready-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for notReady:NoExecute that is added by
default to every pod that does not already have such a toleration.
--default-unreachable-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for unreachable:NoExecute that is added by
default to every pod that does not already have such a toleration.
--disable-compression
If true, opt-out of response compression for all requests to the server
--insecure-skip-tls-verify
If true, the server's certificate will not be checked for validity. This will make your HTTPS
connections insecure
--kubeconfig string
Path to the kubeconfig file to use for CLI requests.
--match-server-version
Require server version to match client version
-n, --namespace string
If present, the namespace scope for this CLI request
--password string
Password for basic authentication to the API s | 6,706 |
erver
--profile string Default: "none"
Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex)
--profile-output string Default: "profile.pprof"
Name of the file to write the profile to
--request-timeout string Default: "0"
The length of time to wait before giving up on a single server request. Non-zero values should
contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout
requests | 6,707 |
-s, --server string
The address and port of the Kubernetes API server
--storage-driver-buffer-duration duration Default: 1m0s
Writes in the storage driver will be buffered for this duration, and committed to the non
memory backends as a single transaction
--storage-driver-db string Default: "cadvisor"
database name
--storage-driver-host string Default: "localhost:8086"
database host:port
--storage-driver-password string Default: "root"
database password
--storage-driver-secure
use secure connection with database
--storage-driver-table string Default: "stats"
table name
--storage-driver-user string Default: "root"
database username
--tls-server-name string
Server name to use for server certificate validation. If it is not provided, the hostname used to
contact the server is used
--token string
Bearer token for authentication to the API server
--user string
The name of the kubeconfig user to use
--username string
Username for basic authentication to the API server | 6,708 |
--version version[=true | 6,709 |
--version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the
reported version
--warnings-as-errors
Treat warnings received from the server as errors and exit with a non-zero exit code
See Also
kubectl - kubectl controls the Kubernetes cluster manager
kubectl events
Synopsis
Display events.
Prints a table of the most important information about events. You can request events for a
namespace, for all namespace, or filtered to only those pertaining to a specified resource.
kubectl events [(-o|--output=)json|yaml|name|go-template|go-template-file|template|templatefile|
jsonpath|jsonpath-as-json|jsonpath-file] [--for TYPE/NAME] [--watch] [--
types=Normal,Warning]
Examples
# List recent events in the default namespace
kubectl events
# List recent events in all namespaces
kubectl events --all-namespaces
# List recent events for the specified pod, then wait for more events and list them as they
arrive
kubectl events --for pod/web-pod-13je7 --w | 6,710 |
atch
# List recent events in YAML format
kubectl events -oyaml
# List recent only events of type 'Warning' or 'Normal'
kubectl events --types=Warning,Normal
Options
-A, --all-namespaces | 6,711 |
If present, list the requested object(s) across all namespaces. Namespace in current context is
ignored even if specified with --namespace.
--allow-missing-template-keys Default: true
If true, ignore any errors in templates when a field or map key is missing in the template. Only
applies to golang and jsonpath output formats.
--chunk-size int Default: 500
Return large lists in chunks rather than all at once. Pass 0 to disable. This flag is beta and may
change in the future.
--for string
Filter events to only those pertaining to the specified resource.
-h, --help
help for events
--no-headers
When using the default output format, don't print headers.
-o, --output string
Output format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile,
jsonpath, jsonpath-as-json, jsonpath-file).
--show-managed-fields
If true, keep the managedFields when printing objects in JSON or YAML format.
--template string
Template string or path to template file to use when -o= | 6,712 |
go-template, -o=go-template-file. The
template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
--types strings
Output only events of given types.
-w, --watch
After listing the requested events, watch for more events.
--as strin | 6,713 |
Username to impersonate for the operation. User could be a regular user or a service account
in a namespace.
--as-group strings
Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--as-uid string
UID to impersonate for the operation.
--azure-container-registry-config string
Path to the file containing Azure container registry configuration information.
--cache-dir string Default: "$HOME/.kube/cache"
Default cache directory
--certificate-authority string
Path to a cert file for the certificate authority
--client-certificate string
Path to a client certificate file for TLS
--client-key string
Path to a client key file for TLS
--cloud-provider-gce-l7lb-src-cidrs cidrs Default: 130.211.0.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L7 LB traffic proxy & health checks
--cloud-provider-gce-lb-src-cidrs cidrs Default:
130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L4 LB traffic proxy & | 6,714 |
health checks
--cluster string
The name of the kubeconfig cluster to use
--context string
The name of the kubeconfig context to use
--default-not-ready-toleration-seconds int Default: 30 | 6,715 |
Indicates the tolerationSeconds of the toleration for notReady:NoExecute that is added by
default to every pod that does not already have such a toleration.
--default-unreachable-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for unreachable:NoExecute that is added by
default to every pod that does not already have such a toleration.
--disable-compression
If true, opt-out of response compression for all requests to the server
--insecure-skip-tls-verify
If true, the server's certificate will not be checked for validity. This will make your HTTPS
connections insecure
--kubeconfig string
Path to the kubeconfig file to use for CLI requests.
--match-server-version
Require server version to match client version
-n, --namespace string
If present, the namespace scope for this CLI request
--password string
Password for basic authentication to the API server
--profile string Default: "none"
Name of profile to capture. One of (none|cpu|heap|goroutine | 6,716 |
|threadcreate|block|mutex)
--profile-output string Default: "profile.pprof"
Name of the file to write the profile to
--request-timeout string Default: "0"
The length of time to wait before giving up on a single server request. Non-zero values should
contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout
requests.
-s, --server string
The address and port of the Kubernetes API serve | 6,717 |
--storage-driver-buffer-duration duration Default: 1m0s
Writes in the storage driver will be buffered for this duration, and committed to the non
memory backends as a single transaction
--storage-driver-db string Default: "cadvisor"
database name
--storage-driver-host string Default: "localhost:8086"
database host:port
--storage-driver-password string Default: "root"
database password
--storage-driver-secure
use secure connection with database
--storage-driver-table string Default: "stats"
table name
--storage-driver-user string Default: "root"
database username
--tls-server-name string
Server name to use for server certificate validation. If it is not provided, the hostname used to
contact the server is used
--token string
Bearer token for authentication to the API server
--user string
The name of the kubeconfig user to use
--username string
Username for basic authentication to the API server
--version version[=true]
--version, --version=raw prints version info | 6,718 |
rmation and quits; --version=vX.Y.Z... sets the
reported version
--warnings-as-error | 6,719 |
Treat warnings received from the server as errors and exit with a non-zero exit code
See Also
kubectl - kubectl controls the Kubernetes cluster manager
kubectl exec
Synopsis
Execute a command in a container.
kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]
Examples
# Get output from running the 'date' command from pod mypod, using the first container by
default
kubectl exec mypod -- date
# Get output from running the 'date' command in ruby-container from pod mypod
kubectl exec mypod -c ruby-container -- date
# Switch to raw terminal mode; sends stdin to 'bash' in ruby-container from pod mypod
# and sends stdout/stderr from 'bash' back to the client
kubectl exec mypod -c ruby-container -i -t -- bash -il
# List contents of /usr from the first container of pod mypod and sort by modification time
# If the command you want to execute in the pod has any flags in common (e.g. -i),
# you must use two dashes (--) to separate your command' | 6,720 |
s flags/arguments
# Also note, do not surround your command and its flags/arguments with quotes
# unless that is how you would execute it normally (i.e., do ls -t /usr, not "ls -t /usr")
kubectl exec mypod -i -t -- ls -t /usr
# Get output from running 'date' command from the first pod of the deployment
mydeployment, using the first container by default
kubectl exec deploy/mydeployment -- date
# Get output from running 'date' command from the first pod of the service myservice, using
the first container by default
kubectl exec svc/myservice -- date
Options
-c, --container string | 6,721 |
Container name. If omitted, use the kubectl.kubernetes.io/default-container annotation for
selecting the container to be attached or the first container in the pod will be chosen
-f, --filename strings
to use to exec into the resource
-h, --help
help for exec
--pod-running-timeout duration Default: 1m0s
The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is
running
-q, --quiet
Only print output from the remote session
-i, --stdin
Pass stdin to the container
-t, --tty
Stdin is a TTY
--as string
Username to impersonate for the operation. User could be a regular user or a service account
in a namespace.
--as-group strings
Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--as-uid string
UID to impersonate for the operation.
--azure-container-registry-config string
Path to the file containing Azure container registry configuration information.
--cache-dir string Default: "$HOME/.kube/cache"
Default cac | 6,722 |
he directory
--certificate-authority strin | 6,723 |
Path to a cert file for the certificate authority
--client-certificate string
Path to a client certificate file for TLS
--client-key string
Path to a client key file for TLS
--cloud-provider-gce-l7lb-src-cidrs cidrs Default: 130.211.0.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L7 LB traffic proxy & health checks
--cloud-provider-gce-lb-src-cidrs cidrs Default:
130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L4 LB traffic proxy & health checks
--cluster string
The name of the kubeconfig cluster to use
--context string
The name of the kubeconfig context to use
--default-not-ready-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for notReady:NoExecute that is added by
default to every pod that does not already have such a toleration.
--default-unreachable-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for unreachable:NoExecute that is added by
| 6,724 |
default to every pod that does not already have such a toleration.
--disable-compression
If true, opt-out of response compression for all requests to the server
--insecure-skip-tls-verify
If true, the server's certificate will not be checked for validity. This will make your HTTPS
connections insecure
--kubeconfig string
Path to the kubeconfig file to use for CLI requests.
--match-server-versio | 6,725 |
Require server version to match client version
-n, --namespace string
If present, the namespace scope for this CLI request
--password string
Password for basic authentication to the API server
--profile string Default: "none"
Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex)
--profile-output string Default: "profile.pprof"
Name of the file to write the profile to
--request-timeout string Default: "0"
The length of time to wait before giving up on a single server request. Non-zero values should
contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout
requests.
-s, --server string
The address and port of the Kubernetes API server
--storage-driver-buffer-duration duration Default: 1m0s
Writes in the storage driver will be buffered for this duration, and committed to the non
memory backends as a single transaction
--storage-driver-db string Default: "cadvisor"
database name
--storage-driver-host string | 6,726 |
Default: "localhost:8086"
database host:port
--storage-driver-password string Default: "root"
database password
--storage-driver-secure
use secure connection with database
--storage-driver-table string Default: "stats | 6,727 |
table name
--storage-driver-user string Default: "root"
database username
--tls-server-name string
Server name to use for server certificate validation. If it is not provided, the hostname used to
contact the server is used
--token string
Bearer token for authentication to the API server
--user string
The name of the kubeconfig user to use
--username string
Username for basic authentication to the API server
--version version[=true]
--version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the
reported version
--warnings-as-errors
Treat warnings received from the server as errors and exit with a non-zero exit code
See Also
kubectl - kubectl controls the Kubernetes cluster manager
kubectl explain
Synopsis
Describe fields and structure of various resources.
This command describes the fields associated with each supported API resource. Fields are
identified via a simple JSONPath identifier:
<type>.<fieldName>[.<fieldName>]
Information about each fiel | 6,728 |
d is retrieved from the server in OpenAPI format. | 6,729 |
Use "kubectl api-resources" for a complete list of supported resources.
kubectl explain TYPE [--recursive=FALSE|TRUE] [--api-version=api-version-group] [--
output=plaintext|plaintext-openapiv2]
Examples
# Get the documentation of the resource and its fields
kubectl explain pods
# Get all the fields in the resource
kubectl explain pods --recursive
# Get the explanation for deployment in supported api versions
kubectl explain deployments --api-version=apps/v1
# Get the documentation of a specific field of a resource
kubectl explain pods.spec.containers
# Get the documentation of resources in different format
kubectl explain deployment --output=plaintext-openapiv2
Options
--api-version string
Use given api-version (group/version) of the resource.
-h, --help
help for explain
--output string Default: "plaintext"
Format in which to render the schema. Valid values are: (plaintext, plaintext-openapiv2).
--recursive
When true, print the name of all the fields | 6,730 |
recursively. Otherwise, print the available fields
with their description.
--as string
Username to impersonate for the operation. User could be a regular user or a service account
in a namespace.
--as-group strings
Group to impersonate for the operation, this flag can be repeated to specify multiple groups | 6,731 |
--as-uid string
UID to impersonate for the operation.
--azure-container-registry-config string
Path to the file containing Azure container registry configuration information.
--cache-dir string Default: "$HOME/.kube/cache"
Default cache directory
--certificate-authority string
Path to a cert file for the certificate authority
--client-certificate string
Path to a client certificate file for TLS
--client-key string
Path to a client key file for TLS
--cloud-provider-gce-l7lb-src-cidrs cidrs Default: 130.211.0.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L7 LB traffic proxy & health checks
--cloud-provider-gce-lb-src-cidrs cidrs Default:
130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L4 LB traffic proxy & health checks
--cluster string
The name of the kubeconfig cluster to use
--context string
The name of the kubeconfig context to use
--default-not-ready-toleration-seconds int Default: 300
Indicates the tolerationSecond | 6,732 |
s of the toleration for notReady:NoExecute that is added by
default to every pod that does not already have such a toleration.
--default-unreachable-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for unreachable:NoExecute that is added by
default to every pod that does not already have such a toleration.
--disable-compressio | 6,733 |
If true, opt-out of response compression for all requests to the server
--insecure-skip-tls-verify
If true, the server's certificate will not be checked for validity. This will make your HTTPS
connections insecure
--kubeconfig string
Path to the kubeconfig file to use for CLI requests.
--match-server-version
Require server version to match client version
-n, --namespace string
If present, the namespace scope for this CLI request
--password string
Password for basic authentication to the API server
--profile string Default: "none"
Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex)
--profile-output string Default: "profile.pprof"
Name of the file to write the profile to
--request-timeout string Default: "0"
The length of time to wait before giving up on a single server request. Non-zero values should
contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout
requests.
-s, --server string
The address and port of | 6,734 |
the Kubernetes API server
--storage-driver-buffer-duration duration Default: 1m0s
Writes in the storage driver will be buffered for this duration, and committed to the non
memory backends as a single transaction
--storage-driver-db string Default: "cadvisor"
database name
--storage-driver-host string Default: "localhost:8086 | 6,735 |
database host:port
--storage-driver-password string Default: "root"
database password
--storage-driver-secure
use secure connection with database
--storage-driver-table string Default: "stats"
table name
--storage-driver-user string Default: "root"
database username
--tls-server-name string
Server name to use for server certificate validation. If it is not provided, the hostname used to
contact the server is used
--token string
Bearer token for authentication to the API server
--user string
The name of the kubeconfig user to use
--username string
Username for basic authentication to the API server
--version version[=true]
--version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the
reported version
--warnings-as-errors
Treat warnings received from the server as errors and exit with a non-zero exit code
See Also
kubectl - kubectl controls the Kubernetes cluster manager • | 6,736 |
kubectl expose
Synopsis
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the
selector for that resource as the selector for a new service on the specified port. A deployment
or replica set will be exposed as a service only if its selector is convertible to a selector that
service supports, i.e. when the selector contains only the matchLabels component. Note that if
no port is specified via --port and the exposed resource has multiple ports, all will be re-used by
the new service. Also if no labels are specified, the new service will re-use the labels from the
resource it exposes.
Possible resources include (case insensitive):
pod (po), service (svc), replicationcontroller (rc), deployment (deploy), replicaset (rs)
kubectl expose (-f FILENAME | TYPE NAME) [--port=port] [--protocol=TCP|UDP|SCTP] [--
target-port=number-or-name] [--name=name] [--external-ip=external-ip-of-service] [--
type=type]
Examp | 6,737 |
les
# Create a service for a replicated nginx, which serves on port 80 and connects to the
containers on port 8000
kubectl expose rc nginx --port=80 --target-port=8000
# Create a service for a replication controller identified by type and name specified in "nginx-
controller.yaml", which serves on port 80 and connects to the containers on port 8000
kubectl expose -f nginx-controller.yaml --port=80 --target-port=8000
# Create a service for a pod valid-pod, which serves on port 444 with the name "frontend"
kubectl expose pod valid-pod --port=444 --name=frontend
# Create a second service based on the above service, exposing the container port 8443 as port
443 with the name "nginx-https"
kubectl expose service nginx --port=443 --target-port=8443 --name=nginx-https
# Create a service for a replicated streaming application on port 4100 balancing UDP traffic
and named 'video-stream'.
kubectl expose rc streamer --port=4100 --protocol=UDP --name=video-stream
| 6,738 |
# Create a service for a replicated nginx using replica set, which serves on port 80 and
connects to the containers on port 8000
kubectl expose rs nginx --port=80 --target-port=8000
# Create a service for an nginx deployment, which serves on port 80 and connects to the
containers on port 8000
kubectl expose deployment nginx --port=80 --target-port=800 | 6,739 |
Options
--allow-missing-template-keys Default: true
If true, ignore any errors in templates when a field or map key is missing in the template. Only
applies to golang and jsonpath output formats.
--cluster-ip string
ClusterIP to be assigned to the service. Leave empty to auto-allocate, or set to 'None' to create
a headless service.
--dry-run string[="unchanged"] Default: "none"
Must be "none", "server", or "client". If client strategy, only print the object that would be sent,
without sending it. If server strategy, submit server-side request without persisting the
resource.
--external-ip string
Additional external IP address (not managed by Kubernetes) to accept for the service. If this IP
is routed to a node, the service can be accessed by this IP in addition to its generated service
IP.
--field-manager string Default: "kubectl-expose"
Name of the manager used to track field ownership.
-f, --filename strings
Filename, directory, or URL to files identifying the resource to | 6,740 |
expose a service
-h, --help
help for expose
-k, --kustomize string
Process the kustomization directory. This flag can't be used together with -f or -R.
-l, --labels string
Labels to apply to the service created by this call.
--load-balancer-ip string
IP to assign to the LoadBalancer. If empty, an ephemeral IP will be created and used (cloud-
provider specific).
--name strin | 6,741 |
The name for the newly created object.
-o, --output string
Output format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile,
jsonpath, jsonpath-as-json, jsonpath-file).
--override-type string Default: "merge"
The method used to override the generated object: json, merge, or strategic.
--overrides string
An inline JSON override for the generated object. If this is non-empty, it is used to override the
generated object. Requires that the object supply a valid apiVersion field.
--port string
The port that the service should serve on. Copied from the resource being exposed, if
unspecified
--protocol string
The network protocol for the service to be created. Default is 'TCP'.
-R, --recursive
Process the directory used in -f, --filename recursively. Useful when you want to manage
related manifests organized within the same directory.
--save-config
If true, the configuration of current object will be saved in its annotation. Otherwise, the
annotation will be | 6,742 |
unchanged. This flag is useful when you want to perform kubectl apply on
this object in the future.
--selector string
A label selector to use for this service. Only equality-based selector requirements are
supported. If empty (the default) infer the selector from the replication controller or replica
set.)
--session-affinity string
If non-empty, set the session affinity for the service to this; legal values: 'None', 'ClientIP'
--show-managed-fields
If true, keep the managedFields when printing objects in JSON or YAML format.
--target-port strin | 6,743 |
Name or number for the port on the container that the service should direct traffic to.
Optional.
--template string
Template string or path to template file to use when -o=go-template, -o=go-template-file. The
template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
--type string
Type for this service: ClusterIP, NodePort, LoadBalancer, or ExternalName. Default is
'ClusterIP'.
--as string
Username to impersonate for the operation. User could be a regular user or a service account
in a namespace.
--as-group strings
Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--as-uid string
UID to impersonate for the operation.
--azure-container-registry-config string
Path to the file containing Azure container registry configuration information.
--cache-dir string Default: "$HOME/.kube/cache"
Default cache directory
--certificate-authority string
Path to a cert file for the certificate authority
--client-certificate s | 6,744 |
tring
Path to a client certificate file for TLS
--client-key string
Path to a client key file for TLS
--cloud-provider-gce-l7lb-src-cidrs cidrs Default: 130.211.0.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L7 LB traffic proxy & health check | 6,745 |
--cloud-provider-gce-lb-src-cidrs cidrs Default:
130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L4 LB traffic proxy & health checks
--cluster string
The name of the kubeconfig cluster to use
--context string
The name of the kubeconfig context to use
--default-not-ready-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for notReady:NoExecute that is added by
default to every pod that does not already have such a toleration.
--default-unreachable-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for unreachable:NoExecute that is added by
default to every pod that does not already have such a toleration.
--disable-compression
If true, opt-out of response compression for all requests to the server
--insecure-skip-tls-verify
If true, the server's certificate will not be checked for validity. This will make your HTTPS
connections insecure
--kubeconfig string
Path | 6,746 |
to the kubeconfig file to use for CLI requests.
--match-server-version
Require server version to match client version
-n, --namespace string
If present, the namespace scope for this CLI request
--password string
Password for basic authentication to the API server
--profile string Default: "none"
Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex | 6,747 |
--profile-output string Default: "profile.pprof"
Name of the file to write the profile to
--request-timeout string Default: "0"
The length of time to wait before giving up on a single server request. Non-zero values should
contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout
requests.
-s, --server string
The address and port of the Kubernetes API server
--storage-driver-buffer-duration duration Default: 1m0s
Writes in the storage driver will be buffered for this duration, and committed to the non
memory backends as a single transaction
--storage-driver-db string Default: "cadvisor"
database name
--storage-driver-host string Default: "localhost:8086"
database host:port
--storage-driver-password string Default: "root"
database password
--storage-driver-secure
use secure connection with database
--storage-driver-table string Default: "stats"
table name
--storage-driver-user string Default: "root"
database username
--tls-s | 6,748 |
erver-name string
Server name to use for server certificate validation. If it is not provided, the hostname used to
contact the server is used
--token string
Bearer token for authentication to the API serve | 6,749 |
--user string
The name of the kubeconfig user to use
--username string
Username for basic authentication to the API server
--version version[=true]
--version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the
reported version
--warnings-as-errors
Treat warnings received from the server as errors and exit with a non-zero exit code
See Also
kubectl - kubectl controls the Kubernetes cluster manager
kubectl get
Synopsis
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the
list using a label selector and the --selector flag. If the desired resource type is namespaced you
will only see results in your current namespace unless you pass --all-namespaces.
By specifying the output as 'template' and providing a Go template as the value of the --
template flag, you can filter the attributes of the fetched resources.
Use "kubectl api-resources" for a complete list of supported resources.
kub | 6,750 |
ectl get [(-o|--output=)json|yaml|name|go-template|go-template-file|template|templatefile|
jsonpath|jsonpath-as-json|jsonpath-file|custom-columns|custom-columns-file|wide]
(TYPE[.VERSION][.GROUP] [NAME | -l label] | TYPE[.VERSION][.GROUP]/NAME ...) [flags]
Examples
# List all pods in ps output format
kubectl get pods
# List all pods in ps output format with more information (such as node name)
kubectl get pods -o wide
# List a single replication controller with specified NAME in ps output format | 6,751 |
kubectl get replicationcontroller web
# List deployments in JSON output format, in the "v1" version of the "apps" API group
kubectl get deployments.v1.apps -o json
# List a single pod in JSON output format
kubectl get -o json pod web-pod-13je7
# List a pod identified by type and name specified in "pod.yaml" in JSON output format
kubectl get -f pod.yaml -o json
# List resources from a directory with kustomization.yaml - e.g. dir/kustomization.yaml
kubectl get -k dir/
# Return only the phase value of the specified pod
kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}
# List resource information in custom columns
kubectl get pod test-pod -o custom-
columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image
# List all replication controllers and services together in ps output format
kubectl get rc,services
# List one or more resources by their type and names
kubectl get rc/web service/frontend pods | 6,752 |
/web-pod-13je7
# List the 'status' subresource for a single pod
kubectl get pod web-pod-13je7 --subresource status
Options
-A, --all-namespaces
If present, list the requested object(s) across all namespaces. Namespace in current context is
ignored even if specified with --namespace.
--allow-missing-template-keys Default: true
If true, ignore any errors in templates when a field or map key is missing in the template. Only
applies to golang and jsonpath output formats.
--chunk-size int Default: 500
Return large lists in chunks rather than all at once. Pass 0 to disable. This flag is beta and may
change in the future.
--field-selector strin | 6,753 |
Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector
key1=value1,key2=value2). The server only supports a limited number of field queries per
type.
-f, --filename strings
Filename, directory, or URL to files identifying the resource to get from a server.
-h, --help
help for get
--ignore-not-found
If the requested object does not exist the command will return exit code 0.
-k, --kustomize string
Process the kustomization directory. This flag can't be used together with -f or -R.
-L, --label-columns strings
Accepts a comma separated list of labels that are going to be presented as columns. Names are
case-sensitive. You can also use multiple flag options like -L label1 -L label2...
--no-headers
When using the default or custom-column output format, don't print headers (default print
headers).
-o, --output string
Output format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile,
jsonpath, jsonpath-as-json, jsonpath-file, cust | 6,754 |
om-columns, custom-columns-file, wide). See
custom columns [https://kubernetes.io/docs/reference/kubectl/#custom-columns], golang
template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [https://
kubernetes.io/docs/reference/kubectl/jsonpath/].
--output-watch-events
Output watch event objects when --watch or --watch-only is used. Existing objects are output
as initial ADDED events.
--raw string
Raw URI to request from the server. Uses the transport specified by the kubeconfig file.
-R, --recursiv | 6,755 |
Process the directory used in -f, --filename recursively. Useful when you want to manage
related manifests organized within the same directory.
-l, --selector string
Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2).
Matching objects must satisfy all of the specified label constraints.
--server-print Default: true
If true, have the server return the appropriate table output. Supports extension APIs and
CRDs.
--show-kind
If present, list the resource type for the requested object(s).
--show-labels
When printing, show all labels as the last column (default hide labels column)
--show-managed-fields
If true, keep the managedFields when printing objects in JSON or YAML format.
--sort-by string
If non-empty, sort list types using this field specification. The field specification is expressed as
a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this
JSONPath expression must be an integer or a strin | 6,756 |
g.
--subresource string
If specified, gets the subresource of the requested object. Must be one of [status scale]. This
flag is beta and may change in the future.
--template string
Template string or path to template file to use when -o=go-template, -o=go-template-file. The
template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
-w, --watch
After listing/getting the requested object, watch for changes.
--watch-only
Watch for changes to the requested object(s), without listing/getting first.
--as strin | 6,757 |
Username to impersonate for the operation. User could be a regular user or a service account
in a namespace.
--as-group strings
Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--as-uid string
UID to impersonate for the operation.
--azure-container-registry-config string
Path to the file containing Azure container registry configuration information.
--cache-dir string Default: "$HOME/.kube/cache"
Default cache directory
--certificate-authority string
Path to a cert file for the certificate authority
--client-certificate string
Path to a client certificate file for TLS
--client-key string
Path to a client key file for TLS
--cloud-provider-gce-l7lb-src-cidrs cidrs Default: 130.211.0.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L7 LB traffic proxy & health checks
--cloud-provider-gce-lb-src-cidrs cidrs Default:
130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L4 LB traffic proxy & | 6,758 |
health checks
--cluster string
The name of the kubeconfig cluster to use
--context string
The name of the kubeconfig context to use
--default-not-ready-toleration-seconds int Default: 30 | 6,759 |
Indicates the tolerationSeconds of the toleration for notReady:NoExecute that is added by
default to every pod that does not already have such a toleration.
--default-unreachable-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for unreachable:NoExecute that is added by
default to every pod that does not already have such a toleration.
--disable-compression
If true, opt-out of response compression for all requests to the server
--insecure-skip-tls-verify
If true, the server's certificate will not be checked for validity. This will make your HTTPS
connections insecure
--kubeconfig string
Path to the kubeconfig file to use for CLI requests.
--match-server-version
Require server version to match client version
-n, --namespace string
If present, the namespace scope for this CLI request
--password string
Password for basic authentication to the API server
--profile string Default: "none"
Name of profile to capture. One of (none|cpu|heap|goroutine | 6,760 |
|threadcreate|block|mutex)
--profile-output string Default: "profile.pprof"
Name of the file to write the profile to
--request-timeout string Default: "0"
The length of time to wait before giving up on a single server request. Non-zero values should
contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout
requests.
-s, --server string
The address and port of the Kubernetes API serve | 6,761 |
--storage-driver-buffer-duration duration Default: 1m0s
Writes in the storage driver will be buffered for this duration, and committed to the non
memory backends as a single transaction
--storage-driver-db string Default: "cadvisor"
database name
--storage-driver-host string Default: "localhost:8086"
database host:port
--storage-driver-password string Default: "root"
database password
--storage-driver-secure
use secure connection with database
--storage-driver-table string Default: "stats"
table name
--storage-driver-user string Default: "root"
database username
--tls-server-name string
Server name to use for server certificate validation. If it is not provided, the hostname used to
contact the server is used
--token string
Bearer token for authentication to the API server
--user string
The name of the kubeconfig user to use
--username string
Username for basic authentication to the API server
--version version[=true]
--version, --version=raw prints version info | 6,762 |
rmation and quits; --version=vX.Y.Z... sets the
reported version
--warnings-as-error | 6,763 |
Treat warnings received from the server as errors and exit with a non-zero exit code
See Also
kubectl - kubectl controls the Kubernetes cluster manager
kubectl kustomize
Synopsis
Build a set of KRM resources using a 'kustomization.yaml' file. The DIR argument must be a
path to a directory containing 'kustomization.yaml', or a git repository URL with a path suffix
specifying same with respect to the repository root. If DIR is omitted, '.' is assumed.
kubectl kustomize DIR [flags]
Examples
# Build the current working directory
kubectl kustomize
# Build some shared configuration directory
kubectl kustomize /home/config/production
# Build from github
kubectl kustomize https://github.com/kubernetes-sigs/kustomize.git/examples/helloWorld?
ref=v1.0.6
Options
--as-current-user
use the uid and gid of the command executor to run the function in the container
--enable-alpha-plugins
enable kustomize plugins
--enable-helm
Enable use of the Helm chart inflator generator.
-e, --env | 6,764 |
strings
a list of environment variables to be used by functions | 6,765 |
--helm-command string Default: "helm"
helm command (path to executable)
-h, --help
help for kustomize
--load-restrictor string Default: "LoadRestrictionsRootOnly"
if set to 'LoadRestrictionsNone', local kustomizations may load files from outside their root.
This does, however, break the relocatability of the kustomization.
--mount strings
a list of storage options read from the filesystem
--network
enable network access for functions that declare it
--network-name string Default: "bridge"
the docker network to run the container in
-o, --output string
If specified, write output to this path.
--as string
Username to impersonate for the operation. User could be a regular user or a service account
in a namespace.
--as-group strings
Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--as-uid string
UID to impersonate for the operation.
--azure-container-registry-config string
Path to the file containing Azure container registry configur | 6,766 |
ation information.
--cache-dir string Default: "$HOME/.kube/cache"
Default cache director | 6,767 |
--certificate-authority string
Path to a cert file for the certificate authority
--client-certificate string
Path to a client certificate file for TLS
--client-key string
Path to a client key file for TLS
--cloud-provider-gce-l7lb-src-cidrs cidrs Default: 130.211.0.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L7 LB traffic proxy & health checks
--cloud-provider-gce-lb-src-cidrs cidrs Default:
130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L4 LB traffic proxy & health checks
--cluster string
The name of the kubeconfig cluster to use
--context string
The name of the kubeconfig context to use
--default-not-ready-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for notReady:NoExecute that is added by
default to every pod that does not already have such a toleration.
--default-unreachable-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for unreacha | 6,768 |
ble:NoExecute that is added by
default to every pod that does not already have such a toleration.
--disable-compression
If true, opt-out of response compression for all requests to the server
--insecure-skip-tls-verify
If true, the server's certificate will not be checked for validity. This will make your HTTPS
connections insecure
--kubeconfig string
Path to the kubeconfig file to use for CLI requests | 6,769 |
--match-server-version
Require server version to match client version
-n, --namespace string
If present, the namespace scope for this CLI request
--password string
Password for basic authentication to the API server
--profile string Default: "none"
Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex)
--profile-output string Default: "profile.pprof"
Name of the file to write the profile to
--request-timeout string Default: "0"
The length of time to wait before giving up on a single server request. Non-zero values should
contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout
requests.
-s, --server string
The address and port of the Kubernetes API server
--storage-driver-buffer-duration duration Default: 1m0s
Writes in the storage driver will be buffered for this duration, and committed to the non
memory backends as a single transaction
--storage-driver-db string Default: "cadvisor"
database name
--stor | 6,770 |
age-driver-host string Default: "localhost:8086"
database host:port
--storage-driver-password string Default: "root"
database password
--storage-driver-secure
use secure connection with database
--storage-driver-table string Default: "stats | 6,771 |
table name
--storage-driver-user string Default: "root"
database username
--tls-server-name string
Server name to use for server certificate validation. If it is not provided, the hostname used to
contact the server is used
--token string
Bearer token for authentication to the API server
--user string
The name of the kubeconfig user to use
--username string
Username for basic authentication to the API server
--version version[=true]
--version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the
reported version
--warnings-as-errors
Treat warnings received from the server as errors and exit with a non-zero exit code
See Also
kubectl - kubectl controls the Kubernetes cluster manager
kubectl label
Synopsis
Update the labels on a resource.
A label key and value must begin with a letter or number, and may contain letters,
numbers, hyphens, dots, and underscores, up to 63 characters each.
Optionally, the key can begin with a DNS subdomain prefix and a single | 6,772 |
'/', like
example.com/my-app.
If --overwrite is true, then existing labels can be overwritten, otherwise attempting to
overwrite a label will result in an error.•
•
•
| 6,773 |
If --resource-version is specified, then updates will use this resource version, otherwise
the existing resource-version will be used.
kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--
resource-version=version]
Examples
# Update pod 'foo' with the label 'unhealthy' and the value 'true'
kubectl label pods foo unhealthy=true
# Update pod 'foo' with the label 'status' and the value 'unhealthy', overwriting any existing
value
kubectl label --overwrite pods foo status=unhealthy
# Update all pods in the namespace
kubectl label pods --all status=unhealthy
# Update a pod identified by the type and name in "pod.json"
kubectl label -f pod.json status=unhealthy
# Update pod 'foo' only if the resource is unchanged from version 1
kubectl label pods foo status=unhealthy --resource-version=1
# Update pod 'foo' by removing a label named 'bar' if it exists
# Does not require the --overwrite flag
kubectl label pods foo bar-
Op | 6,774 |
tions
--all
Select all resources, in the namespace of the specified resource types
-A, --all-namespaces
If true, check the specified action in all namespaces.
--allow-missing-template-keys Default: true
If true, ignore any errors in templates when a field or map key is missing in the template. Only
applies to golang and jsonpath output formats.
--dry-run string[="unchanged"] Default: "none"
Must be "none", "server", or "client". If client strategy, only print the object that would be sent,
without sending it. If server strategy, submit server-side request without persisting the
resource.
--field-manager string Default: "kubectl-label" | 6,775 |
Name of the manager used to track field ownership.
--field-selector string
Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector
key1=value1,key2=value2). The server only supports a limited number of field queries per
type.
-f, --filename strings
Filename, directory, or URL to files identifying the resource to update the labels
-h, --help
help for label
-k, --kustomize string
Process the kustomization directory. This flag can't be used together with -f or -R.
--list
If true, display the labels for a given resource.
--local
If true, label will NOT contact api-server but run locally.
-o, --output string
Output format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile,
jsonpath, jsonpath-as-json, jsonpath-file).
--overwrite
If true, allow labels to be overwritten, otherwise reject label updates that overwrite existing
labels.
-R, --recursive
Process the directory used in -f, --filename recursively. Useful when you want to m | 6,776 |
anage
related manifests organized within the same directory.
--resource-version string
If non-empty, the labels update will only succeed if this is the current resource-version for the
object. Only valid when specifying a single resource.
-l, --selector strin | 6,777 |
Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2).
Matching objects must satisfy all of the specified label constraints.
--show-managed-fields
If true, keep the managedFields when printing objects in JSON or YAML format.
--template string
Template string or path to template file to use when -o=go-template, -o=go-template-file. The
template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
--as string
Username to impersonate for the operation. User could be a regular user or a service account
in a namespace.
--as-group strings
Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--as-uid string
UID to impersonate for the operation.
--azure-container-registry-config string
Path to the file containing Azure container registry configuration information.
--cache-dir string Default: "$HOME/.kube/cache"
Default cache directory
--certificate-authority string
Path to a ce | 6,778 |
rt file for the certificate authority
--client-certificate string
Path to a client certificate file for TLS
--client-key string
Path to a client key file for TLS
--cloud-provider-gce-l7lb-src-cidrs cidrs Default: 130.211.0.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L7 LB traffic proxy & health check | 6,779 |
--cloud-provider-gce-lb-src-cidrs cidrs Default:
130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L4 LB traffic proxy & health checks
--cluster string
The name of the kubeconfig cluster to use
--context string
The name of the kubeconfig context to use
--default-not-ready-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for notReady:NoExecute that is added by
default to every pod that does not already have such a toleration.
--default-unreachable-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for unreachable:NoExecute that is added by
default to every pod that does not already have such a toleration.
--disable-compression
If true, opt-out of response compression for all requests to the server
--insecure-skip-tls-verify
If true, the server's certificate will not be checked for validity. This will make your HTTPS
connections insecure
--kubeconfig string
Path | 6,780 |
to the kubeconfig file to use for CLI requests.
--match-server-version
Require server version to match client version
-n, --namespace string
If present, the namespace scope for this CLI request
--password string
Password for basic authentication to the API server
--profile string Default: "none"
Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex | 6,781 |
--profile-output string Default: "profile.pprof"
Name of the file to write the profile to
--request-timeout string Default: "0"
The length of time to wait before giving up on a single server request. Non-zero values should
contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout
requests.
-s, --server string
The address and port of the Kubernetes API server
--storage-driver-buffer-duration duration Default: 1m0s
Writes in the storage driver will be buffered for this duration, and committed to the non
memory backends as a single transaction
--storage-driver-db string Default: "cadvisor"
database name
--storage-driver-host string Default: "localhost:8086"
database host:port
--storage-driver-password string Default: "root"
database password
--storage-driver-secure
use secure connection with database
--storage-driver-table string Default: "stats"
table name
--storage-driver-user string Default: "root"
database username
--tls-s | 6,782 |
erver-name string
Server name to use for server certificate validation. If it is not provided, the hostname used to
contact the server is used
--token string
Bearer token for authentication to the API serve | 6,783 |
--user string
The name of the kubeconfig user to use
--username string
Username for basic authentication to the API server
--version version[=true]
--version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the
reported version
--warnings-as-errors
Treat warnings received from the server as errors and exit with a non-zero exit code
See Also
kubectl - kubectl controls the Kubernetes cluster manager
kubectl logs
Synopsis
Print the logs for a container in a pod or specified resource. If the pod has only one container,
the container name is optional.
kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]
Examples
# Return snapshot logs from pod nginx with only one container
kubectl logs nginx
# Return snapshot logs from pod nginx with multi containers
kubectl logs nginx --all-containers=true
# Return snapshot logs from all containers in pods defined by label app=nginx
kubectl logs -l app=nginx --all-containers=true
# Return snapshot of | 6,784 |
previous terminated ruby container logs from pod web-1
kubectl logs -p -c ruby web-1
# Begin streaming the logs of the ruby container in pod web-1
kubectl logs -f -c ruby web-1
# Begin streaming the logs from all containers in pods defined by label app=nginx | 6,785 |
kubectl logs -f -l app=nginx --all-containers=true
# Display only the most recent 20 lines of output in pod nginx
kubectl logs --tail=20 nginx
# Show all logs from pod nginx written in the last hour
kubectl logs --since=1h nginx
# Show logs from a kubelet with an expired serving certificate
kubectl logs --insecure-skip-tls-verify-backend nginx
# Return snapshot logs from first container of a job named hello
kubectl logs job/hello
# Return snapshot logs from container nginx-1 of a deployment named nginx
kubectl logs deployment/nginx -c nginx-1
Options
--all-containers
Get all containers' logs in the pod(s).
-c, --container string
Print the logs of this container
-f, --follow
Specify if the logs should be streamed.
-h, --help
help for logs
--ignore-errors
If watching / following pod logs, allow for any errors that occur to be non-fatal
--insecure-skip-tls-verify-backend
Skip verifying the identity of the kubelet that logs are requested from. In theory, | 6,786 |
an attacker
could provide invalid log content back. You might want to use this if your kubelet serving
certificates have expired.
--limit-bytes int
Maximum bytes of logs to return. Defaults to no limit.
--max-log-requests int Default: | 6,787 |
Specify maximum number of concurrent logs to follow when using by a selector. Defaults to 5.
--pod-running-timeout duration Default: 20s
The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is
running
--prefix
Prefix each log line with the log source (pod name and container name)
-p, --previous
If true, print the logs for the previous instance of the container in a pod if it exists.
-l, --selector string
Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2).
Matching objects must satisfy all of the specified label constraints.
--since duration
Only return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to all logs. Only
one of since-time / since may be used.
--since-time string
Only return logs after a specific date (RFC3339). Defaults to all logs. Only one of since-time /
since may be used.
--tail int Default: -1
Lines of recent log file to display. Defaults to -1 with no selecto | 6,788 |
r, showing all log lines
otherwise 10, if a selector is provided.
--timestamps
Include timestamps on each line in the log output
--as string
Username to impersonate for the operation. User could be a regular user or a service account
in a namespace.
--as-group strings
Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--as-uid strin | 6,789 |
UID to impersonate for the operation.
--azure-container-registry-config string
Path to the file containing Azure container registry configuration information.
--cache-dir string Default: "$HOME/.kube/cache"
Default cache directory
--certificate-authority string
Path to a cert file for the certificate authority
--client-certificate string
Path to a client certificate file for TLS
--client-key string
Path to a client key file for TLS
--cloud-provider-gce-l7lb-src-cidrs cidrs Default: 130.211.0.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L7 LB traffic proxy & health checks
--cloud-provider-gce-lb-src-cidrs cidrs Default:
130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L4 LB traffic proxy & health checks
--cluster string
The name of the kubeconfig cluster to use
--context string
The name of the kubeconfig context to use
--default-not-ready-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the tolerat | 6,790 |
ion for notReady:NoExecute that is added by
default to every pod that does not already have such a toleration.
--default-unreachable-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for unreachable:NoExecute that is added by
default to every pod that does not already have such a toleration.
--disable-compressio | 6,791 |
If true, opt-out of response compression for all requests to the server
--insecure-skip-tls-verify
If true, the server's certificate will not be checked for validity. This will make your HTTPS
connections insecure
--kubeconfig string
Path to the kubeconfig file to use for CLI requests.
--match-server-version
Require server version to match client version
-n, --namespace string
If present, the namespace scope for this CLI request
--password string
Password for basic authentication to the API server
--profile string Default: "none"
Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex)
--profile-output string Default: "profile.pprof"
Name of the file to write the profile to
--request-timeout string Default: "0"
The length of time to wait before giving up on a single server request. Non-zero values should
contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout
requests.
-s, --server string
The address and port of | 6,792 |
the Kubernetes API server
--storage-driver-buffer-duration duration Default: 1m0s
Writes in the storage driver will be buffered for this duration, and committed to the non
memory backends as a single transaction
--storage-driver-db string Default: "cadvisor"
database name
--storage-driver-host string Default: "localhost:8086 | 6,793 |
database host:port
--storage-driver-password string Default: "root"
database password
--storage-driver-secure
use secure connection with database
--storage-driver-table string Default: "stats"
table name
--storage-driver-user string Default: "root"
database username
--tls-server-name string
Server name to use for server certificate validation. If it is not provided, the hostname used to
contact the server is used
--token string
Bearer token for authentication to the API server
--user string
The name of the kubeconfig user to use
--username string
Username for basic authentication to the API server
--version version[=true]
--version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the
reported version
--warnings-as-errors
Treat warnings received from the server as errors and exit with a non-zero exit code
See Also
kubectl - kubectl controls the Kubernetes cluster manager • | 6,794 |
kubectl options
Synopsis
Print the list of flags inherited by all commands
kubectl options [flags]
Examples
# Print flags inherited by all commands
kubectl options
Options
-h, --help
help for options
--as string
Username to impersonate for the operation. User could be a regular user or a service account
in a namespace.
--as-group strings
Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--as-uid string
UID to impersonate for the operation.
--azure-container-registry-config string
Path to the file containing Azure container registry configuration information.
--cache-dir string Default: "$HOME/.kube/cache"
Default cache directory
--certificate-authority string
Path to a cert file for the certificate authority
--client-certificate string
Path to a client certificate file for TLS | 6,795 |
--client-key string
Path to a client key file for TLS
--cloud-provider-gce-l7lb-src-cidrs cidrs Default: 130.211.0.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L7 LB traffic proxy & health checks
--cloud-provider-gce-lb-src-cidrs cidrs Default:
130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
CIDRs opened in GCE firewall for L4 LB traffic proxy & health checks
--cluster string
The name of the kubeconfig cluster to use
--context string
The name of the kubeconfig context to use
--default-not-ready-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for notReady:NoExecute that is added by
default to every pod that does not already have such a toleration.
--default-unreachable-toleration-seconds int Default: 300
Indicates the tolerationSeconds of the toleration for unreachable:NoExecute that is added by
default to every pod that does not already have such a toleration.
--disable-compression
If true, opt-out of response co | 6,796 |
mpression for all requests to the server
--insecure-skip-tls-verify
If true, the server's certificate will not be checked for validity. This will make your HTTPS
connections insecure
--kubeconfig string
Path to the kubeconfig file to use for CLI requests.
--match-server-version
Require server version to match client version
-n, --namespace string
If present, the namespace scope for this CLI reques | 6,797 |
--password string
Password for basic authentication to the API server
--profile string Default: "none"
Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex)
--profile-output string Default: "profile.pprof"
Name of the file to write the profile to
--request-timeout string Default: "0"
The length of time to wait before giving up on a single server request. Non-zero values should
contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout
requests.
-s, --server string
The address and port of the Kubernetes API server
--storage-driver-buffer-duration duration Default: 1m0s
Writes in the storage driver will be buffered for this duration, and committed to the non
memory backends as a single transaction
--storage-driver-db string Default: "cadvisor"
database name
--storage-driver-host string Default: "localhost:8086"
database host:port
--storage-driver-password string Default: "root"
database password
--s | 6,798 |
torage-driver-secure
use secure connection with database
--storage-driver-table string Default: "stats"
table name
--storage-driver-user string Default: "root"
database username
--tls-server-name strin | 6,799 |