DEV Community

Cover image for 3.Setup Kubernetes Namespaces and PODs
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

3.Setup Kubernetes Namespaces and PODs

Lab Information

The Nautilus DevOps team is planning to deploy some micro services on Kubernetes platform. The team has already set up a Kubernetes cluster and now they want to set up some namespaces, deployments etc. Based on the current requirements, the team has shared some details as below:

Create a namespace named dev and deploy a POD within it. Name the pod dev-nginx-pod and use the nginx image with the latest tag. Ensure to specify the tag as nginx:latest.

Note: The kubectl utility on jump_host is configured to operate with the Kubernetes cluster.

Lab Solutions

Step 1: Create the Namespace

Create the dev namespace

kubectl create namespace dev
Enter fullscreen mode Exit fullscreen mode

Step 2: Create the Nginx Pod in the dev Namespace

# Create the nginx pod in the dev namespace
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
  name: dev-nginx-pod
  namespace: dev
spec:
  containers:
  - name: nginx-container
    image: nginx:latest
    ports:
    - containerPort: 80
EOF
Enter fullscreen mode Exit fullscreen mode

Step 3: Verification
Check if the namespace was created:

kubectl get namespaces | grep dev
Enter fullscreen mode Exit fullscreen mode

Check if the pod is running in the dev namespace:

kubectl get pods -n dev
Enter fullscreen mode Exit fullscreen mode

Get detailed information about the pod:

kubectl describe pod dev-nginx-pod -n dev
Enter fullscreen mode Exit fullscreen mode

Check the pod logs to ensure nginx started correctly:

kubectl logs dev-nginx-pod -n dev
Enter fullscreen mode Exit fullscreen mode


Resources & Next Steps
📦 Full Code Repository: KodeKloud Learning Labs
📖 More Deep Dives: Whispering Cloud Insights - Read other technical articles
💬 Join Discussion: DEV Community - Share your thoughts and questions
💼 Let's Connect: LinkedIn - I'd love to connect with you

Credits
• All labs are from: KodeKloud
• I sincerely appreciate your provision of these valuable resources.

Top comments (0)