I am currently working with Kubernetes on Google Cloud with a microservice architecture. Where in a cluster I have different Pods and each of them can communicate with the others via curl using a ClusterIp.
My problem is that I need an endpoint of one of these pods to be called from time to time using the ClusterIp. For this I created a CronJob which curls the endpoint of the pod, but it always returns:
curl: (7) Failed to connect to xx.xx.xx.xx port 8080: Connection refused
This is the yaml of the cronJob.
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cronjob-test # name of the CronJob
spec:
schedule: "*/1 * * * *" # run every minute
concurrencyPolicy: Replace
jobTemplate:
spec:
template:
spec:
containers:
- name: cronjob-test
image: appropriate/curl
args:
- /bin/sh
- -c
- curl -X POST http://${CLUSTER_IP}:${CLUSTER_PORT}/api/test/
restartPolicy: Never