Home Explore Blog CI



docker

1st chunk of `content/guides/cpp/deploy.md`
c675e3c25f09b25e6b7cf2e314f554f3da5c796d4e1aee7a00000001000008f7
---
title: Test your C++ deployment
linkTitle: Test your deployment
weight: 50
keywords: deploy, kubernetes, c++
description: Learn how to develop locally using Kubernetes
aliases:
  - /language/cpp/deploy/
  - /guides/language/cpp/deploy/
---

## Prerequisites

- Complete all the previous sections of this guide, starting with [Containerize a C++ application](containerize.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 allows you to test and debug your workloads on Kubernetes locally before deploying.

## Create a Kubernetes YAML file

In your `c-plus-plus-docker` directory, create a file named
`docker-kubernetes.yml`. 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 C++ application](configure-ci-cd.md).

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: docker-c-plus-plus-demo
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      service: ok-api
  template:
    metadata:
      labels:
        service: ok-api
    spec:
      containers:
        - name: ok-api-service
          image: DOCKER_USERNAME/REPO_NAME
          imagePullPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  name: service-entrypoint
  namespace: default
spec:
  type: NodePort
  selector:
    service: ok-api
  ports:
    - port: 8080
      targetPort: 8080
      nodePort: 30001
```

In this Kubernetes YAML file, there are two objects, separated by the `---`:

- 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 C++ 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

Title: Test Your C++ Deployment on Kubernetes
Summary
This section guides you through deploying your C++ application to a local Kubernetes environment using Docker Desktop for testing and debugging. It covers the prerequisites, including completing previous sections of the guide and enabling Kubernetes in Docker Desktop. The main step involves creating a `docker-kubernetes.yml` file containing Kubernetes deployment and service configurations. The deployment specifies a single replica of your application's pod, while the NodePort service enables external access to the application through port 30001 on your host machine, which is routed to port 8080 inside the pod.