DEV Community

Cover image for #048 Kubernetes - namespaces 1
Omar
Omar

Posted on

3 2

#048 Kubernetes - namespaces 1

Introduction

intro

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


Namespaces

ns

namespace in general is logical separator used to make sure that process or in case of programming variables with same name are isolated by a logical name.
In Kubernetes it is the same we use namespaces in large projects to divide a cluster into small isolated clusters using namespaces.


Lab

mad

the default Kubernetes is guess what? default.
to get namespaces we type
ns

kubectl get ns
Enter fullscreen mode Exit fullscreen mode

ns is shortcut of namespaces.
let's get the pods list
po

kubectl get po
Enter fullscreen mode Exit fullscreen mode

po is shortcut of pods
to get the pods under default namespace
nsd

kubectl get po -n default
Enter fullscreen mode Exit fullscreen mode

-n is shortcut of --namespace.

it get all the pods because all my pods are in namespace.
ns

kubectl create ns test-k
Enter fullscreen mode Exit fullscreen mode

test-k is the namespace if i get the pods under this namespace
tk

kubectl get po -n test-k
Enter fullscreen mode Exit fullscreen mode

it's empty. That's is the use of it , now I can have sub clusters inside a cluster.
also same as old way we can separate pods created using a yml file

kubectl create -f ex.yml -n tesk-k
Enter fullscreen mode Exit fullscreen mode

or we can specify namespace inside the yml file himself.

Heroku

Deliver your unique apps, your own way.

Heroku tackles the toil — patching and upgrading, 24/7 ops and security, build systems, failovers, and more. Stay focused on building great data-driven applications.

Learn More

Top comments (0)

Sentry image

Make it make sense

Only the context you need to fix your broken code with Sentry.

Start debugging →

👋 Kindness is contagious

Dive into this insightful write-up, celebrated within the collaborative DEV Community. Developers at any stage are invited to contribute and elevate our shared skills.

A simple "thank you" can boost someone’s spirits—leave your kudos in the comments!

On DEV, exchanging ideas fuels progress and deepens our connections. If this post helped you, a brief note of thanks goes a long way.

Okay