Home

namespaces

kube-system Default kube public

//get info about pods from an specific namespace
kubectl get pods --namesapce=kube-system
//create a pod in a specific namespace
kubectl create -f pod-definition.yml --namespace=dev

We can move the namespace definition in the pod definition file

apiVersion: v1
kind: Pod
metadata:
  name: my-app-pod
  namespace: dev
  labels:
    app: myapp
    type:frontend

spec:
  containers:
  - name: nginx-controller
    image: nginx

Creating a namespace suing definition file

apiVersion: v1
kind: Namespace
metadata:
    name: dev
kubetcl create -f namespace-dev.yml
//creating namespace using command
kubectl create namespace dev

Switching namespace

kubectl config set-context $(kubectl config current-context) --namespace=dev

View pods in all namespaces

kubectl get pods --all-namesapces

Resource Quota

apiVersion: v1
kind: ResourceQuota
metadata:
  name: compute-quota
  namespace: dev

spec:
  hard:
    pods: "10"
    request.cpu="4"
    request.memory="5Gi"
    limits.cpu="10"
    limits.memory="10Gi"

kubectl create -f compute-quota.yml