Understand Kubernetes Objects — Namespace

  • Create a namespace using Kubernetes manifest file
  • Delete the namespace using kubectl
  • Find details about the namespace using kubectl

Kubernetes Objects

Kubernetes or K8s as it is commonly called has support for different types of objects. It provides different ways to create basic objects like Namespace, Pod, Volume, Service, etc. There are higher level API’s which make use of the basic objects. These include things like Deployment, ReplicaSet, StatefulSet, DemonSet etc. To start with, we will look at the most basic objects and in the later part of the series revisit other objects as and when the need arises.

Namespaces

Namespaces is simple concept which is quite powerful in nature. It allows us to define logical cluster within a physical Kubernetes cluster. Imagine that a Kubernetes cluster is shared by two or more teams. They have the need to isolate each others services within Kubernetes environment. Namespace can be used for this purpose. Another example of using namespace could be to make logical separation of the same Kubernetes cluster for different environments like Dev, QA etc.

Create namespace using kubectl

Lets see how we can create namespace using Kubernetes CLI, kubectl. Fire up the terminal of your choice and execute the following command

kubectl create namespace abc2018sg

Create namespace using Kubernetes manifest

kubectl create –-filename 00_ABCNamespace.yml

Delete namespace using kubectl

Deleting a namespace using kubectl is as simple as creating a namespace. Run the following command in the terminal

kubectl delete namespace abc2018sg

Find details about namespace using kubectl & dashboard

kubectl provides a helpful command named describe which can be used to get details about different objects. We can use it to describe the namespace as follows

kubectl describe namespace abc2018sg

Conclusion

In this post we saw basic Kubernetes object namespace. As the series progresses, we will discover more objects based on their relevance. Lets conclude this post with a feeling of getting started with Kubernetes using both the Kubernetes CLI as well as the manifest files. There is a wonderful cheatsheet available for Kubernetes. I personally found this quite handy when getting started with Kubernetes. In the next post we will look at another building blocks in Kubernetes the Pod and Deployment. We will be able to put the namespace that we created today to good use in the future parts of this series. Most of the resources we will create, will be part of the namespace abc2018sg.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nilesh Gule

Nilesh Gule

Passionate about software development lives with a motto of Code with Passion and Strive for Excellence. Actively blogs at www.HandsOnArchitect.com.