Skip to main content

Command Palette

Search for a command to run...

Apache-PHP Deployment on Minikube

Updated
2 min read

Introduction

Kubernetes has become the standard for container orchestration, but when learning or experimenting, you don’t always need a full cloud setup. That’s where Minikube comes in — it allows you to run a Kubernetes cluster locally on your laptop.

In this blog, we’ll walk through deploying an Apache Webserver with PHP inside a Kubernetes cluster using Minikube.


📌 Objectives

  • Build and run a Kubernetes cluster locally using Minikube.

  • Deploy an Apache-PHP application using a Deployment manifest.

  • Expose the app externally using a Service (NodePort).

  • Scale deployments and manage pods.


⚙️ Tools Used


🛠️ Setup Steps

1️⃣ Start Minikube

minikube start
kubectl get nodes

image


2️⃣ Create Deployment

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: apache-php-deployment
  labels:
    app: apache-php
    region: india
spec:
  replicas: 2
  selector:
    matchLabels:
      app: apache-php
  template:
    metadata:
      labels:
        app: apache-php
        region: india
    spec:
      containers:
      - name: apache-php-container
        image: vimal13/apache-webserver-php
        ports:
        - containerPort: 80

Apply the deployment:

kubectl apply -f deployment.yaml
kubectl get pods

image


3️⃣ Expose Deployment with Service

service.yaml

apiVersion: v1
kind: Service
metadata:
  name: apache-php-service
spec:
  type: NodePort
  selector:
    app: apache-php
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30008

Apply the service:

kubectl apply -f service.yaml
kubectl get svc

image


4️⃣ Access Application

minikube service apache-php-service

Or open in browser: http://<minikube-ip>:30008

image


5️⃣ Scale Deployment

kubectl scale deployment apache-php-deployment --replicas=4
kubectl get pods

📸 Screenshot here: ()

6️⃣ Debug / Logs

kubectl describe pod <pod-name>
kubectl logs <pod-name>

📸 Screenshot here: ()

📂 Deliverables

  • YAML Filesdeployment.yaml, service.yaml

  • Screenshots → Minikube start, Deployment, Service, Website output


✅ Conclusion

You have successfully: ✔ Started Minikube cluster ✔ Deployed an Apache-PHP web app ✔ Exposed it via NodePort service ✔ Scaled pods ✔ Verified application is accessible locally


Apache-PHP Deployment on Minikube