mirror of
https://github.com/podman-desktop/podman-desktop
synced 2026-04-21 17:47:22 +00:00
* docs(website): updated the tutorial section Signed-off-by: Shipra Singh <shipsing@redhat.com> * docs(website): updated content and screenshots Signed-off-by: Shipra Singh <shipsing@redhat.com> * docs(website): updated content Signed-off-by: Shipra Singh <shipsing@redhat.com> * docs(website): updated a screenshot Signed-off-by: Shipra Singh <shipsing@redhat.com> * docs(website): updated screenshots Signed-off-by: Shipra Singh <shipsing@redhat.com> * docs(website): minor edits Signed-off-by: Shipra Singh <shipsing@redhat.com> --------- Signed-off-by: Shipra Singh <shipsing@redhat.com>
116 lines
3.9 KiB
Markdown
116 lines
3.9 KiB
Markdown
---
|
|
sidebar_position: 4
|
|
title: Deploying a Kubernetes application
|
|
description: Deploying a Kubernetes application
|
|
keywords: [podman desktop, podman, Kubernetes]
|
|
tags: [podman-desktop, deploying-a-kubernetes-application]
|
|
---
|
|
|
|
# Deploying a Kubernetes application
|
|
|
|
This tutorial covers the following end-to-end tasks required to deploy an application in a Kubernetes cluster:
|
|
|
|
- Set the Kubernetes context
|
|
- Creating a deployment
|
|
- Creating a service
|
|
- Verifying the service: port forwarding
|
|
|
|
If you have multiple Kubernetes contexts, you must set the correct context in which you want to create your application resources. Within a Kubernetes cluster, you can access the application by its internal IP address. However, if you want to make your application accessible from an outside network, you must expose the pod containing your application as a Kubernetes service.
|
|
To access the service running on your Kubernetes cluster, you can use one of the following options:
|
|
|
|
- Configure port forwarding
|
|
- [Create an ingress controller](/docs/kind/building-an-image-and-testing-it-in-kind)
|
|
|
|
## Before you begin
|
|
|
|
Make sure you have:
|
|
|
|
- [Installed Podman Desktop](/docs/installation).
|
|
- [A running Podman machine](/docs/podman/creating-a-podman-machine).
|
|
- [A running Kubernetes cluster](/docs/kind/creating-a-kind-cluster).
|
|
- A reachable cluster connection:
|
|
- Go to **Settings > Kubernetes**, and click **Connect** in the cluster tile.
|
|
- A developer role.
|
|
- Created a `Deployment` file using the following code, if you do not have one on your machine:
|
|
|
|
```yaml
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: my-nginx
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
run: my-nginx
|
|
replicas: 2
|
|
template:
|
|
metadata:
|
|
labels:
|
|
run: my-nginx
|
|
spec:
|
|
containers:
|
|
- name: my-nginx
|
|
image: nginx
|
|
ports:
|
|
- containerPort: 80
|
|
```
|
|
|
|
This YAML configuration creates a `my-nginx` deployment running two Nginx pods.
|
|
|
|
- Created a `Service` file using the following code, if you do not have one on your machine:
|
|
|
|
```yaml
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: my-nginx
|
|
labels:
|
|
run: my-nginx
|
|
spec:
|
|
ports:
|
|
- port: 80
|
|
protocol: TCP
|
|
targetPort: 80
|
|
selector:
|
|
run: my-nginx
|
|
```
|
|
|
|
This YAML configuration creates a service named `my-nginx` to expose the Nginx deployment outside the Kubernetes cluster. The service listens client requests on port `80` and then forwards them to a target port `80` on the container.
|
|
|
|
## Setting the Kubernetes context
|
|
|
|
1. Go to **Settings > Kubernetes**.
|
|
2. Set the current Kubernetes context. For example, if you want to use a Kind cluster, use the **Set as Current Context** icon in the UI:
|
|

|
|
|
|
## Creating a deployment
|
|
|
|
1. Go to Kubernetes explorer from the left navigation pane.
|
|
2. Go to **Deployments** and Click **Apply YAML**.
|
|

|
|
3. Select the YAML configuration file and click **Open**. A successful operation notification opens.
|
|

|
|
4. Click **OK**.
|
|
5. View the newly created `my-nginx` deployment on the same page.
|
|

|
|
6. Click **Pods** in the Kubernetes explorer.
|
|
7. View the created `my-nginx` pods.
|
|

|
|
|
|
## Creating a service
|
|
|
|
1. In the Kubernetes explorer, go to **Services**.
|
|
2. Click **Apply YAML**.
|
|
3. Select the YAML configuration file and click **Open**. A successful operation notification opens.
|
|
4. Click **OK**.
|
|
5. View the newly created service on the same page.
|
|

|
|
|
|
## Verifying the service: port forwarding
|
|
|
|
1. In the Kubernetes explorer, go to **Services**.
|
|
1. Click the name of the `my-nginx` service.
|
|
1. Click **Forward...**.
|
|

|
|
1. Click **Open** to view the Nginx welcome page in a web browser.
|
|

|