Skip to content

Commit 3e18e2e

Browse files
committed
Add support to spring-boot and CronJobs
1 parent 8fce8ad commit 3e18e2e

File tree

6 files changed

+65
-19
lines changed

6 files changed

+65
-19
lines changed

plugin/src/components/ApplicationDetailsCard.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,12 @@ const ApplicationDetailsCard: React.FC<{ application: Application }> = ({ applic
137137
<Card>
138138
<CardTitle>Frameworks</CardTitle>
139139
<CardBody>
140-
<TextContent><strong>Quarkus Platform: </strong> {application.metadata.annotations['camel/quarkus-platform']}</TextContent>
141-
<TextContent><strong>Camel Quarkus: </strong> {application.metadata.annotations['camel/camel-quarkus']}</TextContent>
142-
<TextContent><strong>Camel: </strong> {application.metadata.annotations['camel/camel-core-version']}</TextContent>
140+
{application.metadata.annotations['camel/camel-core-version'] && <TextContent><strong>Camel: </strong> {application.metadata.annotations['camel/camel-core-version']}</TextContent>}
141+
{application.metadata.annotations['camel/quarkus-platform'] && <TextContent><strong>Quarkus Platform: </strong> {application.metadata.annotations['camel/quarkus-platform']}</TextContent>}
142+
{application.metadata.annotations['camel/camel-quarkus'] && <TextContent><strong>Camel Quarkus: </strong> {application.metadata.annotations['camel/camel-quarkus']}</TextContent>}
143+
144+
{application.metadata.annotations['camel/camel-spring-boot-version'] && <TextContent><strong>Camel Spring Boot: </strong> {application.metadata.annotations['camel/camel-spring-boot-version']}</TextContent>}
145+
{application.metadata.annotations['camel/spring-boot-version'] && <TextContent><strong>Spring Boot: </strong> {application.metadata.annotations['camel/spring-boot-version']}</TextContent>}
143146
</CardBody>
144147
</Card>
145148
</div>

plugin/src/components/ApplicationList.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,17 @@ export const ApplicationList: React.FC<ApplicationListProps> = ({ apps }) => {
244244
</Td>
245245
<Td dataLabel={columnNames.kind}>{app.kind}</Td>
246246
<Td dataLabel={columnNames.namespace}>{app.metadata.namespace}</Td>
247-
<Td dataLabel={columnNames.status}><Status title={`${app.status.availableReplicas} of ${app.status.replicas} pods`} status={app.status.availableReplicas === app.status.replicas ? "Succeeded" : "Failed"}/></Td>
247+
<Td dataLabel={columnNames.status}>
248+
{(app.kind == 'Deployment' || app.kind == 'DeploymentConfig') &&
249+
<Status title={`${app.status.availableReplicas} of ${app.status.replicas} pods`} status={app.status.availableReplicas === app.status.replicas ? "Succeeded" : "Failed"}/>
250+
}
251+
{app.kind == 'CronJob' &&
252+
<Status title={`${app.cronStatus.lastSuccessfulTime}`} status={app.cronStatus.lastSuccessfulTime ? "Succeeded" : "Failed"}/>
253+
}
254+
</Td>
248255
<Td dataLabel={columnNames.cpu}>{app.cpu}</Td>
249256
<Td dataLabel={columnNames.memory}>{app.memory}</Td>
250-
<Td dataLabel={columnNames.runtime}>Quarkus Platform: {app.metadata.annotations['camel/quarkus-platform']}<br/>Camel: {app.metadata.annotations['camel/camel-core-version']}<br/>Camel Quarkus: {app.metadata.annotations['camel/camel-quarkus']}</Td>
257+
<Td dataLabel={columnNames.runtime}>Camel: {app.metadata.annotations['camel/camel-core-version']}</Td>
251258
</Tr>
252259
))}
253260
</Tbody>

plugin/src/pages/ApplicationPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const ApplicationPage: React.FC<ApplicationPageProps> = ( {match} ) => {
6767
</Helmet>
6868
<Page>
6969
<PageSection variant="light">
70-
<Title headingLevel="h1">{t('Dashboard')}</Title>
70+
<Title headingLevel="h1">{t('Dashboard')} - {selectedName}</Title>
7171
</PageSection>
7272
<PageSection variant="light">
7373
<Tabs activeKey={activeTabKey} onSelect={handleTabClick}>

plugin/src/pages/HomePage.tsx

+15-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useEffect, useState } from 'react';
1414
import { NamespaceBar } from '@openshift-console/dynamic-plugin-sdk';
1515
import ApplicationList from '../components/ApplicationList';
1616
import { Application } from '../types';
17-
import { fetchDeployments, fetchDeploymentConfigs, populateAdddionalInfo } from '../services/CamelService';
17+
import { fetchCronjobs, fetchDeployments, fetchDeploymentConfigs, populateAdddionalInfo } from '../services/CamelService';
1818
import ApplicationsCPUGraph from '../components/ApplicationsCPUGraph';
1919
import ApplicationsMemoryGraph from '../components/ApplicationsMemoryGraph';
2020

@@ -55,6 +55,19 @@ export const CamelPage: React.FC<CamelHomePageProps> = ({ match }) => {
5555
});
5656
})
5757
});
58+
59+
fetchCronjobs(activeNamespace).then((apps: Application[]) => {
60+
apps.forEach(app => {
61+
setApplications((existing: Application[]) => {
62+
return [...existing.filter(e => !matching(e, app)), app];
63+
});
64+
populateAdddionalInfo(app).then(appWithInfo => {
65+
setApplications((existing: Application[]) => {
66+
return [...existing.filter(e => !matching(e, appWithInfo)), appWithInfo];
67+
});
68+
});
69+
})
70+
});
5871
}, [activeNamespace]);
5972

6073
return (
@@ -66,7 +79,7 @@ export const CamelPage: React.FC<CamelHomePageProps> = ({ match }) => {
6679

6780
<Page>
6881
<PageSection variant="light">
69-
<Title headingLevel="h1">{t('Camel Applications')}</Title>
82+
<Title headingLevel="h1">{t('Camel Applications 123')}</Title>
7083
</PageSection>
7184
<PageSection variant="light">
7285
<Card>

plugin/src/services/CamelService.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { consoleFetchJSON } from '@openshift-console/dynamic-plugin-sdk';
2-
import { ConfigMapKind, DeploymentConfigKind, DeploymentKind, JobKind, PersistentVolumeClaimKind, PodKind, RouteKind, SecretKind } from '../k8s-types';
3-
import { Application, deploymentConfigToApplication, deploymentToApplication } from '../types';
2+
import { ConfigMapKind, CronJobKind, DeploymentConfigKind, DeploymentKind, JobKind, PersistentVolumeClaimKind, PodKind, RouteKind, SecretKind } from '../k8s-types';
3+
import { Application, cronjobToApplication, deploymentConfigToApplication, deploymentToApplication } from '../types';
44
import { sprintf } from 'sprintf-js';
55
import { camelApplicationStore } from '../state';
66

@@ -9,6 +9,7 @@ const PROMETHEUS_API_QUERY_PATH = '/api/prometheus/api/v1/query';
99
const PROMETHEUS_API_QUERYRANGE_PATH = '/api/prometheus/api/v1/query_range';
1010

1111
export async function fetchDeployments(ns: string): Promise<Application[]> {
12+
debugger;
1213
let deploymentsUri = ns ? '/api/kubernetes/apis/apps/v1/namespaces/' + ns + '/deployments' : '/api/kubernetes/apis/apps/v1/deployments';
1314
deploymentsUri += '?labelSelector=' + OPENSHIFT_RUNTIME_LABEL
1415
return consoleFetchJSON(deploymentsUri).then(res => {
@@ -17,15 +18,16 @@ export async function fetchDeployments(ns: string): Promise<Application[]> {
1718
});
1819
}
1920

20-
/* export async function fetchCronjobs(ns: string): Promise<Application[]> {
21+
export async function fetchCronjobs(ns: string): Promise<Application[]> {
22+
debugger;
2123
let deploymentsUri = ns ? '/api/kubernetes/apis/batch/v1/namespaces/' + ns + '/cronjobs' : '/api/kubernetes/apis/batch/v1/cronjobs';
2224
deploymentsUri += '?labelSelector=' + OPENSHIFT_RUNTIME_LABEL
2325
return consoleFetchJSON(deploymentsUri).then(res => {
2426
return res.items
25-
.map((d: CronJobKind) => deploymentToApplication(d));
27+
.map((c: CronJobKind) => cronjobToApplication(c));
2628
});
2729
}
28-
*/
30+
2931
async function fetchDeployment(ns: string, name: string): Promise<Application> {
3032
return consoleFetchJSON('/api/kubernetes/apis/apps/v1/namespaces/' + ns + '/deployments/' + name).then(res => {
3133
return deploymentToApplication(res);
@@ -313,6 +315,7 @@ export async function fetchApplicationWithMetrics(kind: string, ns: string, name
313315
}
314316

315317
const CamelService = {
318+
fetchCronjobs,
316319
fetchDeployments,
317320
fetchDeploymentConfigs,
318321
fetchApplications,

plugin/src/types.ts

+26-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { K8sResourceCommon } from "@openshift-console/dynamic-plugin-sdk";
2-
import { DeploymentCondition, DeploymentKind, DeploymentConfigKind, PodSpec } from "k8s-types";
2+
import { CronJobKind, DeploymentCondition, DeploymentKind, DeploymentConfigKind, PodSpec, PodTemplate } from "k8s-types";
33

44
export type Snapshot = {
55
name: string;
@@ -21,7 +21,16 @@ export type Application = {
2121
memory?: string;
2222
url?: string;
2323
metrics?: Metrics;
24-
spec: PodSpec;
24+
spec?: PodSpec;
25+
cronSpec?: {
26+
activeDeadlineSeconds?: number;
27+
backoffLimit?: number;
28+
completions?: number;
29+
manualSelector?: boolean;
30+
parallelism?: boolean;
31+
template: PodTemplate;
32+
ttlSecondsAfterFinished?: number;
33+
};
2534
status?: {
2635
availableReplicas?: number;
2736
collisionCount?: number;
@@ -32,6 +41,18 @@ export type Application = {
3241
unavailableReplicas?: number;
3342
updatedReplicas?: number;
3443
};
44+
cronStatus?: {
45+
active?: {
46+
apiVersion?: string;
47+
fieldPath?: string;
48+
kind?: string;
49+
name?: string;
50+
namespace?: string;
51+
resourceVersion?: string;
52+
uid?: string;
53+
}[];
54+
lastScheduleTime?: string;
55+
};
3556
} & K8sResourceCommon;
3657

3758
export function deploymentToApplication(deployment: DeploymentKind): Application {
@@ -76,13 +97,13 @@ export function deploymentConfigToApplication(deployment: DeploymentConfigKind):
7697
};
7798
};
7899

79-
/* export function cronjobToApplication(cronjob: CronJobKind): Application {
100+
export function cronjobToApplication(cronjob: CronJobKind): Application {
80101
return {
81102
kind: 'CronJob',
82103
metadata: {
83104
...cronjob.metadata,
84105
},
85-
spec: {
106+
cronSpec: {
86107
...cronjob.spec.jobTemplate.spec,
87108
},
88109
metrics: {
@@ -91,9 +112,8 @@ export function deploymentConfigToApplication(deployment: DeploymentConfigKind):
91112
gcPause: [],
92113
gcOverhead: [],
93114
},
94-
status: {
115+
cronStatus: {
95116
...cronjob.status,
96117
},
97118
};
98119
};
99-
*/

0 commit comments

Comments
 (0)