Develop containers using Podman Desktop and Kubernetes

Podman Desktop is a lightweight and efficient tool for managing containers and working with Kubernetes from your Windows, macOS, or Linux machine. From building container images to working with registries and deploying containers, Podman Desktop helps you seamlessly work with containerization technology, and simplifies the transition to container deployment on Kubernetes.

This learning path, created by Don Schenck, demonstrates how you can go from an initial application to a container to a fully running pod on Kubernetes using Podman Desktop and the no-cost Developer Sandbox for Red Hat OpenShift.

Access the Developer Sandbox

Now it's time to start the previously built image and remotely hosted image (Redis) on your local machine with Podman, and interact with them inside of Podman Desktop.

Step 19: Create a new pod

Building this solution involves the following:

  1. Creating a virtual network named “podify” using podman network, which sets up an exclusive communication channel for our application via a private network.
  2. Starting a container running a Redis cache using podman run, which launches a self-container container environment running a Redis database.
  3. Starting a container running the front-end image you specify using podman run, being the Python application you just created.

Using the image name from the image you've already created, run the following command in the working directory:

  • If using Bash:

    ./preload.sh {image-name-goes-here}
  • If using PowerShell:

    ./preload.ps1 {image-name-goes-here}

Here’s a PowerShell example:

.\preload.ps1 quay.io/donschenck/podify-demo-frontend:v1
Starting image quay.io/donschenck/podify-demo-frontend:v1
redis
642fef0f59a352ff5135f7daecb38d69cef45637dd23fa8550018f23366276cb
python-frontend
76702149c5b58e9a5a87e901e995e805e318158ff8edd4dc65d9f95e80db067d

Step 20: Deploy the pod

To finish connecting Podman Desktop to your Developer Sandbox instance and add the OpenShift cluster, simply paste the login command and hit Create (Figure 18). This adds an entry to your system’s kubeconfig file, which is used to connect and authenticate with a Kubernetes cluster.

To finish connecting Podman Desktop to your Developer Sandbox instance and add the OpenShift cluster, paste the login command and hit Create.
Figure 18: Create a new OpenShift cluster connection.

In the Pods view of Podman Desktop, click the kebab menu for the pod you created in the previous step and choose the Deploy to Kubernetes option. When prompted, click the Deploy button (Figure 19).

Click the kebob menu for the pod you created and choose the “Deploy to Kubernetes” option. When prompted, click the Deploy button.
Figure 19: Click the kebob menu for the pod you created and choose the Deploy to Kubernetes option. When prompted, click the Deploy button.

Step 21: View the new results in your OpenShift dashboard

Switch to your Developer Sandbox Topology view and you will see the pod. By clicking on the Open URL icon, you can view the website in your browser (Figure 20).

The front-end website view in your browser.
Figure 20: The front-end website view in your browser.

Refresh the browser multiple times to see the counter increment.

If you return to the Pods section of Podman Desktop, you will notice that this new pod—running in your sandbox—is now reflected in the list (Figure 21).

If you return to the Pods section of Podman Desktop, you will notice that this new pod is reflected in the list.
Figure 21: If you return to the Pods section, your new pod is visible.

Switch to the Developer Sandbox Topology view and you will see the pod. By clicking on the Open URL icon, you can view the website in your browser.

Developer notes

The image that is created starts by running the script startup.sh inside the container. This trick allows you to change an environment variable at startup time, versus at build time.

Move it, remove it, improve it

Now that you know how to create, manage, and deploy containers, here are some other ideas to try.

Move it

You can download all of the YAML files associated with this application and use them to move it to another OpenShift instance by using the Export Application button in the upper right corner of the OpenShift dashboard.

Remove it

You can remove parts of this activity; here’s an example:

  • oc delete all -l app=my-pod

Improve it

If you want to improve or alter this activity:


What did you accomplish?

Through this learning path activity, you’ve been introduced to key concepts such as containers, images, and pods, and learn to use tools like Podman Desktop for container management and Kubernetes for container orchestration. By following the instructions, you should now have two versions of the application running in your Developer Sandbox, and you can iterate over steps multiple times until you reach the result you want.

Resources

Red Hat Developer provides a variety of resources to help streamline and enhance the efficiency of container development, including:

Previous resource
Update to a local solution