Kubernetes Namespaces - LimitRange - Declarative using YAML¶
Step-01: Create Namespace manifest¶
- Important Note: File name starts with
00-so that when creating k8s objects namespace will get created first so it don't throw an error.
Azure Kubernetes Service with Azure DevOps and Terraform¶
Step-02: Create LimitRange manifest¶
- Instead of specifying
resources like cpu and memoryin every container spec of a pod defintion, we can provide the default CPU & Memory for all containers in a namespace usingLimitRangeapiVersion: v1 kind: ResourceQuota metadata: name: ns-resource-quota namespace: dev3 spec: limits: - default: memory: "512Mi" # If not specified the Container's memory limit is set to 512Mi, which is the default memory limit for the namespace. cpu: "500m" # If not specified default limit is 1 vCPU per container defaultRequest: memory: "256Mi" # If not specified default it will take from whatever specified in limits.default.memory cpu: "300m" # If not specified default it will take from whatever specified in limits.default.cpu type: Container
Step-03: Update all k8s manifest with namespace¶
- Update all files from with
namespace: dev3in top metadata section in folderkube-manifests/ - Example
# Deployment Manifest metadata section apiVersion: apps/v1 kind: Deployment metadata: name: app1-nginx-deployment labels: app: app1-nginx namespace: dev3 # Added namespace spec: # Service Manifest metadata section apiVersion: v1 kind: Service metadata: name: app1-nginx-clusterip-service labels: app: app1-nginx namespace: dev3 # Added namespace spec:
Step-04: Create k8s objects & Test¶
# Create All Objects
kubectl apply -f kube-manifests/
# List Pods
kubectl get pods -n dev3
# View Pod Specification (CPU & Memory)
kubectl get pod <pod-name> -o yaml -n dev3
# Get & Describe Limits
kubectl get limits -n dev3
kubectl describe limits default-cpu-mem-limit-range -n dev3
# List Services
kubectl get svc -n dev3
# Access Application
http://<Public-IP-from-List-Services-Output>/app1/index.html
Step-05: Clean-Up¶
- Delete all k8s objects created as part of this section
References:¶
- https://kubernetes.io/docs/tasks/administer-cluster/namespaces-walkthrough/
- https://kubernetes.io/docs/tasks/administer-cluster/manage-resources/cpu-default-namespace/
- https://kubernetes.io/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/
Best Selling Azure Kubernetes Service Course on Udemy¶
Best Selling AWS EKS Kubernetes Course on Udemy¶
HashiCorp Certified Terraform Associate - 50 Practical Demos¶
🎉 New Course
Ultimate DevOps Real-World Project Implementation on AWS
$15.99
$84.99
81% OFF
DEVOPS2026FEB
Enroll Now on Udemy
🎉 Offer



