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.
# Creating the namespace
kubectl create namespace dev
namespace/dev create
# Run the pod inside that namespace
kubectl run dev-nginx-pod --image=nginx:latest --namespace=dev
pod/dev-nginx-pod created
# Verify
kubectl get pods -n dev
NAME READY STATUS RESTARTS AGE
dev-nginx-pod 1/1 Running 0 2m34sYaml is more useful for versioning and repeatability, see below:
# Create the namespace
kubectl create namespace dev
# Define the yaml file - dev-nginx-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: dev-nginx-pod
namespace: dev
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
# Deploy the pod
kubectl apply -f dev-nginx-pod.yaml
# Verify
kubectl get pods -n dev
NAME READY STATUS RESTARTS AGE
dev-nginx-pod 1/1 Running 0 2m34s