github.com/googlecloudplatform/kubernetes-workshops@v0.0.0-20180501174420-d8199445b2c3/bundles/kubernetes-101/workshop/labs/creating-and-managing-deployments.md (about)

     1  # Creating and Managing Deployments
     2  
     3  Deployments abstract away the low level details of managing Pods. Pods are tied to the lifetime of the node they are created on. When the node goes away so does the Pod. ReplicaSets can be used to ensure one or more replicas of a Pods are always running, even when nodes fail.
     4  
     5  Deployments sit on top of ReplicaSets and add the ability to define how updates to Pods should be rolled out.
     6  
     7  In this lab we will combine everything we learned about Pods and Services to breakup the monolith application into smaller Services. You will create 3 deployments, one for each service:
     8  
     9  * frontend 
    10  * auth
    11  * hello
    12  
    13  You will also define internal services for the `auth` and `hello` deployments and an external service for the `frontend` deployment.
    14  
    15  ## Tutorial: Creating Deployments
    16  
    17  ### Create and Expose the Auth Deployment
    18  
    19  ```
    20  kubectl create -f deployments/auth.yaml
    21  ```
    22  
    23  ```
    24  kubectl describe deployments auth
    25  ```
    26  
    27  ```
    28  kubectl create -f services/auth.yaml
    29  ```
    30  
    31  ### Create and Expose the Hello Deployment
    32  
    33  ```
    34  kubectl create -f deployments/hello.yaml
    35  ```
    36  
    37  ```
    38  kubectl describe deployments hello
    39  ```
    40  
    41  ```
    42  kubectl create -f services/hello.yaml
    43  ```
    44  
    45  ### Create and Expose the Frontend Deployment
    46  
    47  
    48  ```
    49  kubectl create configmap nginx-frontend-conf --from-file=nginx/frontend.conf
    50  ```
    51  
    52  ```
    53  kubectl create -f deployments/frontend.yaml
    54  ```
    55  
    56  ```
    57  kubectl create -f services/frontend.yaml
    58  ```
    59  
    60  ## Tutorial: Scaling Deployments
    61  
    62  Behind the scenes Deployments manage ReplicaSets. Each deployment is mapped to one active ReplicaSet. Use the `kubectl get replicasets` command to view the current set of replicas.
    63  
    64  ```
    65  kubectl get replicasets
    66  ```
    67  
    68  ReplicaSets are scaled through the Deployment for each service and can be scaled independently. Use the `kubectl scale` command to scale the hello deployment:
    69  
    70  ```
    71  kubectl scale deployments hello --replicas=3
    72  ```
    73  
    74  ```
    75  kubectl describe deployments hello
    76  ```
    77  
    78  ```
    79  kubectl get pods
    80  ```
    81  
    82  ```
    83  kubectl get replicasets
    84  ```
    85  
    86  ## Exercise: Scaling Deployments
    87  
    88  In this exercise you will scale the `frontend` deployment using an existing deployment configuration file.
    89  
    90  ### Hints
    91  
    92  ```
    93  vim deployments/frontend.yaml
    94  ```
    95  
    96  ```
    97  kubectl apply -f deployments/frontend.yaml
    98  ```
    99  
   100  ## Exercise: Interact with the Frontend Service
   101  
   102  ### Hints
   103  
   104  ```
   105  kubectl get services frontend
   106  ```
   107  
   108  ```
   109  curl -k https://<EXTERNAL-IP>
   110  ```
   111  
   112  ## Summary
   113  
   114  Deployments are the preferred way to manage application deployments. You learned how to create, expose and scale deployments.