0

I have a Cron job in Kubernetes that does not use the urls in env variables to go to another api's find information to use in him, returning errors like will be using the urls of the appsettings/launchsettings from the console application project.

When I executed the cronjob, it returned an error ex: "Connection refused (20.210.70.20:80)"

My Cron job:

`

apiVersion: batch/v1
kind: CronJob
metadata:
  name: productintegration-cronjob
spec: 
  schedule: "0 3 * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: Never
          containers:
          - name: productintegration-cronjob
            image: reconhece.azurecr.io/ms-product-integration:9399
            command: 
            - /bin/sh
            - -c
            - echo dotnet - $(which dotnet);
              echo Running Product Integration;
              /usr/bin/dotnet /app/MsProductIntegration.dll
            env:
            - name: DatabaseProducts
              value: "http://catalog-api:8097/api/Product/hash/{0}/{1}"
            - name: DatabaseCategory
              value: "http://catalog-api:8097/api/Category"

`

My catalogApi deployment where my cron job needs to go:

`

apiVersion: apps/v1
kind: Deployment
metadata:
  name: catalog-api-deployment
  labels:
    app: catalog-api
spec:
  replicas: 1
  selector:
    matchLabels:
      app: catalog-api
  template:
    metadata:
      labels:
        app: catalog-api
    spec:
      containers:
        - name: catalog-api
          image: test.azurecr.io/ms-catalog-api:6973
          ports:
            - containerPort: 80
          env:
          - name: DatabaseSettings__ConnectionString
            value: "String Connection" - I removed 
          - name: DatabaseSettings__DatabaseName
            value: "DbCatalog"

``

The minikube works fine.

How do I fix this error ?

I already changed the port from my catalogApi but without success.

I tried changing the name of the env variable but without success too.

Hemanth Kumar
  • 2,728
  • 1
  • 4
  • 19
AndreeH
  • 99
  • 4
  • Are you able to ping your catalog-api from node? Did you check is it working properly? Because the connection refused will come when there are no listeners in IP:Port you are trying to connect to. – Dharani Dhar Golladasari Dec 23 '22 at 11:55

0 Answers0