Home Explore Blog Models CI



docker

1st chunk of `content/guides/php/deploy.md`
84a3ed60439efbf61a2dc10a9fff774bb35c4fbe6b1d508300000001000008e5
---
title: Test your PHP deployment
linkTitle: Test your deployment
weight: 50
keywords: deploy, php, local, development
description: Learn how to deploy your application
aliases:
  - /language/php/deploy/
  - /guides/language/php/deploy/
---

## Prerequisites

- Complete all the previous sections of this guide, starting with [Containerize
  a PHP 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 `docker-php-sample` directory, create a file named
`docker-php-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 PHP application](configure-ci-cd.md).

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: docker-php-demo
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      hello-php: web
  template:
    metadata:
      labels:
        hello-php: web
    spec:
      containers:
        - name: hello-site
          image: DOCKER_USERNAME/REPO_NAME
          imagePullPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  name: php-entrypoint
  namespace: default
spec:
  type: NodePort
  selector:
    hello-php: web
  ports:
    - port: 80
      targetPort: 80
      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
  PHP application](configure-ci-cd.md).
- A NodePort service, which will route traffic from port 30001 on your host to
  port 80 inside the pods it routes to, allowing you to reach your app

Title: Test your PHP deployment using Kubernetes on Docker Desktop
Summary
This section guides you through deploying your PHP application to a local Kubernetes environment using Docker Desktop. It requires completing previous steps including containerizing the app and setting up CI/CD. You'll create a `docker-php-kubernetes.yaml` file defining a Deployment (scalable group of identical pods) and a NodePort service (routes traffic from host port 30001 to port 80 inside the pods), and deploying the image built by GitHub Actions.