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 172.17.0.2:3306
The Database is outside of the cluster and lives in a docker container. But the Strapi project lives in a cluster of Kubernetes.
This is my deployment YAML file for doing the Kubernetes stuff:
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: "172.17.0.2"
- name: DATABASE_PORT
value: "3306"
ports:
- containerPort: 1337
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 3306:3306
env:
- name: DATABASE_HOST
value: "host.minikube.internal"
https://minikube.sigs.k8s.io/docs/handbook/host-access/#hostminikubeinternal Looks like you need minikube v1.10+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With