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:
- Creating a virtual network named “podify” using
podman network
, which sets up an exclusive communication channel for our application via a private network. - Starting a container running a Redis cache using
podman run
, which launches a self-container container environment running a Redis database. - 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.
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).
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).
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).
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:
- When you have your final build, consider creating a deployment in your sandbox by building it from a container image.
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:
- OpenShift Toolkit for VSCode and IntelliJ helps develop, build, and test containerized applications on Kubernetes directly within the individual development environment (IDE).
- Working with Kubernetes in Podman Desktop explains how to transition from development to production and the capabilities offered in Podman Desktop.