Podman can be used to capture the configuration of local containers and pods and export them to a Kubernetes YAML file. In this lab, we’re going to examine how interoperability between Podman and Kubernetes works by using Podman to generate a YAML configuration file. We’ll use both Kubernetes and Podman to run the pod defined in our YAML file. Upon completion of this lab, you will have a solid understanding of how Podman interoperates with Kubernetes.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Create an nginx Podman Pod
Before you can create a YAML file, you need a pod and some containers. First, create an
nginx
pod.Perform the following tasks:
- Check for existing pods and containers.
- Create a Podman pod named
test-pod
with port80
published to8080
. - Start the
nginx
container:- Put it in the
test-pod
pod. - Set
restart
toalways
. - Set the name to
test-nginx
. - Use the
nginx
short name for the container image.
- Put it in the
- Check again for pods and containers.
- Test the
nginx
pod withcurl
and a web browser.
- Generate a Kubernetes YAML File
Use the
podman generate kube
command to generate your Kubernetes YAML file.Perform the following tasks:
- Check again for pods and containers.
- Create a YAML file from your
test-pod
pod.- Name the file
test-pod.yml
.
- Name the file
- Examine the
test-pod.yml
file. - Clean up all Podman pods, containers, and images before proceeding.
- Execute Your Podman-Generated Kubernetes YAML File Using Podman
Use Podman to run the pod defined in your
test-pod.yml
file.Perform the following tasks:
- Check for existing pods and containers.
- Run the pod from your
test-pod.yml
YAML file. - Check again for pods and containers.
- Test the
nginx
pod withcurl
and a web browser. - Clean up all Podman pods, containers, and images before proceeding.
- Install and Start MicroK8s
Before you can try to run your YAML file, you need to install and start MicroK8s. 3 scripts have been provided to do this in the
cloud_user
home directory. Run them in the following order:microk8s_1.sh
, thenmicrok8s_2.sh
, and finallymicrok8s_3.sh
. The first 2 scripts need to be run withsudo
. The third must be run withoutsudo
. Wait a minute between scripts 1 and 2 so thatsnapd
can fully initialize.Note: You will need to log out of the lab server after script 2, and then log back in.
- Execute Your Podman-Generated Kubernetes YAML File Using MicroK8s
Use MicroK8s to create your
nginx
pod using thetest-pod.yml
YAML file.Perform the following tasks:
- Check to see if you have any Kubernetes pods.
- Create your
nginx
pod using yourtest-pod.yml
file. - Check again to see if you have any Kubernetes pods.
- Get more information on the details and status of your pod.
- Test the
nginx
pod withcurl
and a web browser. - Remove your
test-pod
pod. - Check again to see if you have any Kubernetes pods.