Search code examples
kubernetesamazon-ekskubernetes-cronjob

Trigger Kubernetes/EKS cron job via HTTP call


I have bunch of cron jobs that sit in an EKS cluster and would like to trigger them via HTTP call. Does such API exist from Kubernetes? If not, what else can be done?


Solution

  • Every action in Kubernetes ca be invoked via rest API call. This is also stated as such in the docs.

    There is a full API reference for the Kubernetes API you can review.

    In fact, kubectl is using http under the hood. You can see those http calls by using the v flag with some verbosity level. For example:

    $ kubectl get pods -v=6
    I1206 00:06:33.591871   19308 loader.go:372] Config loaded from file:  /home/blue/.kube/config
    I1206 00:06:33.826009   19308 round_trippers.go:454] GET https://mycluster.azmk8s.io:443/api?timeout=32s 200 OK in 233 milliseconds
    ...
    

    So you could check out the command you need by looking how kubectl does it. But given the fact that kubectl does use http, it's maybe easier to just use kubectl directly.