Call endpoint from Kubernetes Cron Job

0 votes
I have a web app running in a docker container on kubernetes cluster. The app has an endpoint which I want it to be called periodically. The problem is, this app is running on multiple nodes and I want only one specific node to perform that task. Is that possible? If yes, how?
Sep 27, 2018 in Power BI by lina
• 8,220 points
5,672 views

1 answer to this question.

0 votes

CronJobs are a good choice. Here's a quick layout that runs 3 nginx pods accepting all traffic. Every minute, a Job curls 1 of the 3 pods (always the same pod).

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: main
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:        - containerPort: 80
---apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: singleton
  labels:
    app: nginx
    special: singleton
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
      special: singleton
  template:
    metadata:
      labels:
        app: nginx
        special: singleton
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
--
kind: Service
apiVersion: v1
metadata:
  name: allpods
spec:
  selector:
    app: nginx
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
--
kind: Service
apiVersion: v1
metadata:
  name: singleton
spec:
  selector:
    special: singleton
  ports:
 - protocol: TCP
    port: 80
    targetPort: 80
---
piVersion: batch/v1beta1
kind: CronJob
metadata:
  name: callout
spec:
  schedule: "*/1 * * * *"
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 1
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: callout
            image: buildpack-deps:curl
            args:
            - /bin/sh
            - -ec
            - curl http://singleton
          restartPolicy: Never
answered Sep 27, 2018 by Kalgi
• 52,350 points

Related Questions In Power BI

+1 vote
0 answers

store images from a power publish report in db and call those images

Hi Experts What is the best way to ...READ MORE

Jul 3, 2019 in Power BI by Parminder
• 130 points
841 views
+1 vote
1 answer

How is power BI different from excel

Power series plug-ins you can do certain ...READ MORE

answered Sep 26, 2018 in Power BI by Hannah
• 18,520 points
746 views
0 votes
1 answer

Switch Power BI data sources from Excel to Azure analysis services

One option that you should consider would ...READ MORE

answered Sep 28, 2018 in Power BI by Kalgi
• 52,350 points
686 views
0 votes
1 answer

Error saying - UNKNOWN RangeError: Maximum call stack size exceeded"

It happens when tsconfig.json contains *.js files ...READ MORE

answered Oct 3, 2018 in Power BI by Kalgi
• 52,350 points
1,323 views
+1 vote
1 answer
0 votes
1 answer

permissions related to AWS ECR

if you add allowContainerRegistry: true, kops will add those permissions ...READ MORE

answered Oct 9, 2018 in Kubernetes by Kalgi
• 52,350 points
1,396 views
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
15,477 views
0 votes
1 answer

Why should I shift from MS Excel to Power BI

There are a lot of advantages from ...READ MORE

answered Sep 26, 2018 in Power BI by Kalgi
• 52,350 points
737 views
0 votes
1 answer

How to publish .pbix report from power bi desktop to power bi service directly?

To save powerbi file directly to report ...READ MORE

answered Sep 27, 2018 in Power BI by Kalgi
• 52,350 points
1,944 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP