> For the complete documentation index, see [llms.txt](https://dev7days.gitbook.io/dev7days/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev7days.gitbook.io/dev7days/namespaces.md).

# Namespaces

Describe about What is Namespaces ?

It like a house that group all of the component such as `Pod` `Service` and we can create the separate rule of each house . \
\
In Kubernetes there are 3 namespaces that are created automatically when we first set up

1. **kube-system**
2. **default**
3. **kube-public**

**kube-system**

It is the namespace that store all configuration about the K8s system , this namespace will not allow the normal user to access

**default**

It is normal namespace when everytime you created new pod it will create in this namespace

**kube-public**

It is namespace that stored resoure and everyone can access

{% hint style="warning" %}
**Noted:**

When we would like to access service across namespace the DNS is <br>

\<service\_name>.\<namespace>.svc.<mark style="color:orange;">cluster.local</mark>\
\ <mark style="color:orange;">orange = domain</mark>
{% endhint %}

**Why we need to isolate namespace ?**

Ans:  Because we can determine the `Resource Quota` for each namespace

```yaml
// Example
apiVersion: v1
kind: ResourceQuota
metadata:
  name: object-counts
spec:
  hard:
    configmaps: "10"
    persistentvolumeclaims: "4"
    pods: "4"
    replicationcontrollers: "20"
    secrets: "10"
    services: "10"
    services.loadbalancers: "2"
```

**CheatSheet Command**

1. Change default name space: `kubectl config set-context $(kubectl config current-context) --namespace=<namespace_name>`
2. Get namespace: `kubectl get ns`
3. Get pod specify namespace : `kubectl get po -n research`
4. Create pod specify namespace: `kubectl run <pod_name> --image=<image_name> -n <namespace_name>`
