DEV Community

Cover image for #039 Kubernetes - Deployment Lab 1
Omar
Omar

Posted on

#039 Kubernetes - Deployment Lab 1

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


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
you can see it's the same we only change kind.

now to create our deployment we also do the same as replicas .
create

kubectl create -f app_039.yml
Enter fullscreen mode Exit fullscreen mode

we got a message that our deployment successfully created.
dep

kubectl get deployments
Enter fullscreen mode Exit fullscreen mode

he can see we have 1 deployment that we created right now.
rs

kubectl get rs
Enter fullscreen mode Exit fullscreen mode

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

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

we can see also he create 6 deployments for us (6 is what we specify in yml)
desc1

kubectl describe deployments myapp-deployment
Enter fullscreen mode Exit fullscreen mode

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
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


Back to lab

now to see what versions I made in deployment (history) We type
roll-out

kubectl rollout history deployment/myapp-deployment
Enter fullscreen mode Exit fullscreen mode

we can see CHANGE-CAUSE is 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

kubectl delete deployments myapp-deployment
Enter fullscreen mode Exit fullscreen mode

he will delete all the things related to it , replicas , pods and history.
delete

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

if we get the pods we see they start to terminate then deleted.
record

kubectl create -f app_039.yml --record
Enter fullscreen mode Exit fullscreen mode

We recreate it with --record
his

kubectl rollout history deployment/myapp-deployment
Enter fullscreen mode Exit fullscreen mode

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 :)

Top comments (0)