Building an image and testing it in Kind
With Podman Desktop, you can build an image with your container engine, and test it in your local Kind-powered Kubernetes cluster.
Prerequisites
- You onboarded a container engine.
- You onboarded a Kind cluster.
- You have set your Kubernetes context to your local Kind-powered Kubernetes cluster.
- A container definition file:
Containerfile
orDockerfile
.
Procedure
Build your image:
- Open Images > Build an image.
- Containerfile path: select your
Containerfile
orDockerfile
. - Build context directory: optionally, select a directory different from the directory containing your
Containerfile
orDockerfile
. - Image Name: enter your image name
my-custom-image
. - Click Build.
- Wait for the image build to finish.
- Click Done to get back to the images list.
Push your image to your Kind cluster:
- Search images: enter your image name
my-custom-image
to find the image. - Click > Push image to Kind cluster.
- Search images: enter your image name
Test your image by creating a container:
- Click to open the Create a container from image dialog.
- Container name: enter
my-custom-image-container
. - Review the parameters that Podman Desktop has detected from your image definition.
- Click Start Container to start the container in your container engine.
Test your image and container on your Kind cluster:
- Search containers: enter
my-custom-image-container
to find the running container. - Click > Deploy to Kubernetes to open the Deploy generated pod to Kubernetes screen.
- Pod Name: keep the proposed value
my-custom-image-container-pod
. - Use Kubernetes Services: select Replace
hostPort
exposure on containers by Services. It is the recommended way to expose ports, as a cluster policy might prevent to usehostPort
. - Expose service locally using Kubernetes Ingress: if your container is exposing at a port, select Create a Kubernetes ingress to get access to the ports that this pod exposes, at the default ingress controller location. Example: on a default Kind cluster created with Podman Desktop:
http://localhost:9090
. Requirements: your cluster has an ingress controller`. - Optionally, if your container is exposing more than one port, select the port to expose.
- Kubernetes namespaces: select
default
. - Click Deploy.
- Wait for the pod to reach the state: Phase: Running.
- Click Done.
- Search containers: enter
Verification
- The Pods screen lists the running
my-image-container-pod
pod. - Click on the pod name to view details and logs.
- Optionally, if your container is exposing a port, go to
http://localhost:9090
: your application is running.