Skip to content

Commit 81027d6

Browse files
author
Weiping Cai
committed
use kubectl create deployment to create Deployment
1 parent a255ff8 commit 81027d6

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

content/en/docs/reference/kubectl/docker-cli-to-kubectl.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You can use the Kubernetes command line tool kubectl to interact with the API Se
1313
<!-- body -->
1414
## docker run
1515

16-
To run an nginx Pod and expose the Pod, see [kubectl run](/docs/reference/generated/kubectl/kubectl-commands/#run).
16+
To run an nginx Deployment and expose the Deployment, see [kubectl create deployment](/docs/reference/generated/kubectl/kubectl-commands#-em-deployment-em-).
1717

1818
docker:
1919

@@ -36,29 +36,35 @@ kubectl:
3636

3737
```shell
3838
# start the pod running nginx
39-
kubectl run --image=nginx nginx-app --port=80 --env="DOMAIN=cluster"
39+
kubectl create deployment --image=nginx nginx-app
4040
```
4141
```
42-
pod/nginx-app created
42+
deployment.apps/nginx-app created
43+
```
44+
45+
```
46+
# add env to nginx-app
47+
kubectl set env deployment/nginx-app DOMAIN=cluster
48+
```
49+
```
50+
deployment.apps/nginx-app env updated
4351
```
4452

4553
{{< note >}}
46-
Pods are considered to be relatively ephemeral (rather than durable) entities,so you should use Deployment instead to make sure that your container are available throughout the cluster,see [kubectl create deployment](/docs/reference/generated/kubectl/kubectl-commands/#-em-deployment-em-),or [assign this pod to Node](/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector).
54+
`kubectl` commands print the type and name of the resource created or mutated, which can then be used in subsequent commands. You can expose a new Service after a Deployment is created.
4755
{{< /note >}}
4856

49-
You can expose a new Service after a Pod is created.
50-
5157
```shell
5258
# expose a port through with a service
53-
kubectl expose pod nginx-app --port=80 --name=nginx-http
59+
kubectl expose deployment nginx-app --port=80 --name=nginx-http
5460
```
5561
```
5662
service "nginx-http" exposed
5763
```
5864

59-
By using kubectl, you can create a [Pod](/docs/concepts/workloads/pods/pod/) that pod are running nginx. You can also create a [service](/docs/concepts/services-networking/service/) with a selector that matches the pod labels. For more information, see [Use a Service to Access an Application in a Cluster](/docs/tasks/access-application-cluster/service-access-application-cluster).
65+
By using kubectl, you can create a [Deployment](/docs/concepts/workloads/controllers/deployment/) to ensure that N pods are running nginx, where N is the number of replicas stated in the spec and defaults to 1. You can also create a [service](/docs/concepts/services-networking/service/) with a selector that matches the pod labels. For more information, see [Use a Service to Access an Application in a Cluster](/docs/tasks/access-application-cluster/service-access-application-cluster).
6066

61-
By default images run in the background, similar to `docker run -d ...`. To run things in the foreground, use:
67+
By default images run in the background, similar to `docker run -d ...`. To run things in the foreground, use [`kubectl run`](/docs/reference/generated/kubectl/kubectl-commands/#run) to create pod:
6268

6369
```shell
6470
kubectl run [-i] [--tty] --attach <name> --image=<image>
@@ -67,8 +73,8 @@ kubectl run [-i] [--tty] --attach <name> --image=<image>
6773
Unlike `docker run ...`, if you specify `--attach`, then you attach `stdin`, `stdout` and `stderr`. You cannot control which streams are attached (`docker -a ...`).
6874
To detach from the container, you can type the escape sequence Ctrl+P followed by Ctrl+Q.
6975

70-
Because the kubectl run command starts a Pod for the container, the Pod restarts if you terminate the attached process by using Ctrl+C, unlike `docker run -it`.
71-
To destroy the pod you need to run `kubectl delete pod <name>`.
76+
Because the kubectl run command starts a Deployment for the container, the Deployment restarts if you terminate the attached process by using Ctrl+C, unlike `docker run -it`.
77+
To destroy the Deployment and its pods you need to run `kubectl delete deployment <name>`.
7278

7379
## docker ps
7480

0 commit comments

Comments
 (0)