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: example
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: "8080"
port: 8080
targetPort: 8080
nodePort: 30001
selector:
service: server
status:
loadBalancer: {}
---
apiVersion: v1
kind: Service
metadata:
labels:
service: db
name: db
namespace: default
spec:
ports:
- name: "5432"
port: 5432
targetPort: 5432
selector:
service: db
status:
loadBalancer: {}
```
In this Kubernetes YAML file, there are four objects, separated by the `---`. In addition to a Service and Deployment for the database, the other two objects are:
- A Deployment, describing a scalable group of identical pods. In this case,
you'll get just one replica, or copy of your pod. That pod, which is
described under `template`, has just one container in it. The container is
created from the image built by GitHub Actions in [Configure CI/CD for your
.NET application](configure-ci-cd.md).
- A NodePort service, which will route traffic from port 30001 on your host to
port 8080 inside the pods it routes to, allowing you to reach your app
from the network.
To learn more about Kubernetes objects, see the [Kubernetes documentation](https://kubernetes.io/docs/home/).
## Deploy and check your application
1. In a terminal, navigate to the `docker-dotnet-sample` directory
and deploy your application to Kubernetes.