I have a k8s cluster set up on a few raspberry pis for local development. I am trying to use a database running in the local network however I can't seem to get the pods to connect to the db. I have tried using a service and endpoint configuration:
---
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.database.host }}
annotations:
"helm.sh/hook-weight": "-2"
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation
spec:
clusterIP: None
ports:
- port: {{ .Values.database.port }}
---
apiVersion: v1
kind: Endpoints
metadata:
name: {{ .Values.database.host }}
annotations:
"helm.sh/hook-weight": "-2"
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation
subsets:
- addresses:
- ip: {{ .Values.database.ip }}
ports:
- port: {{ .Values.database.port }}
name: {{ .Values.database.host }}
I can confirm that the endpoint and service resources are created and that all the connection details are correct but my application (running on the k8s cluster) still will not connect to the database on the host network. Reading the documentation closer it sounds like these resources are for connecting to the cluster from the local network, not the other way around? Is there a way to connect to services on a local network from k8s resources?
result of running kubectl get pods -n kube-system
local-path-provisioner-5ff76fc89d-txj6k 1/1 Running 4 65d
metrics-server-86cbb8457f-r8q6w 1/1 Running 3 65d
coredns-7448499f4d-5646n 1/1 Running 10 176d
csi-smb-node-9j5gm 3/3 Running 3291 150d
csi-smb-controller-6c696945f8-8t6qj 3/3 Running 27 150d
csi-smb-controller-6c696945f8-ck5hh 3/3 Running 3361 150d
csi-smb-node-822bb 3/3 Running 3260 150d
csi-smb-node-4nckf 3/3 Running 3655 150d