I am trying to send mail using sendgrid api and cronjob in k8s , I tried my python code in cloud function and it is running as expected however when I used my code to create GCR image and deploy it in a k8s cronjob i got an urllib.error.URLError: <urlopen error [Errno 104] Connection reset by peer>
error
Well i created a pod for debugging , here is my pod definition that uses my linux image :
apiVersion: v1
kind: Pod
metadata:
name: notifier
spec:
serviceAccountName: xxxxxxxxxxx
containers:
- name: test
image: eu.gcr.io/xxxxxxxxxxxxxxxxxxxxxx:v1.4
command: [ "/bin/bash", "-c", "--" ]
args: [ "while true; do sleep 30; done;" ]
I know that I need to allow traffic (egress and ingress ) so that my pod can get traffic from api however i don't know how to do it , here is my cronjob definition :
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: zzzzzzzzzzzzzzz
spec:
schedule: "00 7 * * *"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 5
failedJobsHistoryLimit: 3
jobTemplate:
spec:
parallelism: 1
backoffLimit: 0
template:
spec:
restartPolicy: Never
serviceAccountName: xxxxxxxxxx
containers:
- name: yyyyyyyyyyyyy
image: eu.gcr.io/xxxxxxxxxxxxxxxxxxxxxxxx:v1.4
resources:
requests:
memory: "512Mi"
cpu: 1
limits:
memory: "1024Mi"
cpu: 2
I am using kustomize k8s , GKE , python sendgrid api
thank you for your support