Skip to content

Commit 5d5b932

Browse files
authored
blog: added _Setting up and running a Kubernetes cluster locally_ (podman-desktop#2162)
1 parent 52b6ffb commit 5d5b932

16 files changed

+247
-2
lines changed

.vale.ini

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ RedHat.PascalCamelCase = suggestion
2929
RedHat.Slash = suggestion
3030
RedHat.Spelling = suggestion
3131
RedHat.Usage = suggestion
32+
RedHat.CaseSensitiveTerms = suggestion
3233

3334
[website/blog/*.md]
3435
RedHat.Headings = suggestion

.vale/styles/PodmanDesktop/ProductNames.yml

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ ignorecase: false
66
# swap map tokens in the form of bad: good
77
swap:
88
Podman desktop: Podman Desktop
9-
podman: '`podman` or Podman'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
---
2+
title: Setting up and running a Kubernetes cluster locally with Podman Desktop
3+
description: Setting up and running a Kubernetes cluster locally with Podman Desktop
4+
slug: running-a-local-kubernetes-cluster-with-podman-desktop
5+
authors: [themr0c]
6+
tags: [podman-desktop, story, kubernetes, kind]
7+
hide_table_of_contents: false
8+
---
9+
10+
# Setting up and running a Kubernetes cluster locally with Podman Desktop
11+
12+
In this blog post you will learn to use Podman Desktop to run the [Kubernetes documentation example: Deploying PHP Guestbook application with Redis](https://kubernetes.io/docs/tutorials/stateless-application/guestbook/).
13+
14+
On the agenda:
15+
16+
1. Installing Podman Desktop.
17+
1. Installing and initializing your container engine: Podman.
18+
1. Installing and starting your local Kubernetes provider: Kind.
19+
1. Starting the Redis leader.
20+
1. Starting and scaling the Redis followers.
21+
1. Starting and exposing the Guestbook frontend.
22+
23+
<!--truncate-->
24+
25+
## Installing Podman Desktop
26+
27+
You need Podman Desktop.
28+
29+
1. Go to [Podman Desktop installation documentation](/docs/Installation).
30+
1. Click on your platform name: [Windows](/docs/installation/windows-install), [macOS](/docs/installation/macos-install), or [Linux](/docs/installation/linux-install).
31+
1. Follow the instructions. Stick to the default installation method.
32+
1. Start **Podman Desktop**.
33+
34+
At this point, you have a graphical user interface to:
35+
36+
- Install Podman and Kind.
37+
- Control and work with your container engines and Kubernetes clusters.
38+
- Run your application on your container engine and migrate it to Kubernetes.
39+
40+
## Installing and initializing your container engine: Podman
41+
42+
Podman Desktop can control various container engines, such as:
43+
44+
- Docker
45+
- Lima
46+
- Podman
47+
48+
Consider installing the Podman container engine for:
49+
50+
- Added security
51+
- No daemon
52+
- Open source
53+
54+
Containers are a Linux technology.
55+
56+
- On Linux, you can install Podman natively.
57+
See: [Installing Podman on Linux](https://podman.io/getting-started/installation#installing-on-linux).
58+
- On macOS and Windows, Podman requires to run in a Linux virtual machine: the Podman machine.
59+
Use Podman Desktop to install Podman and initialize your Podman machine:
60+
61+
#### Procedure
62+
63+
1. Open Podman Desktop **Dashboard**
64+
1. The **Dashboard** displays _Podman Desktop was not able to find an installation of Podman_.
65+
1. Click on **Install**.
66+
1. Podman Desktop checks the prerequisites to install Podman Engine. When necessary, follow the instructions to install prerequisites.
67+
1. Podman displays the dialog: _Podman is not installed on this system, would you like to install Podman?_. Click on **Yes** to install Podman.
68+
1. Click on **Initialize and start**.
69+
70+
#### Verification
71+
72+
- The **Dashboard** displays _Podman is running_.
73+
74+
![Podman is running](img/running-a-local-kubernetes-cluster-with-podman-desktop/podman-is-running.png)
75+
76+
At this point, you can start working with containers.
77+
78+
## Installing and starting your local Kubernetes provider: Kind
79+
80+
You want to deploy your application to a local Kubernetes cluster.
81+
82+
Podman Desktop can help you run Kind-powered local Kubernetes clusters on a container engine, such as Podman.
83+
84+
Podman Desktop helps you [installing the `kind` CLI](/docs/kubernetes/kind/installing-kind):
85+
86+
1. In the status bar, click on **Kind**, and follow the prompts.
87+
1. When the `kind` CLI is available, the status bar does not display **Kind**.
88+
1. On Windows, [configure Podman in rootful mode](docs/kubernetes/kind/configuring-podman-for-kind-on-windows)
89+
90+
```shell-session
91+
$ podman system connection default podman-machine-default-root
92+
```
93+
94+
1. Go to **<icon icon="fa-solid fa-cog" size="lg" /> Settings > Resources**
95+
1. In the **<img src="/img/podman-icon.png" alt="Podman icon" style={{height: '1.5em', display: 'inline'}} /> Podman** tile, click on the **<icon icon="fa-solid fa-repeat" size="lg" />** icon to restart the Podman container engine.
96+
1. In the **<img src="/img/kind-icon.png" alt="Kind icon" style={{height: '1.5em', display: 'inline'}} /> Kind** tile, click on the **Create new** button.
97+
1. **Name**: enter `kind-cluster`.
98+
1. **Provider Type**: select `podman`.
99+
1. **HTTP Port**: select `9090`.
100+
1. **HTTPS Port**: select `9443`.
101+
1. **Setup an ingress controller**: `Enabled`
102+
1. Click the **Create** button.
103+
![Create a Kind cluster screen](img/running-a-local-kubernetes-cluster-with-podman-desktop/create-a-kind-cluster.png)
104+
1. After successful creation, click on the **Go back to resources** button
105+
106+
#### Verification
107+
108+
1. In **<icon icon="fa-solid fa-cog" size="lg" /> Settings > Resources** your Kind cluster is running/
109+
110+
![Kind cluster is running](img/running-a-local-kubernetes-cluster-with-podman-desktop/kind-cluster-is-running.png)
111+
112+
1. In the **Podman Desktop** tray, open the **Kubernetes** menu: you can set the context to your Kind cluster: `kind-kind-cluster`.
113+
114+
![Kind cluster Kubernetes context in the tray](img/running-a-local-kubernetes-cluster-with-podman-desktop/kind-cluster-context-in-the-tray.png)
115+
116+
At this point, you can start working with containers, and your local Kubernetes cluster.
117+
118+
#### Additional resources
119+
120+
- [Creating a local Kind-powered Kubernetes cluster](docs/kubernetes/kind/creating-a-kind-cluster)
121+
122+
## Starting the Redis leader
123+
124+
The Guestbook application uses Redis to store its data.
125+
126+
With Podman Desktop, you can prepare the Redis leader image and container on your local container engine, and deploy the results to a Kubernetes pod and service.
127+
This is functionally equal to the `redis-leader` deployment that the Kubernetes example propose.
128+
129+
#### Procedure
130+
131+
1. Open **<icon icon="fa-solid fa-cloud" size="lg" /> Images > <icon icon="fa-solid fa-arrow-circle-down" size="lg" /> Pull an image**.
132+
1. **Image to Pull**: enter `docker.io/redis:6.0.5`
133+
1. Click **Pull image** to pull the image to your container engine local image registry.
134+
1. Click **Done** to get back to the images list.
135+
1. **<icon icon="fa-solid fa-cloud" size="lg" /> Search images**: enter `redis:6.0.5` to find the image.
136+
1. Click **<icon icon="fa-solid fa-play" size="lg" />** to open the **Create a container from image** dialog.
137+
1. **Container name**: enter `leader`,
138+
1. **Local port for `6379/tcp`**: `6379`.
139+
1. Click **<icon icon="fa-solid fa-play" size="lg" /> Start Container** to start the container in your container engine.
140+
1. **<icon icon="fa-solid fa-cloud" size="lg" /> Search containers**: enter `leader` to find the running container.
141+
1. Click **<icon icon="fa-solid fa-stop" size="lg" />** to stop the container, and leave the `6379` port available for the Redis follower container.
142+
143+
1. Click **<icon icon="fa-solid fa-ellipsis-v" size="lg" /> > <icon icon="fa-solid fa-rocket" size="lg" /> Deploy to Kubernetes** to open the **Deploy generated pod to Kubernetes** screen.
144+
145+
1. **Pod Name**: enter `redis-leader`.
146+
1. **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 use `hostPort`.**
147+
1. **Expose service locally using Kubernetes Ingress**: deselect **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`**.
148+
1. **Kubernetes namespaces**: select `default`.
149+
1. Click **<icon icon="fa-solid fa-rocket" size="lg" /> Deploy**.
150+
![Deploy generated leader pod to Kubernetes screen](img/running-a-local-kubernetes-cluster-with-podman-desktop/deploy-generated-leader-pod-to-kubernetes.png)
151+
1. Wait for the pod to reach the state: **Phase: Running**.
152+
1. Click **Done**.
153+
154+
#### Verification
155+
156+
- The **<icon icon="fa-solid fa-cubes" size="lg" /> Pods** screen lists the running `redis-leader` pod.
157+
158+
![leader pod is running](img/running-a-local-kubernetes-cluster-with-podman-desktop/leader-pod-is-running.png)
159+
160+
## Starting the Redis followers
161+
162+
Although the Redis leader is a single Pod, you can make it highly available and meet traffic demands by adding a few Redis followers, or replicas.
163+
164+
**With Podman Desktop, you can prepare the Redis follower image and container on your local container engine, and deploy the results to Kubernetes pods and services.**
165+
This is functionally equal to the `redis-follower` deployment that the Kubernetes example propose.
166+
167+
#### Procedure
168+
169+
1. Open **<icon icon="fa-solid fa-cloud" size="lg" /> Images > <icon icon="fa-solid fa-arrow-circle-down" size="lg" /> Pull an image**.
170+
1. **Image to Pull**: enter `gcr.io/google_samples/gb-redis-follower:v2`
171+
1. Click **Pull image** to pull the image to your container engine local image registry.
172+
1. Click **Done** to get back to the images list.
173+
1. **<icon icon="fa-solid fa-cloud" size="lg" /> Search images**: enter `gb-redis-follower:v2` to find the image.
174+
1. Click **<icon icon="fa-solid fa-play" size="lg" />** to open the **Create a container from image** dialog.
175+
1. **Container name**: enter `follower`,
176+
1. **Local port for `6379/tcp`**: `6379`.
177+
1. Click **<icon icon="fa-solid fa-play" size="lg" /> Start Container** to start the container in your container engine.
178+
1. **<icon icon="fa-solid fa-cloud" size="lg" /> Search containers**: enter `follower` to find the running container.
179+
1. Click **<icon icon="fa-solid fa-stop" size="lg" />** to stop the container: you do not need it to run in the container engine.
180+
1. Click **<icon icon="fa-solid fa-ellipsis-v" size="lg" /> > <icon icon="fa-solid fa-rocket" size="lg" /> Deploy to Kubernetes** to open the **Deploy generated pod to Kubernetes** screen.
181+
1. **Pod Name**: enter `redis-follower`.
182+
1. **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 use `hostPort`.**
183+
1. **Expose service locally using Kubernetes Ingress**: deselect **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`**.
184+
1. **Kubernetes namespaces**: select `default`.
185+
1. Click **<icon icon="fa-solid fa-rocket" size="lg" /> Deploy**.
186+
![Deploy generated follower pod to Kubernetes screen](img/running-a-local-kubernetes-cluster-with-podman-desktop/deploy-generated-follower-pod-to-kubernetes.png)
187+
1. Wait for the pod to reach the state: **Phase: Running**.
188+
1. Click **Done**.
189+
1. To add replicas, repeat the last step with another **Pod Name** value.
190+
191+
#### Verification
192+
193+
- The **<icon icon="fa-solid fa-cubes" size="lg" /> Pods** screen lists the running `redis-follower` pods.
194+
195+
![follower pods are running](img/running-a-local-kubernetes-cluster-with-podman-desktop/follower-pods-are-running.png)
196+
197+
## Starting the default frontend
198+
199+
Now that you have the Redis storage of your Guestbook up and running, start the Guestbook web servers.
200+
Like the Redis followers, deploy the frontend using Kubernetes pods and services.
201+
202+
The Guestbook app uses a PHP frontend.
203+
It is configured to communicate with either the Redis follower or leader Services, depending on whether the request is a read or a write.
204+
The frontend exposes a JSON interface, and serves a jQuery-Ajax-based UX.
205+
206+
With Podman Desktop, you can prepare the Guestbook frontend image and container on your local container engine, and deploy the results to Kubernetes pods and services.
207+
This is functionally equal to the `frontend` deployment that the Kubernetes example propose.
208+
209+
#### Procedure
210+
211+
1. Open **<icon icon="fa-solid fa-cloud" size="lg" /> Images > <icon icon="fa-solid fa-arrow-circle-down" size="lg" /> Pull an image**.
212+
1. **Image to Pull**: enter `gcr.io/google_samples/gb-frontend:v5`
213+
1. Click **Pull image** to pull the image to your container engine local image registry.
214+
1. Wait for the pull to complete.
215+
1. Click **Done** to get back to the images list.
216+
1. **<icon icon="fa-solid fa-cloud" size="lg" /> Search images**: enter `gb-frontend:v5` to find the image.
217+
1. Click **<icon icon="fa-solid fa-play" size="lg" />** to open the **Create a container from image** dialog.
218+
1. **Container name**: enter `frontend`,
219+
1. **Local port for `80/tcp`**: `9000`.
220+
1. Click **<icon icon="fa-solid fa-play" size="lg" /> Start Container** to start the container in your container engine.
221+
1. **<icon icon="fa-solid fa-cloud" size="lg" /> Search containers**: enter `frontend` to find the running container.
222+
1. Click **<icon icon="fa-solid fa-stop" size="lg" />** to stop the container: you do not need it to run in the container engine.
223+
1. Click **<icon icon="fa-solid fa-ellipsis-v" size="lg" /> > <icon icon="fa-solid fa-rocket" size="lg" /> Deploy to Kubernetes** to open the **Deploy generated pod to Kubernetes** screen.
224+
1. **Pod Name**: enter `frontend`.
225+
1. **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 use `hostPort`.**
226+
1. **Expose service locally using Kubernetes Ingress**: 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`**.
227+
1. **Kubernetes namespaces**: select `default`.
228+
1. Click **<icon icon="fa-solid fa-rocket" size="lg" /> Deploy**.
229+
![Deploy generated frontend pod to Kubernetes screen](img/running-a-local-kubernetes-cluster-with-podman-desktop/deploy-generated-frontend-pod-to-kubernetes.png)
230+
1. Wait for the pod to reach the state: **Phase: Running**.
231+
1. Click **Done**.
232+
233+
#### Verification
234+
235+
1. The **<icon icon="fa-solid fa-cubes" size="lg" /> Pods** screen lists the running `frontend` pod.
236+
237+
![`frontend` pod is running](img/running-a-local-kubernetes-cluster-with-podman-desktop/frontend-pod-is-running.png)
238+
239+
1. Go to `http://localhost:9090`: the Guestbook application is running.

website/blog/authors.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,10 @@ deboer:
2020
name: Tim deBoer
2121
title: Architect
2222
url: https://github.com/deboer-tim
23-
image_url: https://github.com/deboer-tim.png
23+
image_url: https://github.com/deboer-tim.png
24+
25+
themr0c:
26+
name: Fabrice Flore-Thebault
27+
title: Technical writer
28+
url: https://github.com/themr0c
29+
image_url: https://github.com/themr0c.png
Loading

website/static/img/kind-icon.png

83.6 KB
Loading

website/static/img/podman-icon.png

51.7 KB
Loading

0 commit comments

Comments
 (0)