<p>I wanted to deploy Strapi CMS to Kubernetes. On my local machine, I am trying to do this with Minikube. The structure of the project is MySQL in a different container outside of the cluster. I want to access the MySQL database from inside the cluster via this IP <code>172.17.0.2:3306</code></p>
<p>The Database is outside of the cluster and lives in a docker container. But the Strapi project lives in a cluster of Kubernetes.</p>
<p>This is my deployment YAML file for doing the Kubernetes stuff:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: cg-api
spec:
  selector:
    matchLabels:
      app: cg-api
  replicas: 2
  template:
    metadata:
      labels:
        app: cg-api
    spec:
      containers:
        - name: cg-api
          image: alirezahd/cg-api
          env:
            - name: DATABASE_HOST
              value: &quot;172.17.0.2&quot;
            - name: DATABASE_PORT
              value: &quot;3306&quot;
          ports:
            - containerPort: 1337

</code></pre>

Alireza Hamid
<p>You could try using the special minikube host to access your root machine. Assuming you have exposed the docker mysql container on your root machine using -p <code>3306:3306</code></p>
<pre><code>env:
  - name: DATABASE_HOST
    value: &quot;host.minikube.internal&quot;
</code></pre>
<p><a href="https://minikube.sigs.k8s.io/docs/handbook/host-access/#hostminikubeinternal" rel="nofollow noreferrer">https://minikube.sigs.k8s.io/docs/handbook/host-access/#hostminikubeinternal</a>
Looks like you need minikube v1.10+</p>
