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.
- Open the Terminal.
- Navigate to the Downloads folder.
cd ./Downloads
- Use the following command to create an empty YAML file in your Downloads folder.
touch pod.yaml
- Use the nano text editor in the Terminal.
nano pod.yaml
- Copy and paste the configuration below into the text editor.
- Press Cmd + X, then type Y and press Return to save the pod.yaml file.
- Open the command prompt.
- Navigate to the Downloads folder.
cd ./Downloads
- Use the following command to create an empty YAML file in your Downloads folder.
copy NUL pod.yaml
- Open the pod.yaml file with a text editor.
- Copy and paste the configuration below into the text editor.
- Save the pod.yaml file.
- Open the Terminal.
- Navigate to the Downloads folder.
cd ./Downloads
- Use the following command to create an empty YAML file in your Downloads folder.
touch pod.yaml
- Use the nano text editor in the Terminal.
nano pod.yaml
- Copy and paste the configuration below into the text editor.
- Press Cmd + X, then type Y and press Return to save the pod.yaml file.
Add a Pod¶
- In the Terminal or Command Prompt, get a list of all the pods in your environment.
microk8s kubectl get pods -A
- Use the following command to add the pod to your environment using a YAML file.
microk8s kubectl create -f pod.yaml
- 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"