-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: implement job * fix: refresh * fix: auto refresh * feat: job active
- Loading branch information
1 parent
f3efe28
commit 582dd4f
Showing
11 changed files
with
206 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
frontend/providers/cronjob/src/pages/api/cronjob/implementJob.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { authSession } from '@/services/backend/auth'; | ||
import { getK8s } from '@/services/backend/kubernetes'; | ||
import { jsonRes } from '@/services/backend/response'; | ||
import * as k8s from '@kubernetes/client-node'; | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
try { | ||
const { jobName } = req.body; | ||
const { namespace, k8sBatch } = await getK8s({ | ||
kubeconfig: await authSession(req) | ||
}); | ||
|
||
const cronJob = await k8sBatch.readNamespacedCronJob(jobName, namespace); | ||
if (!cronJob.body) { | ||
throw new Error('CronJob not found'); | ||
} | ||
|
||
const jobSpec = cronJob.body.spec?.jobTemplate.spec; | ||
const job = { | ||
metadata: { | ||
name: `${jobName}-manual-${Date.now()}`, | ||
namespace: namespace, | ||
annotations: { | ||
'cronjob.kubernetes.io/instantiate': 'manual' | ||
} | ||
}, | ||
spec: jobSpec | ||
}; | ||
|
||
const response = await k8sBatch.createNamespacedJob(namespace, job); | ||
|
||
jsonRes(res, { data: response.body }); | ||
} catch (err: any) { | ||
jsonRes(res, { | ||
code: 500, | ||
error: err | ||
}); | ||
} | ||
} |
17 changes: 3 additions & 14 deletions
17
frontend/providers/cronjob/src/pages/job/detail/components/AppBaseInfo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.