I don’t want to create a pod for mysql. MySQL is installed on another machine in the same network (the machine is not dedicated to kubernates Network).
How to access mysql service from pod running in kubernetes cluster?
I have tried using the service and endpoint configured below. But, no luck.
apiVersion: v1
kind: Service
metadata:
name: database
spec:
ports:
-port: 13080
targetPort: 13080
protocol: TCP
-- -
kind: Deployment
apiVersion: v1
metadata:
name: database
subsets:
-addresses:
-ip: XX. XX.XX.XX
ports:
-port: 13080
---
kind: ReplicationController
metadata:
name: test
spec:
replicas: 1
selector:
app: test
template:
metadata:
name: test
labels:
app: test
spec:
containers:
-name: my_pods
image: my_pods
env:
-name: DATABASE_HOST
value : database
-name: DATABASE_PORT
value: "13080"
-name: DATABASE_USER
value: "SAAS"
-name: DATABASE_PAS SWORD
value: "SAAS"
-name: DATABASE_NAME
value: "SAASDB"
ports:
-containerPort: 8080
imagePullSecrets:
-name: my-secret
---
apiVersion: v1
kind: Service
metadata:
name: test-service
labels:< br /> name: test-service
spec:
type: NodePort
ports:
-port: 11544
targetPort: 8080
nodePort: 30600< br /> selector:
name: test
I run the kubernetes cluster on my centos machine.
I don’t want to create a pod for mysql. MySQL is installed on another machine in the same network (the machine is not in the kubernates private network).
How to run a pod from a kubernetes cluster Access mysql service?
I have tried using the service and endpoint configured below. But, no luck.
apiVersion: v1
kind: Service
metadata:
name: database
spec:
ports:
-port: 13080
targetPort: 13080
protocol: TCP
-- -
kind: Deployment
apiVersion: v1
metadata:
name: database
subsets:
-addresses:
-ip: XX. XX.XX.XX
ports:
-port: 13080
---
kind: ReplicationController
metadata:
name: test
spec:
replicas: 1
selector:
app: test
template:
metadata:
name: test
labels:
app: test
spec:
containers:
-name: my_pods
image: my_pods
env:
-name: DATABASE_HOST
value : database
-name: DATABASE_PORT
value: "13080"
-name: DATABASE_USER
value: "SAAS"
-name: DATABASE_PASSWO RD
value: "SAAS"
-name: DATABASE_NAME
value: "SAASDB"
ports:
-containerPort: 8080
imagePullSecrets:
-name: my-secret
---
apiVersion: v1
kind: Service
metadata:
name: test-service
labels:< br /> name: test-service
spec:
type: NodePort
ports:
-port: 11544
targetPort: 8080
nodePort: 30600< br /> selector:
name: test
You do not need to provide services for things outside the cluster. According to the network model you use, the docker container (I.e. kubernetes pod) should be able to connect to the MySQL container normally through the bridge set up by Docker. Check if the host has a connection on port 3306, and it does, just enter the DNS name (your kube-dns pod should base any non- The request of kubernetes is forwarded to the host resolv.conf of the host it arranges)