From Kubernetes Namespaces to OpenShift Projects
In many meetings, I witnessed that a lot of participants have missing or incorrect information about Kubernetes core concepts.
So I decided to begin a series of articles about the Kubernetes core concepts. In this one, I’m gonna try to find answers to the questions like:
What are Kubernetes namespaces & OpenShift Projects?
What is the motivation to use them?
What’s the difference between namespaces and projects?
And will be some extras.
When it comes to work in understanding a new concept, creating lists is very helpful. So let’s make it together:
- are a mechanism for resource groups’ isolation in a single cluster.
- allow to divide cluster resources between multiple users via resource quota.
- shouldn’t be named with the prefix “kube-” ; It’s reserved for Kubernetes system namespaces.
- that Kubernetes initiated with and purposes:
- default objects with no other namespaces
- kube-system for objects created by Kubernetes system
- kube-public for resources should be visible and readable publicly
- kube-node-lease for detecting node failures by control plane
- should be valid to RFC 1035 Label Names
- contain at most 63 characters
- contain only lowercase alphanumeric characters or ‘-’
- start with an alphabetic character
- end with an alphanumeric character
- don’t include all objects. (nodes, persistentVolumes, StorageClasses etc. are not namespaced)
- help different projects, teams or customers to share a Kubernetes cluster.
# namespace yaml example.
Namespaces provide a mechanism to attach authorization and policy to a subsection of the cluster.
- encapsulates namespace in the name of security and manageability
- access is must be given to regular users by cluster admin. It’s possible to allow regular users to create projects
- can have a separate
- scopes its own set of
Don’t forget that you can still create a namespace with
oc create namespace <namespace>command. It’s usually necessary for operator installation.
Switching Between Namespaces or Projects
Normally, If you are not working with default namespace/project in cluster, you have to specify the namespace in every command. But there is an easy way:
For Kubernetes namespaces, It’s essential to assign a context to each namespace to switch between them by contexts.
You can use any namespace as default while running commands with the method above.
For OpenShift projects, It’s easier.
Namespaces Stucked in Terminating State
Namespace deleting might be boring from time to time. Even if you clean the resources before sending delete command to cluster, It might stuck in terminating state.
whether single or many, you can delete namespaces stuck as terminating situation by a shell script that I wrote:
GitHub - ugurserhattoy/DTN: Delete Terminating Namespaces
Delete multiple namespaces stucked as Terminating
Don’t hesitate to take a look.
The utility deletes multiple namespaces stuck as terminating
- bash shell
- user able to run kubectl command
How to Use
After that, instructions & questions will guide you.
Share a Cluster with Namespaces
This page shows how to view, work in, and delete namespaces. The page also shows how to use Kubernetes namespaces to…