☸️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

Noted:

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

<service_name>.<namespace>.svc.cluster.local orange = domain

Why we need to isolate namespace ?

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

// 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>

Last updated