Skip to content

Part 2: Using Pods

This is Part 2 of a multi-part, self-paced quick start exercise.

Note

This exercise requires MicroK8s. If you do not have these already installed and running, see "Prerequisites".


What Will You Do

In part 2, you will:

  • Use Pods in your namespaces.

Estimated Time

Estimated time for this exercise is 10 minutes. Watch a video of the exercise below.


Using Pods

Pods are the smallest deployable units of computing that you can create and manage in Kubernetes. For this exercise, you will deploy BusyBox, a small Docker image.

Pod YAML file

You can also create a pod using a YAML file, which is a configuration file. You could create a YAML file from the command line, but for this exercise, you can just use a text editor. Or you can download the pod YAML file from this public Git repository.

  1. Open the Terminal.
  2. Navigate to the Downloads folder.
    cd ./Downloads
    
  3. Use the following command to create an empty YAML file in your Downloads folder.
    touch pod.yaml
    
  4. Use the nano text editor in the Terminal.
    nano pod.yaml
    
  5. Copy and paste the configuration below into the text editor.
  6. Press Cmd + X, then type Y and press Return to save the pod.yaml file.
  1. Open the command prompt.
  2. Navigate to the Downloads folder.
    cd ./Downloads
    
  3. Use the following command to create an empty YAML file in your Downloads folder.
    copy NUL pod.yaml
    
  4. Open the pod.yaml file with a text editor.
  5. Copy and paste the configuration below into the text editor.
  6. Save the pod.yaml file.
  1. Open the Terminal.
  2. Navigate to the Downloads folder.
    cd ./Downloads
    
  3. Use the following command to create an empty YAML file in your Downloads folder.
    touch pod.yaml
    
  4. Use the nano text editor in the Terminal.
    nano pod.yaml
    
  5. Copy and paste the configuration below into the text editor.
  6. Press Cmd + X, then type Y and press Return to save the pod.yaml file.

Add a Pod

  1. In the Terminal or Command Prompt, get a list of all the pods in your environment.
    microk8s kubectl get pods -A
    
  2. Use the following command to add the pod to your environment using a YAML file.
    microk8s kubectl create -f pod.yaml
    
  3. List the pods in your environment. The "busybox-sleep" image has been added as a pod.
    microk8s kubectl get pods -A
    

pod.yaml

apiVersion: v1
kind: Pod
metadata:
  name: busybox-sleep
spec:
  containers:
  - name: busybox
    image: busybox
    args:
    - sleep
    - "1000"