Setup Kubernetes Namespaces and PODs
Abishek Kafle
1 min read
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
Abishek Kafle
Infosec Poet and CAP-certified DevOps/SecOps Engineer, passionate about security, creativity, and continuous learning.