Skip to content

Commit

Permalink
Merge pull request #43 from The-Huginn/issue-2
Browse files Browse the repository at this point in the history
Add kubernetes CronJob
  • Loading branch information
xstefank authored Feb 21, 2024
2 parents e9d9f44 + bdcb650 commit dbc10ca
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,35 @@ Fork this repository to your GitHub account.
```env
jira-issue-lottery.access-token=<YOUR TOKEN>
## Production deployment
1. Log into your Openshift
```shell
oc login ...
```
2. Create secret
```shell
oc create secret generic jira-lottery
--from-literal=JIRA_ISSUE_LOTTERY_ACCESS_TOKEN={TBD}
--from-literal=QUARKUS_MAILER_FROM={TBD}
--from-literal=QUARKUS_MAILER_USERNAME={TBD}
--from-literal=QUARKUS_MAILER_PASSWORD={TBD}
```
3. Build the application, this step will eventually fail
> **_NOTE:_** You can use script `deploy.sh` for convenience.
```shell
./mvnw clean package -Dquarkus.openshift.deploy=true
```
4. Update CronJob deployment
```shell
cd target/kubernetes
```
And in file `openshift.yml` delete the following line `selector: {}`
5. Deploy the YAML file
```shell
oc apply -f openshift.yml
```


## Running the application in dev mode

You can run your application in dev mode that enables live coding using:
Expand Down
3 changes: 3 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
./mvnw clean package -Dquarkus.kubernetes.deploy=true
sed -i '/^\s*selector: {}/d' target/kubernetes/openshift.yml
oc apply -f target/kubernetes/openshift.yml
13 changes: 8 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
<version>1.0.0-SNAPSHOT</version>
<properties>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<maven.compiler.release>21</maven.compiler.release>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.5.3</quarkus.platform.version>
<version.checkstyle>3.3.1</version.checkstyle>
<version.org.wildfly.checkstyle>1.0.8.Final</version.org.wildfly.checkstyle>
<skipITs>true</skipITs>
<surefire-plugin.version>3.1.2</surefire-plugin.version>
<version.checkstyle>3.3.1</version.checkstyle>
<version.org.wildfly.checkstyle>1.0.8.Final</version.org.wildfly.checkstyle>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -57,6 +57,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mailer</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-openshift</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
Expand All @@ -65,7 +69,7 @@
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.16.0</version>
<version>2.15.3</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down Expand Up @@ -182,7 +186,6 @@
</dependency>
</dependencies>
<configuration>
<!-- store outside of target to speed up formatting when mvn clean is used -->
<cachedir>.cache/formatter-maven-plugin-${formatter-maven-plugin.version}</cachedir>
<configFile>eclipse-format.xml</configFile>
<lineEnding>LF</lineEnding>
Expand Down
17 changes: 16 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
camel.component.jira.jira-url=https://issues.redhat.com/
%test.jira-issue-lottery.access-token=ignored
jira-issue-lottery.config-file-repo=https://github.com/The-Huginn/jira-issue-lottery
jira-issue-lottery.config-file-repo=https://github.com/The-Huginn/jira-issue-lottery
quarkus.kubernetes.deployment-kind=cron-job
# Cron expression to run the job every Monday see https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#writing-a-cronjob-spec
quarkus.kubernetes.cron-job.schedule=* * * * 1
quarkus.openshift.env.secrets=jira-lottery
quarkus.openshift.labels.app=jira-issue-lottery

# These 2 options are disabled to remove labels from selector field. However,
# a manual removal of selector field all together is needed in the generated yml file under target/kubernetes
quarkus.openshift.add-version-to-label-selectors=false
quarkus.openshift.add-name-to-label-selectors=false

quarkus.mailer.auth-methods=DIGEST-MD5 CRAM-SHA256 CRAM-SHA1 CRAM-MD5 PLAIN LOGIN
quarkus.mailer.host=smtp.gmail.com
quarkus.mailer.port=465
quarkus.mailer.ssl=true
3 changes: 2 additions & 1 deletion src/test/java/org/jboss/set/draw/LotteryDrawingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ public void testAppendingRepositoryForUnsubcription() throws Exception {
List<Mail> sent = mailbox.getMailsSentTo(email);
assertEquals(1, sent.size());
// Check directly for this URL as we know it is valid one. Using templates might result in a corrupted URL overall
assertTrue(sent.get(0).getText().contains("https://github.com/The-Huginn/jira-issue-lottery/blob/main/.github/jira-issue-lottery.yml"));
assertTrue(sent.get(0).getText()
.contains("https://github.com/The-Huginn/jira-issue-lottery/blob/main/.github/jira-issue-lottery.yml"));
}

@Test
Expand Down

0 comments on commit dbc10ca

Please sign in to comment.