Args and commands for a CronJob

development

#1

Hi,
I have a ASP.NET Core 2.1 console application witch should run in a docker container. Width a kubernetes CronJob it should run every hour. But I don’t know what arguments (args) and commants are to set. At the internet I find lots of examples for very short console applications like “Hello world!”. Please could me help some body with informations about that.
Below you see my cronjob.yaml
Thanks for your help,
Frank

apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: myjob
creationTimestamp: 2019-02-15T09:10:20Z
namespace: default
selfLink: /apis/batch/v1beta1/namespaces/default/cronjobs/myjob
spec:
concurrencyPolicy: Allow
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 3
suspend: false
schedule: “0 */1 * * *”
jobTemplate:
metadata:
labels:
job: myjob
spec:
template:
spec:
containers:
- name: ad_sync
image: busybox
command: [“printenv”]
args: [“myHost”, “80”]
restartPolicy: OnFailure


#2

To be honest, I’m not 100% sure what you’re referring to.
If you are looking for the the difference between command and args in a podspec their equivalent with docker would be entrypoint and and command.

command in kubernetes is usually the path to the starting binary or script and args is the arguments for it.

In your example you’re passing “myHost” and “80” to printenv which would just print those environment variables.


#3

So when my small application does not neet any arguments args stays empty
and command get’s the URL, right?

command: [“myHost”, “80”]
args: []

Frank


#4

Command overrides the docker entrypoint, if you’re trying to pass a url or other things, those should be args.


#5

The URL? What command do you execute to start your application? That command or some friend is the command you want.


#6

What is the command to start?


#7

Yo start your app? It really depends on your app.

How do you start it locally when you develop? Probably that is a good starting point


#8

It is a console application. I start with F5.
command: [“F5”] :wink:
args: [“myHost”, “80”]

No honestly, what is the command to start a console application?
Frank


#9

What do you use to launch it when running in a vanilla container, not in Kubernetes?


#10

I never run vanilla container. I don’t know this container. I’m really new in this topic.


#11

Sorry, by vanilla I meant plain (Vanilla is an english idiom for plain). Just the container itself – Outside of Kubernetes, straight docker.


#12

No idea. I dit not start it with docker so far.
Which commands could be possible?


#13

I would highly recommend getting to know docker and containers in general before approaching kubernetes. A good understanding of containers is an essential skill to be successful.

There are quite a few tutorial available, a few I would suggest are:




#14

Now I will answer my question by my self for people who came along with the same question.

args stay empty, because in my console application I also dont use arguments (as usual I think)
command get the value from the endpoint at the Dockerfile
and
image needs to get the repository path