From e9784b98be593077f56d2e1b209c42baacb242e5 Mon Sep 17 00:00:00 2001 From: zhuzhenghao Date: Sun, 19 Feb 2023 15:30:04 +0800 Subject: [PATCH] Add syntax tag to highlight the shell --- .../run-stateless-application-deployment.md | 148 +++++++++--------- 1 file changed, 76 insertions(+), 72 deletions(-) diff --git a/content/en/docs/tasks/run-application/run-stateless-application-deployment.md b/content/en/docs/tasks/run-application/run-stateless-application-deployment.md index 62bd984ddc..370892522b 100644 --- a/content/en/docs/tasks/run-application/run-stateless-application-deployment.md +++ b/content/en/docs/tasks/run-application/run-stateless-application-deployment.md @@ -9,27 +9,16 @@ weight: 10 This page shows how to run an application using a Kubernetes Deployment object. - - - ## {{% heading "objectives" %}} - -* Create an nginx deployment. -* Use kubectl to list information about the deployment. -* Update the deployment. - - - +- Create an nginx deployment. +- Use kubectl to list information about the deployment. +- Update the deployment. ## {{% heading "prerequisites" %}} - {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}} - - - ## Creating and exploring an nginx deployment @@ -40,60 +29,71 @@ a Deployment that runs the nginx:1.14.2 Docker image: {{< codenew file="application/deployment.yaml" >}} - 1. Create a Deployment based on the YAML file: - kubectl apply -f https://k8s.io/examples/application/deployment.yaml + ```shell + kubectl apply -f https://k8s.io/examples/application/deployment.yaml + ``` 1. Display information about the Deployment: - kubectl describe deployment nginx-deployment + ```shell + kubectl describe deployment nginx-deployment + ``` - The output is similar to this: + The output is similar to this: - Name: nginx-deployment - Namespace: default - CreationTimestamp: Tue, 30 Aug 2016 18:11:37 -0700 - Labels: app=nginx - Annotations: deployment.kubernetes.io/revision=1 - Selector: app=nginx - Replicas: 2 desired | 2 updated | 2 total | 2 available | 0 unavailable - StrategyType: RollingUpdate - MinReadySeconds: 0 - RollingUpdateStrategy: 1 max unavailable, 1 max surge - Pod Template: - Labels: app=nginx - Containers: - nginx: - Image: nginx:1.14.2 - Port: 80/TCP - Environment: - Mounts: - Volumes: - Conditions: - Type Status Reason - ---- ------ ------ - Available True MinimumReplicasAvailable - Progressing True NewReplicaSetAvailable - OldReplicaSets: - NewReplicaSet: nginx-deployment-1771418926 (2/2 replicas created) - No events. + ``` + Name: nginx-deployment + Namespace: default + CreationTimestamp: Tue, 30 Aug 2016 18:11:37 -0700 + Labels: app=nginx + Annotations: deployment.kubernetes.io/revision=1 + Selector: app=nginx + Replicas: 2 desired | 2 updated | 2 total | 2 available | 0 unavailable + StrategyType: RollingUpdate + MinReadySeconds: 0 + RollingUpdateStrategy: 1 max unavailable, 1 max surge + Pod Template: + Labels: app=nginx + Containers: + nginx: + Image: nginx:1.14.2 + Port: 80/TCP + Environment: + Mounts: + Volumes: + Conditions: + Type Status Reason + ---- ------ ------ + Available True MinimumReplicasAvailable + Progressing True NewReplicaSetAvailable + OldReplicaSets: + NewReplicaSet: nginx-deployment-1771418926 (2/2 replicas created) + No events. + ``` 1. List the Pods created by the deployment: - kubectl get pods -l app=nginx + ```shell + kubectl get pods -l app=nginx + ``` - The output is similar to this: + The output is similar to this: - NAME READY STATUS RESTARTS AGE - nginx-deployment-1771418926-7o5ns 1/1 Running 0 16h - nginx-deployment-1771418926-r18az 1/1 Running 0 16h + ``` + NAME READY STATUS RESTARTS AGE + nginx-deployment-1771418926-7o5ns 1/1 Running 0 16h + nginx-deployment-1771418926-r18az 1/1 Running 0 16h + ``` 1. Display information about a Pod: - kubectl describe pod + ```shell + kubectl describe pod + ``` - where `` is the name of one of your Pods. + where `` is the name of one of your Pods. ## Updating the deployment @@ -104,11 +104,15 @@ specifies that the deployment should be updated to use nginx 1.16.1. 1. Apply the new YAML file: - kubectl apply -f https://k8s.io/examples/application/deployment-update.yaml + ```shell + kubectl apply -f https://k8s.io/examples/application/deployment-update.yaml + ``` 1. Watch the deployment create pods with new names and delete the old pods: - kubectl get pods -l app=nginx + ```shell + kubectl get pods -l app=nginx + ``` ## Scaling the application by increasing the replica count @@ -120,25 +124,33 @@ should have four Pods: 1. Apply the new YAML file: - kubectl apply -f https://k8s.io/examples/application/deployment-scale.yaml + ```shell + kubectl apply -f https://k8s.io/examples/application/deployment-scale.yaml + ``` 1. Verify that the Deployment has four Pods: - kubectl get pods -l app=nginx + ```shell + kubectl get pods -l app=nginx + ``` - The output is similar to this: + The output is similar to this: - NAME READY STATUS RESTARTS AGE - nginx-deployment-148880595-4zdqq 1/1 Running 0 25s - nginx-deployment-148880595-6zgi1 1/1 Running 0 25s - nginx-deployment-148880595-fxcez 1/1 Running 0 2m - nginx-deployment-148880595-rwovn 1/1 Running 0 2m + ``` + NAME READY STATUS RESTARTS AGE + nginx-deployment-148880595-4zdqq 1/1 Running 0 25s + nginx-deployment-148880595-6zgi1 1/1 Running 0 25s + nginx-deployment-148880595-fxcez 1/1 Running 0 2m + nginx-deployment-148880595-rwovn 1/1 Running 0 2m + ``` ## Deleting a deployment Delete the deployment by name: - kubectl delete deployment nginx-deployment +```shell +kubectl delete deployment nginx-deployment +``` ## ReplicationControllers -- the Old Way @@ -147,14 +159,6 @@ which in turn uses a ReplicaSet. Before the Deployment and ReplicaSet were added to Kubernetes, replicated applications were configured using a [ReplicationController](/docs/concepts/workloads/controllers/replicationcontroller/). - - - ## {{% heading "whatsnext" %}} - -* Learn more about [Deployment objects](/docs/concepts/workloads/controllers/deployment/). - - - - +- Learn more about [Deployment objects](/docs/concepts/workloads/controllers/deployment/).