---
title: Test your Rust deployment
linkTitle: Test your deployment
weight: 50
keywords: deploy, kubernetes, rust
description: Learn how to test your Rust deployment locally using Kubernetes
aliases:
- /language/rust/deploy/
- /guides/language/rust/deploy/
---
## Prerequisites
- Complete the previous sections of this guide, starting with [Develop your Rust application](develop.md).
- [Turn on Kubernetes](/manuals/desktop/features/kubernetes.md#install-and-turn-on-kubernetes) in Docker Desktop.
## Overview
In this section, you'll learn how to use Docker Desktop to deploy your application to a fully-featured Kubernetes environment on your development machine. This lets you to test and debug your workloads on Kubernetes locally before deploying.
## Create a Kubernetes YAML file
In your `docker-rust-postgres` directory, create a file named
`docker-rust-kubernetes.yaml`. Open the file in an IDE or text editor and add
the following contents. Replace `DOCKER_USERNAME/REPO_NAME` with your Docker
username and the name of the repository that you created in [Configure CI/CD for
your Rust application](configure-ci-cd.md).
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
service: server
name: server
namespace: default
spec:
replicas: 1
selector:
matchLabels:
service: server
strategy: {}
template:
metadata:
labels:
service: server
spec:
initContainers:
- name: wait-for-db
image: busybox:1.28
command:
[
"sh",
"-c",
'until nc -zv db 5432; do echo "waiting for db"; sleep 2; done;',
]
containers:
- image: DOCKER_USERNAME/REPO_NAME
name: server
imagePullPolicy: Always
ports:
- containerPort: 8000
hostPort: 5000
protocol: TCP
env:
- name: ADDRESS
value: 0.0.0.0:8000
- name: PG_DBNAME
value: example
- name: PG_HOST
value: db
- name: PG_PASSWORD
value: mysecretpassword
- name: PG_USER
value: postgres
- name: RUST_LOG
value: debug
resources: {}
restartPolicy: Always
status: {}
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
service: db
name: db
namespace: default
spec:
replicas: 1
selector:
matchLabels:
service: db
strategy:
type: Recreate
template:
metadata:
labels:
service: db
spec:
containers:
- env:
- name: POSTGRES_DB
value: example
- name: POSTGRES_PASSWORD
value: mysecretpassword
- name: POSTGRES_USER
value: postgres
image: postgres
name: db
ports:
- containerPort: 5432
protocol: TCP
resources: {}
restartPolicy: Always
status: {}
---
apiVersion: v1
kind: Service
metadata:
labels:
service: server
name: server
namespace: default
spec:
type: NodePort
ports:
- name: "5000"
port: 5000
targetPort: 8000
nodePort: 30001