text
stringlengths
1
1k
id
int64
0
8.58k
flag is useful when you want to perform kubectl apply on this object in the future. show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 true If true, use a schema to validate the input before sending it cronjob Create a cron job kubectl create cronjob my-job --image =busybox --schedule ="*/1 * * * *" Create a cron job with a command kubectl create cronjob my-job --image =busybox --schedule ="*/1 * * * *" -- date Create a cron job with the specified name. Usage $ kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...
7,800
Flags Name Shorthand Default Usage allow- missing- template-keystrueIf 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 noneMust 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-managerkubectl- createName of the manager used to track field ownership. image Image name to run. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. restart job's restart policy. supported values: OnFailure, Never save-config falseIf 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. schedule A schedule in the Cro
7,801
n format the job should be run with. show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 true If true, use a schema to validate the input before sending it deployment Create a deployment named my-dep that runs the busybox image kubectl create deployment my-dep --image=busybox Create a deployment with a command kubectl create deployment my-dep --image=busybox -- date Create a deployment named my-dep that runs the nginx image with 3 replicas kubectl create deployment my-dep --image =nginx --replicas =3 Create a deployment named my-dep that runs the busybox image and expose port 5701 kubectl create deployment my-dep --image =busybox --port =570
7,802
Create a deployment with the specified name. Usage $ kubectl create deployment NAME --image=image -- [COMMAND] [args...] Flags Name Shorthand Default Usage allow- missing- template-keystrueIf 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 noneMust 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-managerkubectl- createName of the manager used to track field ownership. image [] Image names to run. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. port -1 The port that this container exposes. replicas r 1 Number of replicas to create. Default is 1. save-config falseIf true, the configuration of current object will be saved in its annotation. O
7,803
therwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future. show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 true If true, use a schema to validate the input before sending it ingress Create a single ingress called 'simple' that directs requests to foo.com/bar to svc # svc1:8080 with a tls secret "my-cert" kubectl create ingress simple --rule ="foo.com/bar=svc1:8080,tls=my-cert" Create a catch all ingress of "/path" pointing to service svc:port and Ingress Class as "otheringress" kubectl create ingress catch -all -- class =otheringress --rule= "/path=svc:port
7,804
Create an ingress with two annotations: ingress.annotation1 and ingress.annotations2 kubectl create ingress annotated --class =default --rule ="foo.com/bar=svc:port" \ --annotation ingress. annotation1 =foo \ --annotation ingress. annotation2 =bla Create an ingress with the same host and multiple paths kubectl create ingress multipath --class =default \ --rule ="foo.com/=svc:port" \ --rule ="foo.com/admin/=svcadmin:portadmin" Create an ingress with multiple hosts and the pathType as Prefix kubectl create ingress ingress1 --class =default \ --rule ="foo.com/path*=svc:8080" \ --rule ="bar.com/admin*=svc2:http" Create an ingress with TLS enabled using the default ingress certificate and different path types kubectl create ingress ingtls --class =default \ --rule ="foo.com/=svc:https,tls" \ --rule ="foo.com/path/subpath*=othersvc:8080" Create an ingress with TLS enabled using a specific secret and pathType as Prefix kubectl create ingress ingsecret -- class =default \ --rule= "foo.com
7,805
/*=svc:8080,tls=secret1" Create an ingress with a default backend kubectl create ingress ingdefault --class =default \ --default-backend =defaultsvc:http \ --rule ="foo.com/*=svc:8080,tls=secret1" Create an ingress with the specified name. Usage $ kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]] Flags Name Shorthand Default Usage allow- missing- template- keystrueIf 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. annotation []Annotation to insert in the ingress object, in the format annotation=value class Ingress Class to be use
7,806
Name Shorthand Default Usage default- backendDefault service for backend, in format of svcname:port dry-run noneMust 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- managerkubectl- createName of the manager used to track field ownership. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. rule []Rule in format host/path=service:port [,tls=secretname ]. Paths containing the leading character '*' are considered pathType=Prefix. tls argument is optional. save-config falseIf 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- fieldsfalseIf true, keep the managedFields when pri
7,807
nting objects in JSON or YAML format. templateTemplate 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 true If true, use a schema to validate the input before sending it job Create a job kubectl create job my-job --image=busybox Create a job with a command kubectl create job my-job --image= busybox -- date Create a job from a cron job named "a-cronjob" kubectl create job test-job --from=cronjob/a-cronjob Create a job with the specified name. Usage $ kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...
7,808
Flags Name Shorthand Default Usage allow- missing- template-keystrueIf 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 noneMust 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-managerkubectl- createName of the manager used to track field ownership. fromThe name of the resource to create a Job from (only cronjob is supported). image Image name to run. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. save-config falseIf 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- f
7,809
ieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 true If true, use a schema to validate the input before sending it namespace Create a new namespace named my-namespace kubectl create namespace my- namespace Create a namespace with the specified name. Usage $ kubectl create namespace NAME [--dry-run=server|client|none] Flags Name Shorthand Default Usage allow- missing- template-keystrueIf 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
7,810
Name Shorthand Default Usage dry-run noneMust 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-managerkubectl- createName of the manager used to track field ownership. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. save-config falseIf 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- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 ]. valida
7,811
te true If true, use a schema to validate the input before sending it poddisruptionbudget Create a pod disruption budget named my-pdb that will select all pods with the app=rails label # and require at least one of them being available at any point in time kubectl create poddisruptionbudget my-pdb --selector =app=rails --min-available =1 Create a pod disruption budget named my-pdb that will select all pods with the app=nginx label # and require at least half of the pods selected to be available at any point in time kubectl create pdb my-pdb --selector =app=nginx --min-available =50% Create a pod disruption budget with the specified name, selector, and desired minimum available pods. Usage $ kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N [--dry- run=server|client|none] Flags Name Shorthand Default Usage allow-missing- template-keystru
7,812
Name Shorthand Default Usage 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 noneMust 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-managerkubectl- createName of the manager used to track field ownership. max- unavailableThe maximum number or percentage of unavailable pods this budget requires. min-availableThe minimum number or percentage of available pods this budget requires. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. save-config falseIf 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 objec
7,813
t in the future. selectorA label selector to use for this budget. Only equality- based selector requirements are supported. show- managed-fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 trueIf true, use a schema to validate the input before sending it priorityclass Create a priority class named high-priority kubectl create priorityclass high-priority --value =1000 --description ="high priority" Create a priority class named default-priority that is considered as the global default priority kubectl create priorityclass default -priority -- value =1000 --global -default =true --description= "de fault priority" Create a priority class named high-priority that cannot preempt pods with lower priority kubectl create priorityclass high-priority --v
7,814
alue =1000 --description ="high priority" -- preemption-policy ="Never
7,815
Create a priority class with the specified name, value, globalDefault and description. Usage $ kubectl create priorityclass NAME --value=VALUE --global-default=BOOL [--dry-run=server| client|none] Flags Name Shorthand Default Usage allow-missing- template-keystrueIf 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. descriptiondescription is an arbitrary string that usually provides guidelines on when this priority class should be used. dry-run noneMust 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 kubectl-createName of the manager used to track field ownership. global-default falseglobal-default specifies whether this PriorityClass should be considered as the default priority. output oOutput format. One of: json|yaml|name|go- temp
7,816
late|go-template-file|template| templatefile|jsonpath|jsonpath-as-json| jsonpath-file. preemption- policyPreemptLowerPrioritypreemption-policy is the policy for preempting pods with lower priority. save-config falseIf 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- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 trueIf true, use a schema to validate the input before sending it value 0 the value of this priority class
7,817
quota Create a new resource quota named my-quota kubectl create quota my-quota --hard=cpu= 1,memory= 1G,pods= 2,services= 3,replicationcontroll ers=2,resourcequotas= 1,secrets= 5,persistentvolumeclaims= 10 Create a new resource quota named best-effort kubectl create quota best-effort --hard =pods=100 --scopes =BestEffort Create a resource quota with the specified name, hard limits, and optional scopes. Usage $ kubectl create quota NAME [--hard=key1=value1,key2=value2] [--scopes=Scope1,Scope2] [-- dry-run=server|client|none] Flags Name Shorthand Default Usage allow- missing- template- keystrueIf 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 noneMust 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-managerkubectl- createName of the ma
7,818
nager used to track field ownership. hardA comma-delimited set of resource=quantity pairs that define a hard limit. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. save-config falseIf 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. scopesA comma-delimited set of quota scopes that must all match each object tracked by the quota. show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 true If true, use a schema to validate the input before sending i
7,819
role Create a role named "pod-reader" that allows user to perform "get", "watch" and "list" on pods kubectl create role pod-reader --verb =get --verb =list --verb =watch --resource =pods Create a role named "pod-reader" with ResourceName specified kubectl create role pod-reader --verb =get --resource =pods --resource-name =readablepod -- resource-name =anotherpod Create a role named "foo" with API Group specified kubectl create role foo --verb =get,list,watch --resource =rs.extensions Create a role named "foo" with SubResource specified kubectl create role foo --verb =get,list,watch --resource =pods,pods/status Create a role with single rule. Usage $ kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource- name=resourcename] [--dry-run=server|client|none] Flags Name Shorthand Default Usage allow- missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output
7,820
formats. dry-run noneMust 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-managerkubectl- createName of the manager used to track field ownership. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. resource [] Resource that the rule applies to resource- name[]Resource in the white list that the rule applies to, repeat this flag for multiple items save-config falseIf 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. falseIf true, keep the managedFields when printing objects in JSON or YAML format
7,821
Name Shorthand Default Usage show- managed- fields templateTemplate 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 true If true, use a schema to validate the input before sending it verb [] Verb that applies to the resources contained in the rule rolebinding Create a role binding for user1, user2, and group1 using the admin cluster role kubectl create rolebinding admin --clusterrole =admin --user =user1 --user =user2 --group =group 1 Create a role binding for a particular role or cluster role. Usage $ kubectl create rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [-- group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run=server| client|none] Flags Name Shorthand Default Usage allow-missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applie
7,822
s to golang and jsonpath output formats. clusterrole ClusterRole this RoleBinding should reference dry-run noneMust 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-managerkubectl- createName of the manager used to track field ownership. group [] Groups to bind to the role output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath- as-json|jsonpath-file. role Role this RoleBinding should reference save-config falseIf 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. serviceaccount [
7,823
Name Shorthand Default Usage Service accounts to bind to the role, in the format <namespace>:<name> show-managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 trueIf true, use a schema to validate the input before sending it secret Create a secret using specified subcommand. Usage $ kubectl create secret secret docker-registry If you don't already have a .dockercfg file, you can create a dockercfg secret directly by using: kubectl create secret docker-registry my-secret --docker-server =DOCKER_REGISTRY_SERVER --docker-username =DOCKER_USER --docker-password =DOCKER_PASSWORD --docker- email =DOCKER_EMAIL Create a new secret named my-secret from ~/.docker/config.json kubectl create secret docker-registry my-secret --from-file =.dockerconf
7,824
igjson=path/to/.docker/ config.json Create a new secret for use with Docker registries. Dockercfg secrets are used to authenticate against Docker registries. When using the Docker command line to push images, you can authenticate to a given registry by running: '$ docker login DOCKER_REGISTRY_SERVER --username=DOCKER_USER -- password=DOCKER_PASSWORD --email=DOCKER_EMAIL'. That produces a ~/.dockercfg file that is used by subsequent 'docker push' and 'docker pull' commands to authenticate to the registry. The email address is optional. When creating applications, you may have a Docker registry that requires authentication. In order for the nodes to pull images on your behalf, they must have the credentials. You can provide this information by creating a dockercfg secret and attaching it to your service account
7,825
Usage $ kubectl create secret docker-registry NAME --docker-username=user --docker- password=password --docker-email=email [--docker-server=string] [--from-file=[key=]source] [--dry-run=server|client|none] Flags Name Shorthand Default Usage allow- missing- template- keystrueIf 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. append- hashfalse Append a hash of the secret to its name. docker- emailEmail for Docker registry docker- passwordPassword for Docker registry authentication docker- serverhttps:// index.docker.io/ v1/Server location for Docker registry docker- usernameUsername for Docker registry authentication dry-run noneMust 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- managerkubectl-create Name of the manager used to track
7,826
field ownership. from-file []Key files can be specified using their file path, in which case a default name will be given to them, or optionally with a name and file path, in which case the given name will be used. Specifying a directory will iterate each named file in the directory that is a valid secret key. output oOutput format. One of: json|yaml|name|go-template| go-template-file|template|templatefile|jsonpath| jsonpath-as-json|jsonpath-file. save-config falseIf 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- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The templat
7,827
Name Shorthand Default Usage format is golang templates [http://golang.org/pkg/ text/template/#pkg-overview ]. validate trueIf true, use a schema to validate the input before sending it secret generic Create a new secret named my-secret with keys for each file in folder bar kubectl create secret generic my-secret --from-file =path/to/bar Create a new secret named my-secret with specified keys instead of names on disk kubectl create secret generic my-secret --from-file =ssh-privatekey=path/to/id_rsa --from-file =ss h-publickey=path/to/id_rsa.pub Create a new secret named my-secret with key1=supersecret and key2=topsecret kubectl create secret generic my-secret --from-literal =key1=supersecret --from-literal =key2=top secret Create a new secret named my-secret using a combination of a file and a literal kubectl create secret generic my-secret --from-file =ssh-privatekey=path/to/id_rsa --from- literal =passphrase=topsecret Create a new secret named my-secret from an env file kubectl
7,828
create secret generic my-secret --from-env-file =path/to/bar.env Create a secret based on a file, directory, or specified literal value. A single secret may package one or more key/value pairs. When creating a secret based on a file, the key will default to the basename of the file, and the value will default to the file content. If the basename is an invalid key or you wish to chose your own, you may specify an alternate key. When creating a secret based on a directory, each file whose basename is a valid key in the directory will be packaged into the secret. Any directory entries except regular files are ignored (e.g. subdirectories, symlinks, devices, pipes, etc). Usage $ kubectl create generic NAME [--type=string] [--from-file=[key=]source] [--from- literal=key1=value1] [--dry-run=server|client|none] Flags Name Shorthand Default Usage tru
7,829
Name Shorthand Default Usage allow- missing- template- keysIf 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. append-hash false Append a hash of the secret to its name. dry-run noneMust 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- managerkubectl- createName of the manager used to track field ownership. from-env- fileSpecify the path to a file to read lines of key=val pairs to create a secret (i.e. a Docker .env file). from-file []Key files can be specified using their file path, in which case a default name will be given to them, or optionally with a name and file path, in which case the given name will be used. Specifying a directory will iterate each named file in the directory that is a valid secret key. from-literal []Specify a k
7,830
ey and literal value to insert in secret (i.e. mykey=somevalue) output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. save-config falseIf 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- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 The type of secret to create validate true If true, use a schema to validate the input before sending it secret tls Create a new TLS secret named tls-secret with the given key pair kubectl create secret tls tls-secret --cert =path/to/tls.cert --key =path/t
7,831
o/tls.key Create a TLS secret from the given public/private key pair. The public/private key pair must exist beforehand. The public key certificate must be .PEM encoded and match the given private key
7,832
Usage $ kubectl create secret tls NAME --cert=path/to/cert/file --key=path/to/key/file [--dry- run=server|client|none] Flags Name Shorthand Default Usage allow- missing- template-keystrueIf 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. append-hash false Append a hash of the secret to its name. cert Path to PEM encoded public key certificate. dry-run noneMust 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-managerkubectl- createName of the manager used to track field ownership. key Path to private key associated with given certificate. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. save-config falseIf true, the configuration of current object w
7,833
ill 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- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 true If true, use a schema to validate the input before sending it service Create a service using a specified subcommand. Usage $ kubectl create service service clusterip Create a new ClusterIP service named my-c
7,834
kubectl create service clusterip my-cs --tcp =5678:8080 Create a new ClusterIP service named my-cs (in headless mode) kubectl create service clusterip my-cs --clusterip ="None" Create a ClusterIP service with the specified name. Usage $ kubectl create service clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run=server|client| none] Flags Name Shorthand Default Usage allow- missing- template- keystrueIf 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. clusteripAssign your own ClusterIP or set to 'None' for a 'headless' service (no loadbalancing). dry-run noneMust 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- managerkubectl- createName of the manager used to track field ownership. output oOutput format. One of: json|yaml|name|go-templat
7,835
e|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. save-config falseIf 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- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. tcp [] Port pairs can be specified as '<port>:<targetPort>'. templateTemplate 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 true If true, use a schema to validate the input before sending it service externalname Create a new ExternalName service named my-ns kubectl create service externalname my-ns --external-name bar.co
7,836
Create an ExternalName service with the specified name. ExternalName service references to an external DNS address instead of only pods, which will allow application authors to reference services that exist off platform, on other clusters, or locally. Usage $ kubectl create service externalname NAME --external-name external.name [--dry-run=server| client|none] Flags Name Shorthand Default Usage allow- missing- template- keystrueIf 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 noneMust 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- nameExternal name of service field- managerkubectl- createName of the manager used to track field ownership. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|tem
7,837
platefile|jsonpath|jsonpath-as- json|jsonpath-file. save-config falseIf 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- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. tcp [] Port pairs can be specified as '<port>:<targetPort>'. templateTemplate 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 true If true, use a schema to validate the input before sending it service loadbalancer Create a new LoadBalancer service named my-lbs kubectl create service loadbalancer my-lbs --tcp =5678:8080 Create a LoadBalancer service with the specified name
7,838
Usage $ kubectl create service loadbalancer NAME [--tcp=port:targetPort] [--dry-run=server|client| none] Flags Name Shorthand Default Usage allow- missing- template- keystrueIf 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 noneMust 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- managerkubectl- createName of the manager used to track field ownership. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. save-config falseIf 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-
7,839
fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. tcp [] Port pairs can be specified as '<port>:<targetPort>'. templateTemplate 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 true If true, use a schema to validate the input before sending it service nodeport Create a new NodePort service named my-ns kubectl create service nodeport my-ns --tcp =5678:8080 Create a NodePort service with the specified name. Usage $ kubectl create service nodeport NAME [--tcp=port:targetPort] [--dry-run=server|client|none
7,840
Flags Name Shorthand Default Usage allow- missing- template- keystrueIf 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 noneMust 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- managerkubectl- createName of the manager used to track field ownership. node-port 0 Port used to expose the service on each node in a cluster. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. save-config falseIf 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- fieldsfalseIf true, keep the mana
7,841
gedFields when printing objects in JSON or YAML format. tcp [] Port pairs can be specified as '<port>:<targetPort>'. templateTemplate 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 true If true, use a schema to validate the input before sending it serviceaccount Create a new service account named my-service-account kubectl create serviceaccount my-service- account Create a service account with the specified name. Usage $ kubectl create serviceaccount NAME [--dry-run=server|client|none] Flags Name Shorthand Default Usage allow- missing- template-keystrueIf 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
7,842
Name Shorthand Default Usage dry-run noneMust 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-managerkubectl- createName of the manager used to track field ownership. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. save-config falseIf 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- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 ]. valida
7,843
te true If true, use a schema to validate the input before sending it get 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 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 jso
7,844
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:.sp ec.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/web-pod-13je7 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. Uninitialized objects are not shown unless --include-uninitialized is passed. By specifying the
7,845
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. Usage $ kubectl 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] Flags Name Shorthand Default Usage all- namespacesA falseIf present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace. allow- missing- template- keystrueIf 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 500Return large lists in chunks rather than all at once. Pass 0 to disable. This flag is beta and may change in the future
7,846
Name Shorthand Default Usage field-selectorSelector (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. filename f []Filename, directory, or URL to files identifying the resource to get from a server. ignore-not- foundfalseIf the requested object does not exist the command will return exit code 0. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. label- columnsL []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 falseWhen using the default or custom-column output format, don't print headers (default print headers). output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file|custom-columns-file|custo
7,847
m-columns|wide See custom columns [https://kubernetes.io/docs/reference/ kubectl/overview/#custom-columns ], golang template [http://golang.org/pkg/text/template/#pkg-overview ] and jsonpath template [https://kubernetes.io/docs/reference/ kubectl/jsonpath/ ]. output- watch-eventsfalseOutput watch event objects when --watch or --watch-only is used. Existing objects are output as initial ADDED events. rawRaw URI to request from the server. Uses the transport specified by the kubeconfig file. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. selector lSelector (label query) to filter on, supports '=', '==', and '!='. (e.g. -l key1=value1,key2=value2) server-print trueIf true, have the server return the appropriate table output. Supports extension APIs and CRDs. show-kind false If present, list the resource type for the requested object(s). show-labels falseWhen printing,
7,848
show all labels as the last column (default hide labels column) show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. sort-byIf 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 string. templateTemplate 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 ]. fals
7,849
Name Shorthand Default Usage use-openapi- print- columnsIf true, use x-kubernetes-print-column metadata (if present) from the OpenAPI schema for displaying a resource. watch w falseAfter listing/getting the requested object, watch for changes. Uninitialized objects are excluded if no object name is provided. watch-only falseWatch for changes to the requested object(s), without listing/getting first. run Start a nginx pod kubectl run nginx --image =nginx Start a hazelcast pod and let the container expose port 5701 kubectl run hazelcast --image =hazelcast/hazelcast --port =5701 Start a hazelcast pod and set environment variables "DNS_DOMAIN=cluster" and "POD_NAMESPACE=default" in the container kubectl run hazelcast --image =hazelcast/hazelcast --env ="DNS_DOMAIN=cluster" --env ="POD _NAMESPACE=default" Start a hazelcast pod and set labels "app=hazelcast" and "env=prod" in the container kubectl run hazelcast --image =hazelcast/hazelcast --labels ="app=hazelcast,env=prod" Dry run; prin
7,850
t the corresponding API objects without creating them kubectl run nginx --image =nginx --dry-run =client Start a nginx pod, but overload the spec with a partial set of values parsed from JSON kubectl run nginx --image=nginx --overrides= '{ "apiVersion" : "v1", "spec" : { ... } }' Start a busybox pod and keep it in the foreground, don't restart it if it exits kubectl run -i -t busybox --image =busybox --restart =Never Start the nginx pod using the default command, but use custom arguments (arg1 .. argN) for that command kubectl run nginx --image =nginx -- <arg1> <arg2> ... <argN> Start the nginx pod using a different command and custom arguments kubectl run nginx --image =nginx --command -- <cmd> <arg1> ... <argN
7,851
Create and run a particular image in a pod. Usage $ kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server| client] [--overrides=inline-json] [--command] -- [COMMAND] [args...] Flags Name Shorthand Default Usage allow-missing- template-keystrueIf 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. annotations [] Annotations to apply to the pod. attach falseIf true, wait for the Pod to start running, and then attach to the Pod as if 'kubectl attach ...' were called. Default false, unless '-i/--stdin' is set, in which case the default is true. With '--restart=Never' the exit code of the container process is returned. cascade backgroundMust be "background", "orphan", or "foreground". Selects the deletion cascading strategy for the dependents (e.g. Pods created by a ReplicationController). Defaults to background. command falseIf true and extra arguments are present, use
7,852
them as the 'command' field in the container, rather than the 'args' field which is the default. dry-run noneMust 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. env [] Environment variables to set in the container. expose falseIf true, service is created for the container(s) which are run field-manager kubectl-run Name of the manager used to track field ownership. filename f [] to use to replace the resource. force falseIf 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. grace-period -1Period 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). hostport -1The host port
7,853
mapping for the container port. To demonstrate a single-machine container. image The image for the container to run. image-pull- policyThe image pull policy for the container. If left empty, this value will not be specified by the client and defaulted by the server kustomize
7,854
Name Shorthand Default Usage Process a kustomization directory. This flag can't be used together with -f or -R. labels lComma separated labels to apply to the pod(s). Will override previous values. leave-stdin- openfalseIf the pod is started in interactive mode or with stdin, leave stdin open after the first attach completes. By default, stdin will be closed after the first attach completes. limitsThe resource requirement limits for this container. For example, 'cpu=200m,memory=512Mi'. Note that server side components may assign limits depending on the server configuration, such as limit ranges. output oOutput format. One of: json|yaml|name|go-template| go-template-file|template|templatefile|jsonpath| jsonpath-as-json|jsonpath-file. overridesAn 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. pod-running- timeout1m0sThe length of time (like 5s, 2m, or 3h, hig
7,855
her than zero) to wait until at least one pod is running port The port that this container exposes. privileged false If true, run the container in privileged mode. quiet q false If true, suppress prompt messages. record falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. requestsThe resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges. restart AlwaysThe restart policy for this Pod. Legal values [Always, OnFailure, Never ]. rm falseIf true, delete resources created in this command for attached con
7,856
tainers. save-config falseIf 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. serviceaccount Service account to set in the pod spec. show-managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. stdin i fals
7,857
Name Shorthand Default Usage Keep stdin open on the container(s) in the pod, even if nothing is attached. templateTemplate 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 0sThe length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object tty t false Allocated a TTY for each container in the pod. wait falseIf true, wait for resources to be gone before returning. This waits for finalizers. expose 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
7,858
=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 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
7,859
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) Usage $ 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] Flags Name Shorthand
7,860
Default Usage allow- missing- template- keystrueIf 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-ipClusterIP to be assigned to the service. Leave empty to auto-allocate, or set to 'None' to create a headless service. container- portSynonym for --target-port dry-run noneMust 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-ipAdditional 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-managerkubectl- exposeName of the manager used to track field ownership. filename f []Filename, directory, or URL to files identifying the resource to expose a service generatorservice/ v2The name of the
7,861
API generator to use. There are 2 generators: 'service/v1' and 'service/v2'. The only difference between them is that service port in v1 is named 'default', while it is left unnamed in v2. Default is 'service/v2'. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. labels l Labels to apply to the service created by this call
7,862
Name Shorthand Default Usage load- balancer-ipIP to assign to the LoadBalancer. If empty, an ephemeral IP will be created and used (cloud-provider specific). name The name for the newly created object. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. overridesAn 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. portThe port that the service should serve on. Copied from the resource being exposed, if unspecified protocolThe network protocol for the service to be created. Default is 'TCP'. record falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. recursive R falseProcess the directory used in
7,863
-f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. save-config falseIf 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. selectorA 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- affinityIf non-empty, set the session affinity for the service to this; legal values: 'None', 'ClientIP' show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. target-portName or number for the port on the container that the service should direct traffic to. Optional. templateTemplate string or path to template file to use when - o=go-template, -o=go-template-file. The template format is go
7,864
lang templates [http://golang.org/pkg/text/template/ #pkg-overview ]. typeType for this service: ClusterIP, NodePort, LoadBalancer, or ExternalName. Default is 'ClusterIP'. delete Delete a pod using the type and name specified in pod.jso
7,865
kubectl delete -f ./pod.json Delete resources from a directory containing kustomization.yaml - e.g. dir/ kustomization.yaml kubectl delete -k dir Delete a pod based on the type and name in the JSON passed into stdin cat pod.json | kubectl delete -f - Delete pods and services with same names "baz" and "foo" kubectl delete pod,service baz foo Delete pods and services with label name=myLabel kubectl delete pods,services -l name =myLabel Delete a pod with minimal delay kubectl delete pod foo --now Force delete a pod on a dead node kubectl delete pod foo --force Delete all pods kubectl delete pods --all Delete resources by file names, stdin, resources and names, or by resources and label selector. JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label selector. Some resources, such as pods, support graceful deletion. These resources define a default period before they are forcibly terminated (the grace
7,866
period) but you may override that value with the --grace-period flag, or pass --now to set a grace-period of 1. Because these resources often represent entities in the cluster, deletion may not be acknowledged immediately. If the node hosting a pod is down or cannot reach the API server, termination may take significantly longer than the grace period. To force delete a resource, you must specify the --force flag. Note: only a subset of resources support graceful deletion. In absence of the support, the --grace-period flag is ignored. IMPORTANT: Force deleting pods does not wait for confirmation that the pod's processes have been terminated, which can leave those processes running until the node detects the deletion and completes graceful deletion. If your processes use shared storage or talk to a remote API and depend on the name of the pod to identify themselves, force deleting those pods may result in multiple processes running on different machines using the same identification whic
7,867
h may lead to data corruption or inconsistency. Only force delete pods when you are sure the pod is terminated, or if your application can tolerate multiple copies of the same pod running at once. Also, if you force delete pods, the scheduler may place new pods on those nodes before the node has released those resources and causing those pods to be evicted immediately
7,868
Note that the delete command does NOT do resource version checks, so if someone submits an update to a resource right when you submit a delete, their update will be lost along with the rest of the resource. Usage $ kubectl delete ([-f FILENAME] | [-k DIRECTORY] | TYPE [(NAME | -l label | --all)]) Flags Name Shorthand Default Usage all falseDelete all resources, including uninitialized ones, in the namespace of the specified resource types. all- namespacesA falseIf present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace. cascade backgroundMust 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 noneMust 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 persi
7,869
sting the resource. field- selectorSelector (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. filename f [] containing the resource to delete. force falseIf 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. grace-period -1Period 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). ignore-not- foundfalseTreat "resource not found" as a successful delete. Defaults to "true" when --all is specified. kustomize kProcess a kustomization directory. This flag can't be used together with -f or -R. now falseIf true, resources are signaled for immediate shutdown (same as --grace-period=1). output oOutput
7,870
mode. Use "-o name" for shorter output (resource/ name). rawRaw URI to DELETE to the server. Uses the transport specified by the kubeconfig file. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory
7,871
Name Shorthand Default Usage selector lSelector (label query) to filter on, not including uninitialized ones. timeout 0sThe length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object wait trueIf true, wait for resources to be gone before returning. This waits for finalizers. APP MANAGEMENT This section contains commands for creating, updating, deleting, and viewing your workloads in a Kubernetes cluster. apply Apply the configuration in pod.json to a pod kubectl apply -f ./pod.json 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 - 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
7,872
in manifest.yaml and delete all the other config maps that are not in the file kubectl apply --prune -f manifest .yaml --all --prune -whitelist=core/v1/ConfigMap 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 not use unless you are aware of what the current state is. See https://issues.k8s.io/34274
7,873
Usage $ kubectl apply (-f FILENAME | -k DIRECTORY) Flags Name Shorthand Default Usage all falseSelect all resources in the namespace of the specified resource types. allow- missing- template- keystrueIf 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. cascade backgroundMust 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 noneMust 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- managerkubectl- client-side- applyName of the manager used to track field ownership. filename f [] that contains the configuration to apply force falseIf true, immediately remove resources from API and bypass graceful deletion. Note
7,874
that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation. force- conflictsfalseIf true, server-side apply will force the changes against conflicts. grace-period -1Period 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). kustomize kProcess a kustomization directory. This flag can't be used together with -f or -R. openapi- patchtrueIf 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. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath- as-json|jsonpath-file. overwrite trueAutomatically resolve conflicts between the modified and live configuration by using values from the modified configuration prune falseAutomatically delete resource
7,875
objects, including the uninitialized ones, 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
7,876
Name Shorthand Default Usage prune- whitelist[]Overwrite the default whitelist with <group/version/ kind> for --prune record falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. selector lSelector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) server-side false If true, apply runs in the server instead of the client. show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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-ove
7,877
rview ]. timeout 0sThe length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object validate trueIf true, use a schema to validate the input before sending it wait falseIf true, wait for resources to be gone before returning. This waits for finalizers. edit-last-applied 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 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. Th
7,878
e 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"
7,879
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. Usage $ kubectl apply edit-last-applied (RESOURCE/NAME | -f FILENAME) Flags Name Shorthand Default Usage allow- missing- template- keystrueIf 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- managerkubectl- client-side- applyName of the manager used to track field ownership. filename f []Filename, directory, or URL to files to use to edit the resource kustomize kPr
7,880
ocess the kustomization directory. This flag can't be used together with -f or -R. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. record falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 ]. windows- line-endingsfalse Defaults to the line ending native to your p
7,881
latform
7,882
set-last-applied 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 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 ' was run, without updating any other parts of the object. Usage $ kubectl apply set-last-applied -f FILENAME Flags Name Shorthand Default Usage allow-missing- template-keystrueIf 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. create- annotatio
7,883
nfalseWill create 'last-applied-configuration' annotations if current objects doesn't have one dry-run noneMust 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. filename f []Filename, directory, or URL to files that contains the last- applied-configuration annotations output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. show- managed-fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 ]. view-last-applied View the last-applied-configuration annotations by type/name in YAM
7,884
kubectl apply view -last-applied deployment/nginx View the last-applied-configuration annotations by file in JSON kubectl apply view -last-applied -f deploy.yaml -o json 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. Usage $ kubectl apply view-last-applied (TYPE [NAME | -l label] | TYPE/NAME | -f FILENAME) Flags Name Shorthand Default Usage all falseSelect all resources in the namespace of the specified resource types filename f []Filename, directory, or URL to files that contains the last- applied-configuration annotations kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. output o yaml Output format. Must be one of yaml|json recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. select
7,885
or lSelector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) annotate 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
7,886
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 named 'description' if it exists # Does not require the --overwrite flag kubectl annotate pods foo description - Update the annotations on one or more resources. All Kubernetes objects support 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. Usage $ kubectl annotate [--overwrite] (-f FILENAME | TYPE N
7,887
AME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version] Flags Name Shorthand Default Usage all falseSelect all resources, including uninitialized ones, in the namespace of the specified resource types. all- namespacesA false If true, check the specified action in all namespaces. allow- missing- template-keystrueIf 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 noneMust 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-managerkubectl- annotateName of the manager used to track field ownership. field-selectorSelector (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. filename f []Filename, directory, or
7,888
URL to files identifying the resource to update the annotation kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. list false If true, display the annotations for a given resource
7,889
Name Shorthand Default Usage local falseIf true, annotation will NOT contact api-server but run locally. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. overwrite falseIf true, allow annotations to be overwritten, otherwise reject annotation updates that overwrite existing annotations. record falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. resource- versionIf 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. selector lSelector (label query) to filt
7,890
er on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate 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 ]. autoscale Auto scale a deployment "foo", with the number of pods between 2 and 10, no target CPU utilization specified so a default autoscaling policy will be used kubectl autoscale deployment foo --min =2 --max =10 Auto scale a replication controller "foo", with the number of pods between 1 and 5, target CPU utilization at 80% kubectl autoscale rc foo --max =5 --cpu-percent =80 Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster. Looks up a deployment, replica set, stateful set, or replication controller by name and creates an au
7,891
toscaler that uses the given resource as a reference. An autoscaler can automatically increase or decrease number of pods deployed within the system as needed
7,892
Usage $ kubectl autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] -- max=MAXPODS [--cpu-percent=CPU] Flags Name Shorthand Default Usage allow- missing- template- keystrueIf 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. cpu-percent -1The target average CPU utilization (represented as a percent of requested CPU) over all the pods. If it's not specified or negative, a default autoscaling policy will be used. dry-run noneMust 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-managerkubectl- autoscaleName of the manager used to track field ownership. filename f []Filename, directory, or URL to files identifying the resource to autoscale. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -
7,893
R. max -1The upper limit for the number of pods that can be set by the autoscaler. Required. min -1The lower limit for the number of pods that can be set by the autoscaler. If it's not specified or negative, the server will apply a default value. nameThe name for the newly created object. If not specified, the name of the input resource will be used. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. record falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. save-config falseIf true, the configuration of current object will be saved in its annotation. Oth
7,894
erwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future. falseIf true, keep the managedFields when printing objects in JSON or YAML format
7,895
Name Shorthand Default Usage show- managed- fields templateTemplate 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 ]. debug Create an interactive debugging session in pod mypod and immediately attach to it. # (requires the EphemeralContainers feature to be enabled in the cluster) kubectl debug mypod -it --image =busybox Create a debug container named debugger using a custom automated debugging image. # (requires the EphemeralContainers feature to be enabled in the cluster) kubectl debug --image =myproj/debug-tools -c debugger mypod Create a copy of mypod adding a debug container and attach to it kubectl debug mypod -it --image =busybox --copy-to =my-debugger Create a copy of mypod changing the command of mycontainer kubectl debug mypod -it --copy-to =my-debugger --container =mycontainer -- sh Create a copy of mypod changing all container images to busybox
7,896
kubectl debug mypod --copy-to =my-debugger --set-image =*=busybox Create a copy of mypod adding a debug container and changing container images kubectl debug mypod -it --copy-to =my-debugger --image =debian --set-image =app=app:debug,s idecar=sidecar:debug Create an interactive debugging session on a node and immediately attach to it. # The container will run in the host namespaces and the host's filesystem will be mounted at /host kubectl debug node /mynode -it -- image= busybox Debug cluster resources using interactive debugging containers. 'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by default if no resource is specified
7,897
The action taken by 'debug' varies depending on what resource is specified. Supported actions include: Workload: Create a copy of an existing pod with certain attributes changed, for example changing the image tag to a new version. Workload: Add an ephemeral container to an already running pod, for example to add debugging utilities without restarting the pod. Node: Create a new pod that runs in the node's host namespaces and can access the node's filesystem. Usage $ kubectl debug (POD | TYPE[[.VERSION].GROUP]/NAME) [ -- COMMAND [args...] ] Flags Name Shorthand Default Usage arguments- onlyfalseIf specified, everything after -- will be passed to the new container as Args instead of Command. attach falseIf true, wait for the container to start running, and then attach as if 'kubectl attach ...' were called. Default false, unless '-i/--stdin' is set, in which case the default is true. container c Container name to use for debug container. copy-to Create a copy of the target Pod with t
7,898
his name. env [] Environment variables to set in the container. image Container image to use for debug container. image-pull- policyThe image pull policy for the container. If left empty, this value will not be specified by the client and defaulted by the server. quiet q false If true, suppress informational messages. replace false When used with '--copy-to', delete the original Pod. same-node falseWhen used with '--copy-to', schedule the copy of target Pod on the same node. set-image []When used with '--copy-to', a list of name=image pairs for changing container images, similar to how 'kubectl set image' works. share- processestrueWhen used with '--copy-to', enable process namespace sharing in the copy. stdin i falseKeep stdin open on the container(s) in the pod, even if nothing is attached. targetWhen using an ephemeral container, target processes in this container name. tty t false Allocate a TTY for the debugging container. diff Diff resources included in pod.json• •
7,899