DEV Community

Cover image for #032 Kubernetes - Pods lab 2
Omar
Omar

Posted on

#032 Kubernetes - Pods lab 2

Introduction

this is part 32 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.


lab

in last part we create a pod . we are going to delete this pod using
delete-pod

kubectl delete first-pod
Enter fullscreen mode Exit fullscreen mode

As we see the pod got deleted , now I am going to use another random container from docker hub , I found an container called simple-api you can take a look at it here

let's create a pod from it
create

kubectl run first-pod --image=emondek/simple-api:latest --restart=Never
Enter fullscreen mode Exit fullscreen mode

let's take a look
get-pods

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

we can see status creating container , if we need more info about it we type
describe

kubectl describe pods/first-pod
Enter fullscreen mode Exit fullscreen mode

if we scroll down we can see events
events
it's now on image pulling phase

after pulling we can see now that status is RUNNING
done

now to run this pod in browser we need services(will talk about them later) but we have a nice hack to run it for now

forward

kubectl port-forward pods/first-pod 8080 
Enter fullscreen mode Exit fullscreen mode

8080 is the port the we decide to use in dockerfile
8080

if we go to the browser and type http://localhost:8080/

we have our pod running

running

we can also access this pod using
access

kubectl exec -it first-pod -- bash
Enter fullscreen mode Exit fullscreen mode

We use -- to separate the commands that related to kubectl and linux.
And every change we make to this pod will be discarded just like container so also we need volumes here :D

Top comments (0)