text
stringlengths 1
1k
| id
int64 0
8.58k
|
---|---|
multiple replication controllers
Deleting resources
kubectl delete -f ./pod.json # Delete a pod using the type and name
specified in pod.json
kubectl delete pod unwanted --now # Delete a pod with no grace period
kubectl delete pod,service baz foo # Delete pods and services with same
names "baz" and "foo"
kubectl delete pods,services -l name =myLabel # Delete pods and services with
label name=myLabel
kubectl -n my-ns delete pod,svc --all # Delete all pods and services in
namespace my-ns,
# Delete all pods matching the awk pattern1 or pattern2
kubectl get pods -n mynamespace --no-headers =true | awk '/pattern1|pattern2/{print $1}' |
xargs kubectl delete -n mynamespace pod
Interacting with running Pods
kubectl logs my-pod # dump pod logs (stdout)
kubectl logs -l name =myLabel # d | 6,100 |
ump pod logs, with label name=myLabel
(stdout)
kubectl logs my-pod --previous # dump pod logs (stdout) for a previous
instantiation of a container
kubectl logs my-pod -c my-container # dump pod container logs (stdout, multi-
container case)
kubectl logs -l name =myLabel -c my-container # dump pod container logs, with label
name=myLabel (stdout)
kubectl logs my-pod -c my-container --previous # dump pod container logs (stdout, multi | 6,101 |
container case) for a previous instantiation of a container
kubectl logs -f my-pod # stream pod logs (stdout)
kubectl logs -f my-pod -c my-container # stream pod container logs (stdout, multi-
container case)
kubectl logs -f -l name =myLabel --all-containers # stream all pods logs with label
name=myLabel (stdout)
kubectl run -i --tty busybox --image =busybox:1.28 -- sh # Run pod as interactive shell
kubectl run nginx --image =nginx -n mynamespace # Start a single instance of nginx pod in
the namespace of mynamespace
kubectl run nginx --image =nginx --dry-run =client -o yaml > pod.yaml
# Generate spec for running pod nginx and write it into a file
called pod.yaml
kubectl attach my-pod -i # Attach to Running Container
kubectl port-forward my-pod 5000:6000
# Listen on port 5000 on the local machine and forward to port 6000 on my-pod
kubectl ex | 6,102 |
ec my-pod -- ls / # Run command in existing pod (1 container case)
kubectl exec --stdin --tty my-pod -- /bin/sh # Interactive shell access to a running pod (1
container case)
kubectl exec my-pod -c my-container -- ls / # Run command in existing pod (multi-
container case)
kubectl top pod POD_NAME --containers # Show metrics for a given pod and its
containers
kubectl top pod POD_NAME --sort-by =cpu # Show metrics for a given pod and sort it
by 'cpu' or 'memory'
Copying files and directories to and from containers
kubectl cp /tmp/foo_dir my-pod:/tmp/bar_dir # Copy /tmp/foo_dir local directory to /
tmp/bar_dir in a remote pod in the current namespace
kubectl cp /tmp/foo my-pod:/tmp/bar -c my-container # Copy /tmp/foo local file to /tmp/bar
in a remote pod in a specific container
kubectl cp /tmp/foo my-namespace/my-pod:/tmp/bar # Copy /tmp/foo local file to /tmp/bar
in a remote pod in namespace my-na | 6,103 |
mespace
kubectl cp my-namespace/my-pod:/tmp/foo /tmp/bar # Copy /tmp/foo from a remote pod
to /tmp/bar locally
Note: kubectl cp requires that the 'tar' binary is present in your container image. If 'tar' is not
present, kubectl cp will fail. For advanced use cases, such as symlinks, wildcard expansion or
file mode preservation consider using kubectl exec .
tar cf - /tmp/foo | kubectl exec -i -n my-namespace my-pod -- tar xf - -C /tmp/bar #
Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace my-namespace
kubectl exec -n my-namespace my-pod -- tar cf - /tmp/foo | tar xf - -C /tmp/bar # Copy /tmp/
foo from a remote pod to /tmp/bar locally
Interacting with Deployments and Services
kubectl logs deploy/my-deployment # dump Pod logs for a Deployment (single-
container case)
kubectl logs deploy/my-deployment -c my-container # dump Pod logs for a Deployment
(multi-container case | 6,104 |
kubectl port-forward svc/my-service 5000 # listen on local port 5000 and forward to
port 5000 on Service backend
kubectl port-forward svc/my-service 5000:my-service-port # listen on local port 5000 and
forward to Service target port with name <my-service-port>
kubectl port-forward deploy/my-deployment 5000:6000 # listen on local port 5000 and
forward to port 6000 on a Pod created by <my-deployment>
kubectl exec deploy/my-deployment -- ls # run command in first Pod and first
container in Deployment (single- or multi-container cases)
Interacting with Nodes and cluster
kubectl cordon my-node # Mark my-node as unschedulable
kubectl drain my-node # Drain my-node in preparation for
maintenance
kubectl uncordon my-node # Mark my-node as schedulable
kubectl top node my-node | 6,105 |
# Show metrics for a given node
kubectl cluster-info # Display addresses of the master and
services
kubectl cluster-info dump # Dump current cluster state to stdout
kubectl cluster-info dump --output-directory =/path/to/cluster-state # Dump current cluster
state to /path/to/cluster-state
# View existing taints on which exist on current nodes.
kubectl get nodes -o ='custom-
columns=NodeName:.metadata.name,TaintKey:.spec.taints[*].key,TaintValue:.spec.taints[*].valu
e,TaintEffect:.spec.taints[*].effect'
# If a taint with that key and effect already exists, its value is replaced as specified.
kubectl taint nodes foo dedicated =special-user:NoSchedule
Resource types
List all supported resource types along with their shortnames, API group , whether they are
namespaced , and kind:
kubectl api-resources
Other operations for exploring API resources:
kubectl api-resources --namespaced =tru | 6,106 |
e # All namespaced resources
kubectl api-resources --namespaced =false # All non-namespaced resources
kubectl api-resources -o name # All resources with simple output (only the resource
name)
kubectl api-resources -o wide # All resources with expanded (aka "wide") output
kubectl api-resources --verbs =list,get
# All resources that support the "list" and "get" request verbs
kubectl api-resources --api-group =extensions # All resources in the "extensions" API grou | 6,107 |
Formatting output
To output details to your terminal window in a specific format, add the -o (or --output ) flag to a
supported kubectl command.
Output format Description
-o=custom-columns=<spec> Print a table using a comma separated list of custom columns
-o=custom-columns-
file=<filename>Print a table using the custom columns template in the
<filename> file
-o=go-template=<template> Print the fields defined in a golang template
-o=go-template-
file=<filename>Print the fields defined by the golang template in the
<filename> file
-o=json Output a JSON formatted API object
-o=jsonpath=<template> Print the fields defined in a jsonpath expression
-o=jsonpath-file=<filename>Print the fields defined by the jsonpath expression in the
<filename> file
-o=name Print only the resource name and nothing else
-o=wideOutput in the plain-text format with any additional
information, and for pods, the node name is included
-o=yaml Output a YAML formatted API object
Examples using -o=custom-co | 6,108 |
lumns :
# All images running in a cluster
kubectl get pods -A -o =custom-columns ='DATA:spec.containers[*].image'
# All images running in namespace: default, grouped by Pod
kubectl get pods --namespace default --output =custom-columns ="NAME:.metadata.name,IMAG
E:.spec.containers[*].image"
# All images excluding "registry.k8s.io/coredns:1.6.2"
kubectl get pods -A -o =custom-columns ='DATA:spec.containers[?(@.image!="registry.k8s.io/
coredns:1.6.2")].image'
# All fields under metadata regardless of name
kubectl get pods -A -o =custom-columns ='DATA:metadata.*'
More examples in the kubectl reference documentation .
Kubectl output verbosity and debugging
Kubectl verbosity is controlled with the -v or --v flags followed by an integer representing the
log level. General Kubernetes logging conventions and the associated log levels are described
here.
Verbosity Description
--v=0 Generally useful for this to always be visible to a cluster operator.
--v=1 A reasonable default log level if yo | 6,109 |
u don't want verbosity.
--v= | 6,110 |
Verbosity Description
Useful steady state information about the service and important log messages that
may correlate to significant changes in the system. This is the recommended default
log level for most systems.
--v=3 Extended information about changes.
--v=4 Debug level verbosity.
--v=5 Trace level verbosity.
--v=6 Display requested resources.
--v=7 Display HTTP request headers.
--v=8 Display HTTP request contents.
--v=9 Display HTTP request contents without truncation of contents.
What's next
Read the kubectl overview and learn about JsonPath .
See kubectl options.
Also read kubectl Usage Conventions to understand how to use kubectl in reusable
scripts.
See more community kubectl cheatsheets .
kubectl reference
kubectl
kubectl annotate
kubectl api-resources
kubectl api-versions
kubectl apply
kubectl attach
kubectl auth
kubectl autoscale
kubectl certificate
kubectl cluster-info
kubectl completion
kubectl config•
•
•
• | 6,111 |
kubectl cordon
kubectl cp
kubectl create
kubectl debug
kubectl delete
kubectl describe
kubectl diff
kubectl drain
kubectl edit
kubectl events
kubectl exec
kubectl explain
kubectl expose
kubectl get
kubectl kustomize
kubectl label
kubectl logs
kubectl options
kubectl patch
kubectl plugin
kubectl port-forward
kubectl proxy
kubectl replace
kubectl rollout
kubectl run
kubectl scale | 6,112 |
kubectl set
kubectl taint
kubectl top
kubectl uncordon
kubectl version
kubectl wait
kubectl
Synopsis
kubectl controls the Kubernetes cluster manager.
Find more information at: https://kubernetes.io/docs/reference/kubectl/
kubectl [flags]
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 | 6,113 |
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
default to every pod that does not already have such a toleration.
--disable-c | 6,114 |
ompression
If true, opt-out of response compression for all requests to the server
-h, --help
help for kubectl
--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,115 |
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,116 |
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,117 |
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 annotate - Update the annotations on a resource
kubectl api-resources - Print the supported API resources on the server
kubectl api-versions - Print the supported API versions on the server, in the form of
"group/version"
kubectl apply - Apply a configuration to a resource by file name or stdin
kubectl attach - Attach to | 6,118 |
a running container
kubectl auth - Inspect authorization
kubectl autoscale - Auto-scale a deployment, replica set, stateful set, or replication
controller
kubectl certificate - Modify certificate resources
kubectl cluster-info - Display cluster information
kubectl completion - Output shell completion code for the specified shell (bash, zsh, fish,
or powershell)
kubectl config - Modify kubeconfig files
kubectl cordon - Mark node as unschedulable
kubectl cp - Copy files and directories to and from containers•
•
•
•
•
•
•
•
•
•
•
•
| 6,119 |
kubectl create - Create a resource from a file or from stdin
kubectl debug - Create debugging sessions for troubleshooting workloads and nodes
kubectl delete - Delete resources by file names, stdin, resources and names, or by
resources and label selector
kubectl describe - Show details of a specific resource or group of resources
kubectl diff - Diff the live version against a would-be applied version
kubectl drain - Drain node in preparation for maintenance
kubectl edit - Edit a resource on the server
kubectl events - List events
kubectl exec - Execute a command in a container
kubectl explain - Get documentation for a resource
kubectl expose - Take a replication controller, service, deployment or pod and expose it as
a new Kubernetes service
kubectl get - Display one or many resources
kubectl kustomize - Build a kustomization target from a directory or URL
kubectl label - Update the labels on a resource
kubectl logs - Print the logs for a container in a pod
kubectl optio | 6,120 |
ns - Print the list of flags inherited by all commands
kubectl patch - Update fields of a resource
kubectl plugin - Provides utilities for interacting with plugins
kubectl port-forward - Forward one or more local ports to a pod
kubectl proxy - Run a proxy to the Kubernetes API server
kubectl replace - Replace a resource by file name or stdin
kubectl rollout - Manage the rollout of a resource
kubectl run - Run a particular image on the cluster
kubectl scale - Set a new size for a deployment, replica set, or replication controller
kubectl set - Set specific features on objects
kubectl taint - Update the taints on one or more nodes
kubectl top - Display resource (CPU/memory) usage
kubectl uncordon - Mark node as schedulable
kubectl version - Print the client and server version information
kubectl wait - Experimental: Wait for a specific condition on one or many resources
kubectl annotate
Synopsis
Update the annotations on one or more resources.
All Kubernetes objects suppor | 6,121 |
t the ability to store additional data with the object as
annotations. Annotations are key/value pairs that can be larger than labels and include
arbitrary string values such as structured JSON. Tools and system extensions may use
annotations to store their own data.
Attempting to set an annotation that already exists will fail unless --overwrite is set. If --
resource-version is specified and does not match the current resource version on the server the
command will fail.
Use "kubectl api-resources" for a complete list of supported resources.•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
| 6,122 |
kubectl annotate [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N
[--resource-version=version]
Examples
# Update pod 'foo' with the annotation 'description' and the value 'my frontend'
# If the same annotation is set multiple times, only the last value will be applied
kubectl annotate pods foo description='my frontend'
# Update a pod identified by type and name in "pod.json"
kubectl annotate -f pod.json description='my frontend'
# Update pod 'foo' with the annotation 'description' and the value 'my frontend running nginx',
overwriting any existing value
kubectl annotate --overwrite pods foo description='my frontend running nginx'
# Update all pods in the namespace
kubectl annotate pods --all description='my frontend running nginx'
# Update pod 'foo' only if the resource is unchanged from version 1
kubectl annotate pods foo description='my frontend running nginx' --resource-version=1
# Update pod 'foo' by removing an annotation | 6,123 |
named 'description' if it exists
# Does not require the --overwrite flag
kubectl annotate pods foo description-
Options
--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-annotate"
Name of the manager used to track field ownership | 6,124 |
--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 annotation
-h, --help
help for annotate
-k, --kustomize string
Process the kustomization directory. This flag can't be used together with -f or -R.
--list
If true, display the annotations for a given resource.
--local
If true, annotation 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 annotations to be overwritten, otherwise reject annotation updates that
overwrite existing annotations.
-R, --recursive
Process the directory used in -f, --filename recursively. Useful when you want to manage
related manif | 6,125 |
ests organized within the same directory.
--resource-version string
If non-empty, the annotation update will only succeed if this is the current resource-version
for the object. Only valid when specifying a single resource.
-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.
--show-managed-field | 6,126 |
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 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-c | 6,127 |
idrs 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 strin | 6,128 |
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 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
--pas | 6,129 |
sword 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 | 6,130 |
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-server-name string
Server name to use for server certificate validation. If it is not provided, the hostname used to
contact the server i | 6,131 |
s used
--token string
Bearer token for authentication to the API server
--user string
The name of the kubeconfig user to use
--username strin | 6,132 |
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 api-resources
Synopsis
Print the supported API resources on the server.
kubectl api-resources [flags]
Examples
# Print the supported API resources
kubectl api-resources
# Print the supported API resources with more information
kubectl api-resources -o wide
# Print the supported API resources sorted by a column
kubectl api-resources --sort-by=name
# Print the supported namespaced resources
kubectl api-resources --namespaced=true
# Print the supported non-namespaced resources
kubectl api-resources --namespaced=false
# Print the supported API resources with a specific APIGroup
kubectl api- | 6,133 |
resources --api-group=rbac.authorization.k8s.io
Options
--api-group string | 6,134 |
Limit to resources in the specified API group.
--cached
Use the cached list of resources if available.
--categories strings
Limit to resources that belong to the specified categories.
-h, --help
help for api-resources
--namespaced Default: true
If false, non-namespaced resources will be returned, otherwise returning namespaced
resources by default.
--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: (wide, name).
--sort-by string
If non-empty, sort list of resources using specified field. The field can be either 'name' or 'kind'.
--verbs strings
Limit to resources that support the specified verbs.
--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. | 6,135 |
--azure-container-registry-config strin | 6,136 |
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 toleration for notReady:NoExecute that is added by
default to every pod that does not | 6,137 |
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-verif | 6,138 |
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 the Kubernetes API server
--storage-driver-buffer-duration duration Default: 1m0s
Writes in the | 6,139 |
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 | 6,140 |
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,141 |
kubectl api-versions
Synopsis
Print the supported API versions on the server, in the form of "group/version".
kubectl api-versions
Examples
# Print the supported API versions
kubectl api-versions
Options
-h, --help
help for api-versions
--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,142 |
--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,143 |
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,144 |
--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,145 |
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,146 |
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 apply
Synopsis
Apply a configuration to a resource by file name or stdin. The resource name must be specified.
This resource will be created if it doesn't exist yet. To use 'apply', always create the resource
initially with either 'apply' or 'create --save-config'.
JSON and YAML formats are accepted.
Alpha Disclaimer: the --prune functionality is not yet complete. Do n | 6,147 |
ot use unless you are
aware of what the current state is. See https://issues.k8s.io/34274 .
kubectl apply (-f FILENAME | -k DIRECTORY)
Examples
# Apply the configuration in pod.json to a pod
kubectl apply -f ./pod.json | 6,148 |
# Apply resources from a directory containing kustomization.yaml - e.g. dir/
kustomization.yaml
kubectl apply -k dir/
# Apply the JSON passed into stdin to a pod
cat pod.json | kubectl apply -f -
# Apply the configuration from all files that end with '.json'
kubectl apply -f '*.json'
# Note: --prune is still in Alpha
# Apply the configuration in manifest.yaml that matches label app=nginx and delete all other
resources that are not in the file and match label app=nginx
kubectl apply --prune -f manifest.yaml -l app=nginx
# Apply the configuration in manifest.yaml and delete all the other config maps that are not in
the file
kubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/v1/ConfigMap
Options
--all
Select all resources in the namespace of the specified resource types.
--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 jso | 6,149 |
npath output formats.
--cascade string[="background"] Default: "background"
Must be "background", "orphan", or "foreground". Selects the deletion cascading strategy for
the dependents (e.g. Pods created by a ReplicationController). Defaults to background.
--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-client-side-apply"
Name of the manager used to track field ownership.
-f, --filename strings
The files that contain the configurations to apply.
--forc | 6,150 |
If true, immediately remove resources from API and bypass graceful deletion. Note that
immediate deletion of some resources may result in inconsistency or data loss and requires
confirmation.
--force-conflicts
If true, server-side apply will force the changes against conflicts.
--grace-period int Default: -1
Period of time in seconds given to the resource to terminate gracefully. Ignored if negative. Set
to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion).
-h, --help
help for apply
-k, --kustomize string
Process a kustomization directory. This flag can't be used together with -f or -R.
--openapi-patch Default: true
If true, use openapi to calculate diff when the openapi presents and the resource can be found
in the openapi spec. Otherwise, fall back to use baked-in types.
-o, --output string
Output format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile,
jsonpath, jsonpath-as-json, jsonpath-file).
--overwrite | 6,151 |
Default: true
Automatically resolve conflicts between the modified and live configuration by using values
from the modified configuration
--prune
Automatically delete resource objects, that do not appear in the configs and are created by
either apply or create --save-config. Should be used with either -l or --all.
--prune-allowlist strings
Overwrite the default allowlist with <group/version/kind> for --prune
-R, --recursive
Process the directory used in -f, --filename recursively. Useful when you want to manage
related manifests organized within the same directory.
-l, --selector strin | 6,152 |
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-side
If true, apply runs in the server instead of the client.
--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].
--timeout duration
The length of time to wait before giving up on a delete, zero means determine a timeout from
the size of the object
--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 | 6,153 |
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.
--wait
If true, wait for resources to be gone before returning. This waits for finalizers.
--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 strin | 6,154 |
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 toleration for notReady:NoExecute that is added by
default to every pod that does not | 6,155 |
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-verif | 6,156 |
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 the Kubernetes API server
--storage-driver-buffer-duration duration Default: 1m0s
Writes in the | 6,157 |
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 | 6,158 |
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
kubectl apply edit-last-applied - Edit latest last-applied-configuration annotations of a
resource/object
kubectl apply set-last-applied - Set th | 6,159 |
e last-applied-configuration annotation on a live
object to match the contents of a file
kubectl apply view-last-applied - View the latest last-applied-configuration annotations
of a resource/object•
•
•
| 6,160 |
kubectl apply edit-last-applied
Synopsis
Edit the latest last-applied-configuration annotations of resources from the default editor.
The edit-last-applied command allows you to directly edit any API resource you can retrieve via
the command-line tools. It will open the editor defined by your KUBE_EDITOR, or EDITOR
environment variables, or fall back to 'vi' for Linux or 'notepad' for Windows. You can edit
multiple objects, although changes are applied one at a time. The command accepts file names
as well as command-line arguments, although the files you point to must be previously saved
versions of resources.
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 | 6,161 |
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 apply edit-last-applied (RESOURCE/NAME | -f FILENAME)
Examples
# Edit the last-applied-configuration annotations by type/name in YAML
kubectl apply edit-last-applied deployment/nginx
# Edit the last-applied-configuration annotations by file in JSON
kubectl apply edit-last-applied -f deploy.yaml -o json
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-client-side-apply"
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, --hel | 6,162 |
help for edit-last-applied
-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).
-R, --recursive
Process the directory used in -f, --filename recursively. Useful when you want to manage
related manifests organized within the same directory.
--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].
--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 | 6,163 |
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-endings
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 strin | 6,164 |
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,165 |
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,166 |
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,167 |
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,168 |
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 apply - Apply a configuration to a resource by file name or stdin • | 6,169 |
kubectl apply set-last-applied
Synopsis
Set the latest last-applied-configuration annotations by setting it to match the contents of a file.
This results in the last-applied-configuration being updated as though 'kubectl apply -f<file> '
was run, without updating any other parts of the object.
kubectl apply set-last-applied -f FILENAME
Examples
# Set the last-applied-configuration of a resource to match the contents of a file
kubectl apply set-last-applied -f deploy.yaml
# Execute set-last-applied against each configuration file in a directory
kubectl apply set-last-applied -f path/
# Set the last-applied-configuration of a resource to match the contents of a file; will create the
annotation if it does not already exist
kubectl apply set-last-applied -f deploy.yaml --create-annotation=true
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 jsonp | 6,170 |
ath output formats.
--create-annotation
Will create 'last-applied-configuration' annotations if current objects doesn't have one
--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.
-f, --filename strings
Filename, directory, or URL to files that contains the last-applied-configuration annotations
-h, --help
help for set-last-applied
-o, --output strin | 6,171 |
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=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 cert file for the certificate au | 6,172 |
thority
--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,173 |
--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,174 |
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,175 |
--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,176 |
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,177 |
--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 apply - Apply a configuration to a resource by file name or stdin
kubectl apply view-last-applied
Synopsis
View the latest last-applied-configuration annotations by type/name or file.
The default output will be printed to stdout in YAML format. You can use the -o option to
change the output format.
kubectl apply view-last-applied (TYPE [NAME | -l label] | TYPE/NAME | -f FILENAME)
Examples
# View the last-applied-configuration annotations by type/name in YAML
kubectl apply view-last-applied deployment/nginx
# View the last-applied-configuration annotations by file in JSON
kubectl apply view-last-applie | 6,178 |
d -f deploy.yaml -o json
Options
--all
Select all resources in the namespace of the specified resource types
-f, --filename strings | 6,179 |
Filename, directory, or URL to files that contains the last-applied-configuration annotations
-h, --help
help for view-last-applied
-k, --kustomize string
Process the kustomization directory. This flag can't be used together with -f or -R.
-o, --output string Default: "yaml"
Output format. Must be one of (yaml, json)
-R, --recursive
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.
--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 st | 6,180 |
ring
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 strin | 6,181 |
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
default to every pod that does not already have such a toleration.
--disable-c | 6,182 |
ompression
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 strin | 6,183 |
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 Default: "localhost:8086"
database host:port
--storage-driver-pass | 6,184 |
word 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 | 6,185 |
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 apply - Apply a configuration to a resource by file name or stdin
kubectl attach
Synopsis
Attach to a process that is already running inside an existing container.
kubectl attach (POD | TYPE/NAME) -c CONTAINER
Examples
# Get output from running pod mypod; use the 'kubectl.kubernetes.io/default-container'
annotation
# for selecting the container to be attached or the first contai | 6,186 |
ner in the pod will be chosen
kubectl attach mypod
| 6,187 |
# Get output from ruby-container from pod mypod
kubectl attach mypod -c ruby-container
# 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 attach mypod -c ruby-container -i -t
# Get output from the first pod of a replica set named nginx
kubectl attach rs/nginx
Options
-c, --container string
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
-h, --help
help for attach
--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 namespa | 6,188 |
ce.
--as-group strings
Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--as-uid strin | 6,189 |
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,190 |
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,191 |
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,192 |
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,193 |
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,194 |
kubectl auth
Synopsis
Inspect authorization.
kubectl auth [flags]
Options
-h, --help
help for auth
--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 | 6,195 |
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 compression for all requests to the server
--insecure-skip-tls-verify
If true, the server's certificate will not be checked for validity. Th | 6,196 |
is 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 | 6,197 |
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
--storage-driver-secure
use secure connection with database
--storage-driver-table string Default: "stats" | 6,198 |
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 strin | 6,199 |