From cf3becadff9eecc03e995a3f0ccfead0b2487eac Mon Sep 17 00:00:00 2001 From: Weiping Cai Date: Sat, 13 Jun 2020 17:31:10 +0800 Subject: [PATCH] use kubectl create deployment to create deployment with --replicas and --port. Signed-off-by: Weiping Cai --- .../en/docs/concepts/policy/resource-quotas.md | 3 +-- .../reference/kubectl/docker-cli-to-kubectl.md | 17 +++++++++++------ .../namespaces-walkthrough.md | 3 +-- .../docs/tasks/administer-cluster/namespaces.md | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/content/en/docs/concepts/policy/resource-quotas.md b/content/en/docs/concepts/policy/resource-quotas.md index 39f51bf2d7..2c5f954327 100644 --- a/content/en/docs/concepts/policy/resource-quotas.md +++ b/content/en/docs/concepts/policy/resource-quotas.md @@ -494,8 +494,7 @@ kubectl create quota test --hard=count/deployments.extensions=2,count/replicaset ``` ```shell -kubectl create deployment nginx --image=nginx --namespace=myspace -kubectl scale deployment nginx --replicas=2 --namespace=myspace +kubectl create deployment nginx --image=nginx --namespace=myspace --replicas=2 ``` ```shell diff --git a/content/en/docs/reference/kubectl/docker-cli-to-kubectl.md b/content/en/docs/reference/kubectl/docker-cli-to-kubectl.md index 7def04e04c..ff89d6665d 100644 --- a/content/en/docs/reference/kubectl/docker-cli-to-kubectl.md +++ b/content/en/docs/reference/kubectl/docker-cli-to-kubectl.md @@ -13,8 +13,7 @@ You can use the Kubernetes command line tool kubectl to interact with the API Se {{% capture body %}} ## docker run -To run an nginx Deployment and expose the Deployment, see [kubectl run](/docs/reference/generated/kubectl/kubectl-commands/#run). - +To run an nginx Deployment and expose the Deployment, see [kubectl create deployment](/docs/reference/generated/kubectl/kubectl-commands#-em-deployment-em-). docker: ```shell @@ -36,12 +35,19 @@ kubectl: ```shell # start the pod running nginx -kubectl run --image=nginx nginx-app --port=80 --env="DOMAIN=cluster" +kubectl create deployment --image=nginx nginx-app --port=80 ``` ``` -deployment "nginx-app" created +deployment.apps/nginx-app created ``` +``` +# add env to nginx-app +kubectl set env deployment/nginx-app DOMAIN=cluster +``` +``` +deployment.apps/nginx-app env updated + {{< note >}} `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. {{< /note >}} @@ -56,8 +62,7 @@ service "nginx-http" exposed 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). -By default images run in the background, similar to `docker run -d ...`. To run things in the foreground, use: - +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: ```shell kubectl run [-i] [--tty] --attach --image= ``` diff --git a/content/en/docs/tasks/administer-cluster/namespaces-walkthrough.md b/content/en/docs/tasks/administer-cluster/namespaces-walkthrough.md index 9e3f4d6371..618b9bfaca 100644 --- a/content/en/docs/tasks/administer-cluster/namespaces-walkthrough.md +++ b/content/en/docs/tasks/administer-cluster/namespaces-walkthrough.md @@ -268,8 +268,7 @@ kubectl get pods Production likes to run cattle, so let's create some cattle pods. ```shell -kubectl create deployment cattle --image=k8s.gcr.io/serve_hostname -kubectl scale deployment cattle --replicas=5 +kubectl create deployment cattle --image=k8s.gcr.io/serve_hostname --replicas=5 kubectl get deployment ``` diff --git a/content/en/docs/tasks/administer-cluster/namespaces.md b/content/en/docs/tasks/administer-cluster/namespaces.md index 076f81d9b9..bb4abd964f 100644 --- a/content/en/docs/tasks/administer-cluster/namespaces.md +++ b/content/en/docs/tasks/administer-cluster/namespaces.md @@ -189,7 +189,7 @@ This delete is asynchronous, so for a time you will see the namespace in the `Te To demonstrate this, let's spin up a simple Deployment and Pods in the `development` namespace. ```shell - kubectl create deployment snowflake --image=k8s.gcr.io/serve_hostname -n=development + kubectl create deployment snowflake --image=k8s.gcr.io/serve_hostname -n=development --replicas=2 kubectl scale deployment snowflake --replicas=2 -n=development ``` We have just created a deployment whose replica size is 2 that is running the pod called `snowflake` with a basic container that just serves the hostname.