You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/reference/kubectl/docker-cli-to-kubectl.md
+17-11Lines changed: 17 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ You can use the Kubernetes command line tool kubectl to interact with the API Se
13
13
<!-- body -->
14
14
## docker run
15
15
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-).
17
17
18
18
docker:
19
19
@@ -36,29 +36,35 @@ kubectl:
36
36
37
37
```shell
38
38
# 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
40
40
```
41
41
```
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
43
51
```
44
52
45
53
{{< 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.
47
55
{{< /note >}}
48
56
49
-
You can expose a new Service after a Pod is created.
50
-
51
57
```shell
52
58
# expose a port through with a service
53
-
kubectl expose pod nginx-app --port=80 --name=nginx-http
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).
60
66
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:
62
68
63
69
```shell
64
70
kubectl run [-i] [--tty] --attach <name> --image=<image>
Unlike `docker run ...`, if you specify `--attach`, then you attach `stdin`, `stdout` and `stderr`. You cannot control which streams are attached (`docker -a ...`).
68
74
To detach from the container, you can type the escape sequence Ctrl+P followed by Ctrl+Q.
69
75
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>`.
0 commit comments