#039 Kubernetes - Deployment Lab 1
Tags: kubernetes, devops, tutorial
Published: 2020-07-23 20:21:43

# Introduction

this is part 39 from the journey it's a long journey(360 day) so go please check previous parts , and if you need to walk in the journey with me please make sure to follow because I may post more than once in 1 Day but surely I will post daily at least one 😍.

And I will cover lot of tools as we move on.
***
# Files for this lab

all the files can be found on the repository of this journey , if you already have it just pull if not clone it.
Files can be found [here](https://github.com/OmarElKhatibCS/DevOpsJourney/tree/master/app_039)
***

# Lab
the way to create deployment is very similar to replicasets instead we just change the kind to deployment.
here is a look at the app_039.yml
![app39](https://dev-to-uploads.s3.amazonaws.com/i/b1hyx2li74l8a1m2tbw3.png)
you can see it's the same we only change kind.

now to create our deployment we also do the same as replicas .
![create](https://dev-to-uploads.s3.amazonaws.com/i/umx6y5w0038m43rqdwmr.png)
```bash
kubectl create -f app_039.yml
```
we got a message that our deployment successfully created.
![dep](https://dev-to-uploads.s3.amazonaws.com/i/2udkzt5qnobn7qk9ihxs.png)
```bash
kubectl get deployments
```
he can see we have 1 deployment that we created right now.
![rs](https://dev-to-uploads.s3.amazonaws.com/i/6bmyhrf7kwso8rvy1nt8.png)
```bash
kubectl get rs
```
rs here is the shortcut of replicasets (yes we can use shortcuts in kubectl :D )
we can see he take the name of the deployment and give here and id.
![pods](https://dev-to-uploads.s3.amazonaws.com/i/orwasxrij42prpl29zfk.png)
```bash
kubectl get pods
```
we can see also he create 6 deployments for us (6 is what we specify in yml)
![desc1](https://dev-to-uploads.s3.amazonaws.com/i/pmzoviaf0ndy6xlru1gr.png)
```bash
kubectl describe deployments myapp-deployment
```
we can describe the deployment using the command above (also we can describe the pod , I talk about it before).
here we got useful information about it as labels Image ports etc...
![desc2](https://dev-to-uploads.s3.amazonaws.com/i/sx4jpg25kucwno1u950l.png)
if we scroll down we see events , those are helpful in case we have errors , so we know where and when problem happens.
***
# Take a stretch
![stretch](https://media1.tenor.com/images/b24b65a1385efe772e25ff778b3fe795/tenor.gif?itemid=13149334)
***
# Back to lab
now to see what versions I made in deployment (history) We type
![roll-out](https://dev-to-uploads.s3.amazonaws.com/i/9jrys0rk4rar8gh6n2vd.png)
```bash
kubectl rollout history deployment/myapp-deployment
```
we can see CHANGE-CAUSE is <none> because I didn't record what I edit when I create the deployment.
Record is important (like git commit) to get information about what I do in these version in case I need to go back to it later.
let's delete our deployment and made new one with record
![del](https://dev-to-uploads.s3.amazonaws.com/i/wnh43gdjth4babiul5t2.png)
```bash
kubectl delete deployments myapp-deployment
```
he will delete all the things related to it , replicas , pods and history.
![delete](https://dev-to-uploads.s3.amazonaws.com/i/9nagshcdtj3be4fr466p.png)
```bash
kubectl get pods
```
if we get the pods we see they start to terminate then deleted.
![record](https://dev-to-uploads.s3.amazonaws.com/i/jvsqkal5m0sqsvqy8jms.png)

```bash
kubectl create -f app_039.yml --record
```
We recreate it with --record
![his](https://dev-to-uploads.s3.amazonaws.com/i/hhcgepvdw7qddax9i7l6.png)
```bash
kubectl rollout history deployment/myapp-deployment
```
We can see in the History we have the record of what we do in this REVISION 1.
That's it for this one see ya in lab 2 :)