同一集群上的 CronJob 与 Kubernetes Pod 的连接被拒绝

pds*_*dsm 1 google-cloud-platform kubernetes kubernetes-pod kubernetes-cronjob

我目前正在使用微服务架构在 Google Cloud 上使用 Kubernetes。在集群中,我有不同的 Pod,每个 Pod 都可以使用 ClusterIp 通过 curl 与其他 Pod 通信。

我的问题是我需要使用 ClusterIp 不时调用这些 Pod 之一的端点。为此,我创建了一个 CronJob 来卷曲 pod 的端点,但它总是返回:

curl: (7) Failed to connect to xx.xx.xx.xx port 8080: Connection refused
Run Code Online (Sandbox Code Playgroud)

这是 cronJob 的 yaml。

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
Run Code Online (Sandbox Code Playgroud)

小智 6

istio-proxy与您的工作负载相比,sidecar 的启动速度非常慢,其中只alpine包括在内。

当您的工作负载已经发出请求,而istio-proxy尚未准备好,甚至尚未在Pilot. 这就是为什么它在您sleep 10实际发送请求之前有效。