Skip to content

A simple template for starting a PHP 7 application served by NGINX, using Kubernetes (K8S) deployment object.

Notifications You must be signed in to change notification settings

scottrigby/NGINX-PHP-7-K8S-Deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

NGINX PHP 7 K8S Deployment

What is this?

A simple template for starting a PHP 7 application served by NGINX, using Kubernetes (K8S) deployment object. This also works with Minikube, to aid in learning how to use K8S on a local machine.

How does it work?

Locally via Minikube

  1. Start Minikube:

    $ minikube start
    Starting local Kubernetes cluster...
    Kubectl is now configured to use the cluster.

    Optional: Use xhyve driver for Docker instead of Virtualbox.

    • Follow Minikube documentation on installing the xhyve driver.

    • Pass the --vm-driver argument to "Start Minikube".

      minikube start --vm-driver=xhyve
  2. Create a K8S service:

    $ kubectl create -f resources/kubernetes/services/local-service.yaml
    service "local-service" created
  3. Create a K8S deployment:

    $ kubectl create -f resources/kubernetes/deployments/local-deployment.yaml
    deployment "local-deployment" created

    Optional: Mount local work into the container.

    • Add the a volume info to resources/kubernetes/deployments/local-deployment.yaml:

              image: rabellamy/php7:0.1.0
              ports:
              - containerPort: 9000
      +        volumeMounts:
      +        - mountPath: /var/www/html
      +          name: src
      +      volumes:
      +      - name: src
      +        hostPath:
      +          path: /PATH/TO/NGINX-PHP-7-K8S-Deployment/src
  4. Get the URL for the NGINX service that will serve your PHP 7 app:

    $ minikube service nginx-service --url

    Note, you may see this message until the pods are ready:

    Waiting, endpoint for service is not ready yet...

  5. Clean up when you're done:

    $ minikube delete
    Deleting local Kubernetes cluster...
    Machine deleted.

Why?

We wanted an example of an NGINX and PHP 7 template using the Kubernetes deployment object, and straight K8S configs, but to our knowledge none previously existed. Here you go!

For a templatized solution, consider Helm Charts.

About

A simple template for starting a PHP 7 application served by NGINX, using Kubernetes (K8S) deployment object.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages