<p>I want to execute a function written in Node.js, lets assume on an image called <strong>helloworld</strong>  every minute on Kubernetes using cronjob.</p>
<pre><code>function helloWorld() {
  console.log('hello world!')'
}

</code></pre>
<p>I don't understand how I can call it in yaml file.</p>
<p><strong>Config.yaml</strong></p>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: hello
spec:
  schedule: &quot;*/1 * * * *&quot;
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: helloworld
          restartPolicy: OnFailure
</code></pre>

maopuppets
<p>I think you should use <a href="https://fnproject.io/tutorials/ContainerAsFunction/" rel="nofollow noreferrer">fn</a>. One of the most powerful features of <strong>Fn</strong> is the ability to use custom defined Docker container images as functions. This feature makes it possible to customize your function’s runtime environment including letting you install any Linux libraries or utilities that your function might need. And thanks to the <strong>Fn</strong> CLI’s support for Dockerfiles it’s the same user experience as when developing any function.
Deploying your function is how you publish your function and make it accessible to other users and systems. To see the details of what is happening during a function deploy, use the  <code>--verbose</code>  switch. The first time you build a function of a particular language it takes longer as <strong>Fn</strong> downloads the necessary Docker images. The  <code>--verbose</code>  option allows you to see this process.</p>
<p>New image will be created - example node-app-hello.
Then you can configure CronJob.</p>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: hello-fn-example
spec:
  schedule: &quot;*/1 * * * *&quot;
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: example node-app-hello
            args:
            - ...
          restartPolicy: OnFailure
</code></pre>
<p>You can also add extra command to run hello container.</p>
<p>Then simply exacute command:</p>
<pre><code>$ kubectl create -f you-cronjob-file.yaml
</code></pre>
<p>Take a look: <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" rel="nofollow noreferrer">cron-jobs</a>.</p>
