Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for CronJob controller resources #1954

Closed
vishalrijhwani opened this issue Dec 4, 2022 · 15 comments · Fixed by #2012
Closed

Support for CronJob controller resources #1954

vishalrijhwani opened this issue Dec 4, 2022 · 15 comments · Fixed by #2012
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@vishalrijhwani
Copy link
Contributor

Hi like job in jkube, we can create directly job, such thing is not available for cron job. can you please create for cronjob like job. there should be jkube.enricher.jkube-controller.type for cronjob too

@rohanKanojia
Copy link
Member

Just like JobHandler, we need to implement CronJobHandler as well. How should the schedule be provided?

@manusa
Copy link
Member

manusa commented Dec 5, 2022

I thought there was already an issue for tracking this

@manusa
Copy link
Member

manusa commented Dec 5, 2022

This is one of the improvements that should be completed to simplify the configuration of projects such as: https://github.com/ammbra/cat-adoption-batch

@anurag-rajawat
Copy link
Contributor

@rohanKanojia I tried to add support for cronjob but was not able to provide schedule can you take a look?
anurag-rajawat@b25b83a

@rohanKanojia
Copy link
Member

@anurag-rajawat : I can see you provided schedule in ResourceConfig. Is it not setting the schedule as expected? What error are you getting?

@anurag-rajawat
Copy link
Contributor

I'm sorry for not being clear, I want to know how can we provide schedule in pom.xml file?

@anurag-rajawat
Copy link
Contributor

When I run

$ mvn k8s:resource -Djkube.enricher.jkube-controller.type=cronjob

or add configuration in pom file like

                <configuration>
                    <enricher>
                        <config>
                            <jkube-controller>
                                <type>CronJob</type>
                                <schedule>"* * * * *"</schedule>
                            </jkube-controller>
                        </config>
                    </enricher>
                </configuration>

I get

 Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.11-SNAPSHOT:resource (default-cli) on project random-generator: Execution default-cli of goal org.eclipse.jkube:kubernetes-maven-plugin:1.11-SNAPSHOT:resource failed: No schedule is specified!

So how to pass cronjob specs?

@rohanKanojia
Copy link
Member

I think you have defined expectation for schedule to be like this:

<configuration>
   <resources>
      <schedule>"* * * * *"</schedule
   </resources>
</configuration>

@anurag-rajawat
Copy link
Contributor

Thank you!
The only change is that we have to provide schedule without any quotes.

@anurag-rajawat
Copy link
Contributor

Where should we define expectations for the schedule, concurrencyPolicy, and failedJobsHistoryLimit in resources or in enricher configuration, or in both?

And do we need to validate the corn schedule expression or leave it to Kubernetes?

@sunix
Copy link
Member

sunix commented Jan 11, 2023

Hi there,
I don't know if we already have one, but before going deeper into this, I would first setup a sample Java project that could be used as a cronjob. Does it make sense ?

Maybe this https://github.com/eclipse/jkube/tree/master/quickstarts/maven/hello-world is good enough

edit: ok I have not seen that one https://github.com/ammbra/cat-adoption-batch

@sunix
Copy link
Member

sunix commented Jan 11, 2023

And do we need to validate the cron schedule expression or leave it to Kubernetes?

In my opinion, we should leave it to Kubernetes.

@manusa
Copy link
Member

manusa commented Jan 11, 2023

Where should we define expectations for the schedule, concurrencyPolicy, and failedJobsHistoryLimit in resources or in enricher configuration, or in both?

For this first iteration we can define all of the configuration params in the Enricher configuration.

We can later on move some of them to the resource configuration if it makes sense. There are still some changes (I think yet to be merged) to refactor the resource configuration class in order to have a more structured and organized configuration.

@anurag-rajawat
Copy link
Contributor

For this first iteration we can define all of the configuration params in the Enricher configuration.

How to do that without defining those params in resource configuration class?

If we don't define those params in resource configuration then how can we add them in cronjob specs?

https://github.com/anurag-rajawat/jkube/blob/b25b83a6629e307bdfff588d165150df2cee6af3/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/handler/CronJobHandler.java#L55-L59

anurag-rajawat added a commit to anurag-rajawat/jkube that referenced this issue Jan 20, 2023
anurag-rajawat added a commit to anurag-rajawat/jkube that referenced this issue Jan 21, 2023
anurag-rajawat added a commit to anurag-rajawat/jkube that referenced this issue Jan 21, 2023
anurag-rajawat added a commit to anurag-rajawat/jkube that referenced this issue Jan 21, 2023
anurag-rajawat added a commit to anurag-rajawat/jkube that referenced this issue Jan 31, 2023
anurag-rajawat added a commit to anurag-rajawat/jkube that referenced this issue Feb 27, 2023
anurag-rajawat added a commit to anurag-rajawat/jkube that referenced this issue Mar 4, 2023
anurag-rajawat added a commit to anurag-rajawat/jkube that referenced this issue Mar 27, 2023
anurag-rajawat added a commit to anurag-rajawat/jkube that referenced this issue Mar 28, 2023
@manusa manusa changed the title jkube cron job Support for CronJob controller resources Mar 30, 2023
@manusa manusa added this to the 1.12.0 milestone Mar 30, 2023
anurag-rajawat added a commit to anurag-rajawat/jkube that referenced this issue Mar 31, 2023
manusa pushed a commit that referenced this issue Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants