Running Containers with Kubernetes

Create an Nginx Pod to Function as a Simple Web Server

  • Create a Pod running a container with the nginx image

  • Expose port 80 in order to communicate with Nginx once it is running

nginx-pod.yml

apiVersion: v1
kind: Pod
metadata:
    name: nginx-pod
spec:
    containers:
    - name: nginx
      image: nginx 
     ports:
     - containerPort: 80      
kubectl create -f nginx-pod.yml

Run a Redis Instance Using a Kubernetes Pod

  • Create a Pod running a container with the redis image

redis-pod.yml

apiVersion: v1
kind: Pod
metadata:
    name: redis-pod
spec:
    containers:
    - name: redis
      image: redis  

Check Nginx Container Logs

  • View the logs from the Nginx container

Last updated