Pages

Sunday, May 13, 2018

Kubernetes - Configuration & Name Spaces

Namespace can be taught like a project where multiple users or team of users can work. A team can create a namespace say “Project1” to deploy their work in containers in the namespace. The namespace can be isolated from other namespaces so that people can work only in their name spaces.

Namespaces are a logical partitioning capability that enables one kubernetes cluster to be used by multiple users, teams of users or a single user with multiple applications.

Each user, team of users or application exists in namespace isolated from other users and application and making to think as if they were sole user of the clusters.

Namespaces provide for a scope of Kubernetes objects. You can think of it as a workspace you’re sharing with other users. Many objects such as pods and services are namespaced, while some (like nodes) are not.

To create a namespace , Create a manifest file “development-ns.yml” with the below contents as,
kind: "Namespace"
apiVersion: "v1"
metadata:
 name: "development"
 labels:
   name: "development"

Once file is available , create a development namespace by passing the above file as an argument to the kubectl command,

[root@manja17-I13330 kubetesting]# kubectl create -f development-ns.yml
namespace "development" created

Now check the namespace using
[root@manja17-I13330 kubetesting]# kubectl get namespaces
NAME                STATUS    AGE
default              Active        1d
development     Active        12s
kube-public       Active        1d
kube-system    Active         1d

If we need to create a pod in a namespace we can use the command,
[root@manja17-I13330]# kubectl create --namespace=sample-testing -f basic-pod-in-namespace.yml
pod "sample-testing" created

So all other resources like pod, services etc can be created in namespace. To see what in
namespace we have to pass the “--namespace=<name>” argument with the command.

No comments :

Post a Comment