-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update kubectl documentation #12867
update kubectl documentation #12867
Changes from 1 commit
a6b6173
829cf2b
8e0a7e4
eef3103
6d8c564
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,23 +26,23 @@ Many applications require multiple resources to be created, such as a Deployment | |
Multiple resources can be created the same way as a single resource: | ||
|
||
```shell | ||
$ kubectl create -f https://k8s.io/examples/application/nginx-app.yaml | ||
$ kubectl apply -f https://k8s.io/examples/application/nginx-app.yaml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please remove |
||
service/my-nginx-svc created | ||
deployment.apps/my-nginx created | ||
``` | ||
|
||
The resources will be created in the order they appear in the file. Therefore, it's best to specify the service first, since that will ensure the scheduler can spread the pods associated with the service as they are created by the controller(s), such as Deployment. | ||
|
||
`kubectl create` also accepts multiple `-f` arguments: | ||
`kubectl apply` also accepts multiple `-f` arguments: | ||
|
||
```shell | ||
$ kubectl create -f https://k8s.io/examples/application/nginx/nginx-svc.yaml -f https://k8s.io/examples/application/nginx/nginx-deployment.yaml | ||
$ kubectl apply -f https://k8s.io/examples/application/nginx/nginx-svc.yaml -f https://k8s.io/examples/application/nginx/nginx-deployment.yaml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please remove |
||
``` | ||
|
||
And a directory can be specified rather than or in addition to individual files: | ||
|
||
```shell | ||
$ kubectl create -f https://k8s.io/examples/application/nginx/ | ||
$ kubectl apply -f https://k8s.io/examples/application/nginx/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please remove |
||
``` | ||
|
||
`kubectl` will read any files with suffixes `.yaml`, `.yml`, or `.json`. | ||
|
@@ -52,7 +52,7 @@ It is a recommended practice to put resources related to the same microservice o | |
A URL can also be specified as a configuration source, which is handy for deploying directly from configuration files checked into github: | ||
|
||
```shell | ||
$ kubectl create -f https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/application/nginx/nginx-deployment.yaml | ||
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/application/nginx/nginx-deployment.yaml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please remove |
||
deployment.apps/my-nginx created | ||
``` | ||
|
||
|
@@ -83,7 +83,7 @@ service "my-nginx-svc" deleted | |
Because `kubectl` outputs resource names in the same syntax it accepts, it's easy to chain operations using `$()` or `xargs`: | ||
|
||
```shell | ||
$ kubectl get $(kubectl create -f docs/concepts/cluster-administration/nginx/ -o name | grep service) | ||
$ kubectl get $(kubectl apply -f docs/concepts/cluster-administration/nginx/ -o name | grep service) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please remove |
||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE | ||
my-nginx-svc LoadBalancer 10.0.0.208 <pending> 80/TCP 0s | ||
``` | ||
|
@@ -108,14 +108,14 @@ project/k8s/development | |
By default, performing a bulk operation on `project/k8s/development` will stop at the first level of the directory, not processing any subdirectories. If we had tried to create the resources in this directory using the following command, we would have encountered an error: | ||
|
||
```shell | ||
$ kubectl create -f project/k8s/development | ||
$ kubectl apply -f project/k8s/development | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please remove |
||
error: you must provide one or more resources by argument or filename (.json|.yaml|.yml|stdin) | ||
``` | ||
|
||
Instead, specify the `--recursive` or `-R` flag with the `--filename,-f` flag as such: | ||
|
||
```shell | ||
$ kubectl create -f project/k8s/development --recursive | ||
$ kubectl apply -f project/k8s/development --recursive | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please remove |
||
configmap/my-config created | ||
deployment.apps/my-deployment created | ||
persistentvolumeclaim/my-pvc created | ||
|
@@ -126,7 +126,7 @@ The `--recursive` flag works with any operation that accepts the `--filename,-f` | |
The `--recursive` flag also works when multiple `-f` arguments are provided: | ||
|
||
```shell | ||
$ kubectl create -f project/k8s/namespaces -f project/k8s/development --recursive | ||
$ kubectl apply -f project/k8s/namespaces -f project/k8s/development --recursive | ||
namespace/development created | ||
namespace/staging created | ||
configmap/my-config created | ||
|
@@ -169,7 +169,7 @@ and | |
The labels allow us to slice and dice our resources along any dimension specified by a label: | ||
|
||
```shell | ||
$ kubectl create -f examples/guestbook/all-in-one/guestbook-all-in-one.yaml | ||
$ kubectl apply -f examples/guestbook/all-in-one/guestbook-all-in-one.yaml | ||
$ kubectl get pods -Lapp -Ltier -Lrole | ||
NAME READY STATUS RESTARTS AGE APP TIER ROLE | ||
guestbook-fe-4nlpb 1/1 Running 0 1m guestbook frontend <none> | ||
|
@@ -331,7 +331,7 @@ Currently, resources are created without this annotation, so the first invocatio | |
All subsequent calls to `kubectl apply`, and other commands that modify the configuration, such as `kubectl replace` and `kubectl edit`, will update the annotation, allowing subsequent calls to `kubectl apply` to detect and perform deletions using a three-way diff. | ||
|
||
{{< note >}} | ||
To use apply, always create resource initially with either `kubectl apply` or `kubectl create --save-config`. | ||
To use apply, always create resource initially with either `kubectl apply`. | ||
{{< /note >}} | ||
Liujingfang1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### kubectl edit | ||
|
@@ -379,8 +379,7 @@ deployment.apps/my-nginx replaced | |
|
||
At some point, you'll eventually need to update your deployed application, typically by specifying a new image or image tag, as in the canary deployment scenario above. `kubectl` supports several update operations, each of which is applicable to different scenarios. | ||
|
||
We'll guide you through how to create and update applications with Deployments. If your deployed application is managed by Replication Controllers, | ||
you should read [how to use `kubectl rolling-update`](/docs/tasks/run-application/rolling-update-replication-controller/) instead. | ||
We'll guide you through how to create and update applications with Deployments. | ||
|
||
Let's say you were running version 1.7.9 of nginx: | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please remove
$
to align on style guideline and be consistent