Setup Kubernetes Namespaces and PODs
![Abishek Kafle](https://cdn.hashnode.com/res/hashnode/image/upload/v1726213286603/488379c0-3bf8-45ec-afb8-db5ac8509d5c.jpeg)
1 min read
![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728895051410/ff7bd2c8-4942-461d-992c-3ce2f8626e94.png)
Tasks
Create a namespace named
dev
.Deploy a pod named
dev-nginx-pod
in thedev
namespace.Use the
nginx
image with thelatest
tag for the pod.Ensure to specify the image tag as
nginx:latest
.
Steps
First create the namespace named dev.
kubectl create namespace dev
Manifest with
yaml file
:apiversion: v1 kind: Namespace metadata: name: dev
But I prefer using EOF
cat <<EOF > namespace-dev.yaml apiVersion: v1 kind: Namespace metadata: name: dev EOF
Create namespace now:
kubectl create -f namespace-dev.yaml --save-config
Create pods now,
nginx-pod.yaml
apiVersion: v1 kind: Pod metadata: name: dev-nginx-pod namespace: dev spec: containers: - name: nginx image: nginx:latest
Apply the YAML manifest file.
kubectl apply -f nginx-pod.yaml
Now List Namespaces
kubectl get namespaces
List Pods in a Namespace
kubectl get pods -n dev
#k8s #kubernetes #pods #namespace #happylearning :)
0
Subscribe to my newsletter
Read articles from Abishek Kafle directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
![Abishek Kafle](https://cdn.hashnode.com/res/hashnode/image/upload/v1726213286603/488379c0-3bf8-45ec-afb8-db5ac8509d5c.jpeg)
Abishek Kafle
Abishek Kafle
Infosec Poet and CAP-certified DevOps/SecOps Engineer, passionate about security, creativity, and continuous learning.