<p>I have a PHP Laravel project, I have <code>Dockerfile</code>:</p>
<pre><code>FROM php:7.4-fpm

COPY . /myapp
WORKDIR /myapp

# Install system dependencies
RUN apt-get update &amp;&amp; apt-get install -y \
    git \
    curl \
    libpng-dev \
    libonig-dev \
    libxml2-dev \
    zip \
    unzip

# Clear cache
RUN apt-get clean &amp;&amp; rm -rf /var/lib/apt/lists/*

RUN curl -sS https://getcomposer.org/installer | php
RUN php composer.phar update

EXPOSE 8000
CMD [ &quot;php&quot;, &quot;artisan&quot;, &quot;serve&quot;, &quot;--host&quot;, &quot;0.0.0.0&quot; ]
</code></pre>
<p>I build the image with <code>docker build -t laravel-app .</code> and run it with <code>docker run -d -p 8000:8000 --name backend app</code>, on http://localhost:8000 I can access the api correctly.</p>
<hr />
<h1>The issue:</h1>
<p>I am trying to use Kubernetes for this project, I've written a <code>laravel-deployment.yaml</code> file:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: backend-laravel
  template:
    metadata:
      labels:
        app: backend-laravel
    spec:
      containers:
      - name: laravel-app
        image: laravel-app
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8000
</code></pre>
<p>When I try to deploy it <code>kubectl apply -f laravel-deployment.yaml</code>, the deployment is successful and the pod is created, but I can't access with http://localhost:8000
What I previously did:</p>
<ul>
<li>I've set docker to point to minikube with <code>eval $(minikube docker-env)</code></li>
<li>Create the service <code>kubectl expose -f laravel-deployment.yaml --port=8000 --target-port=8000</code></li>
</ul>

Hamza Ince
<p><code>...can't access with http://localhost:8000 What I previously did</code></p>
<p>You can access http://localhost:8000 with <code>kubectl port-forward &lt;backend-deployment-xxxx-xxxx&gt; 8000:8000</code>. You can also expose as <a href="https://minikube.sigs.k8s.io/docs/handbook/accessing/" rel="nofollow noreferrer">NodePort or LoadBalancer</a> where port-forward will not be required.</p>
