Skip to content

Commit

Permalink
update workloads
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Mar 25, 2024
1 parent 1d8162b commit 04457f3
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 7 deletions.
59 changes: 58 additions & 1 deletion assets/src/components/kubernetes/workloads/DaemonSets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,59 @@ import {
import { useDefaultColumns } from '../utils'
import { ResourceList } from '../ResourceList'

import { UsageText } from '../../cluster/TableElements'

import { WorkloadStatusChip } from './utils'

const columnHelper = createColumnHelper<DaemonSetT>()

const colImages = columnHelper.accessor((ds) => ds, {
id: 'images',
header: 'Images',
cell: ({ getValue }) => {
const ds = getValue()

return (
<div
css={{
display: 'flex',
flexDirection: 'column',
maxWidth: 300,
}}
>
{[
...(ds.initContainerImages ?? []),
...(ds.containerImages ?? []),
]?.map((image) => (
<span
css={{
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
}}
>
{image}
</span>
))}
</div>
)
},
})

const colPods = columnHelper.accessor((ds) => ds.podInfo, {
id: 'pods',
header: 'Pods',
cell: ({ getValue }) => {
const podInfo = getValue()

return (
<UsageText>
{podInfo.running} / {podInfo.desired}
</UsageText>
)
},
})

const colStatus = columnHelper.accessor((ds) => ds.podInfo, {
id: 'status',
header: 'Status',
Expand All @@ -25,7 +74,15 @@ export default function CronJobs() {
const { colName, colNamespace, colLabels, colCreationTimestamp } =
useDefaultColumns(columnHelper)
const columns = useMemo(
() => [colName, colNamespace, colStatus, colLabels, colCreationTimestamp],
() => [
colName,
colNamespace,
colImages,
colPods,
colStatus,
colLabels,
colCreationTimestamp,
],
[colName, colNamespace, colLabels, colCreationTimestamp]
)

Expand Down
59 changes: 58 additions & 1 deletion assets/src/components/kubernetes/workloads/ReplicaSets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,59 @@ import {
import { ResourceList } from '../ResourceList'
import { useDefaultColumns } from '../utils'

import { UsageText } from '../../cluster/TableElements'

import { WorkloadStatusChip } from './utils'

const columnHelper = createColumnHelper<ReplicaSetT>()

const colImages = columnHelper.accessor((rs) => rs, {
id: 'images',
header: 'Images',
cell: ({ getValue }) => {
const rs = getValue()

return (
<div
css={{
display: 'flex',
flexDirection: 'column',
maxWidth: 300,
}}
>
{[
...(rs.initContainerImages ?? []),
...(rs.containerImages ?? []),
]?.map((image) => (
<span
css={{
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
}}
>
{image}
</span>
))}
</div>
)
},
})

const colPods = columnHelper.accessor((rs) => rs.podInfo, {
id: 'pods',
header: 'Pods',
cell: ({ getValue }) => {
const podInfo = getValue()

return (
<UsageText>
{podInfo.running} / {podInfo.desired}
</UsageText>
)
},
})

const colStatus = columnHelper.accessor((rs) => rs.podInfo, {
id: 'status',
header: 'Status',
Expand All @@ -25,7 +74,15 @@ export default function ReplicaSets() {
const { colName, colNamespace, colLabels, colCreationTimestamp } =
useDefaultColumns(columnHelper)
const columns = useMemo(
() => [colName, colNamespace, colStatus, colLabels, colCreationTimestamp],
() => [
colName,
colNamespace,
colImages,
colPods,
colStatus,
colLabels,
colCreationTimestamp,
],
[colName, colNamespace, colLabels, colCreationTimestamp]
)

Expand Down
59 changes: 58 additions & 1 deletion assets/src/components/kubernetes/workloads/StatefulSets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,59 @@ import {
import { ResourceList } from '../ResourceList'
import { useDefaultColumns } from '../utils'

import { UsageText } from '../../cluster/TableElements'

import { WorkloadStatusChip } from './utils'

const columnHelper = createColumnHelper<StatefulSetT>()

const colImages = columnHelper.accessor((ss) => ss, {
id: 'images',
header: 'Images',
cell: ({ getValue }) => {
const ss = getValue()

return (
<div
css={{
display: 'flex',
flexDirection: 'column',
maxWidth: 300,
}}
>
{[
...(ss.initContainerImages ?? []),
...(ss.containerImages ?? []),
]?.map((image) => (
<span
css={{
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
}}
>
{image}
</span>
))}
</div>
)
},
})

const colPods = columnHelper.accessor((ss) => ss.podInfo, {
id: 'pods',
header: 'Pods',
cell: ({ getValue }) => {
const podInfo = getValue()

return (
<UsageText>
{podInfo.running} / {podInfo.desired}
</UsageText>
)
},
})

const colStatus = columnHelper.accessor((ss) => ss.podInfo, {
id: 'status',
header: 'Status',
Expand All @@ -25,7 +74,15 @@ export default function StatefulSets() {
const { colName, colNamespace, colLabels, colCreationTimestamp } =
useDefaultColumns(columnHelper)
const columns = useMemo(
() => [colName, colNamespace, colStatus, colLabels, colCreationTimestamp],
() => [
colName,
colNamespace,
colImages,
colPods,
colStatus,
colLabels,
colCreationTimestamp,
],
[colName, colNamespace, colLabels, colCreationTimestamp]
)

Expand Down
4 changes: 3 additions & 1 deletion assets/src/components/kubernetes/workloads/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function podInfoStatus(
podInfo: PodInfoT
): [string, ComponentProps<typeof Chip>['severity']] {
if (!podInfo) return ['Unknown', 'neutral']
const { succeeded, running, pending, failed, warnings } = podInfo
const { desired, succeeded, running, pending, failed, warnings } = podInfo

if (!isEmpty(warnings)) return ['Warning', 'danger']

Expand All @@ -82,6 +82,8 @@ function podInfoStatus(

if (succeeded > 0) return ['Succeeded', 'success']

if (desired === 0) return ['Stopped', 'neutral']

return ['Unknown', 'neutral']
}

Expand Down
12 changes: 9 additions & 3 deletions assets/src/generated/graphql-kubernetes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4793,7 +4793,7 @@ export type DaemonSetsQueryVariables = Exact<{
}>;


export type DaemonSetsQuery = { __typename?: 'Query', handleGetDaemonSetList?: { __typename?: 'daemonset_DaemonSetList', listMeta: { __typename?: 'types_ListMeta', totalItems: number }, daemonSets: Array<{ __typename?: 'daemonset_DaemonSet', objectMeta: { __typename?: 'types_ObjectMeta', uid?: string | null, name?: string | null, namespace?: string | null, labels?: any | null, annotations?: any | null, creationTimestamp?: string | null }, podInfo: { __typename?: 'common_PodInfo', desired?: number | null, succeeded: number, current: number, running: number, pending: number, failed: number, warnings: Array<{ __typename?: 'common_Event', message: string } | null> } } | null> } | null };
export type DaemonSetsQuery = { __typename?: 'Query', handleGetDaemonSetList?: { __typename?: 'daemonset_DaemonSetList', listMeta: { __typename?: 'types_ListMeta', totalItems: number }, daemonSets: Array<{ __typename?: 'daemonset_DaemonSet', initContainerImages: Array<string | null>, containerImages: Array<string | null>, objectMeta: { __typename?: 'types_ObjectMeta', uid?: string | null, name?: string | null, namespace?: string | null, labels?: any | null, annotations?: any | null, creationTimestamp?: string | null }, podInfo: { __typename?: 'common_PodInfo', desired?: number | null, succeeded: number, current: number, running: number, pending: number, failed: number, warnings: Array<{ __typename?: 'common_Event', message: string } | null> } } | null> } | null };

export type DeploymentsQueryVariables = Exact<{
namespace: Scalars['String']['input'];
Expand Down Expand Up @@ -4837,7 +4837,7 @@ export type ReplicaSetsQueryVariables = Exact<{
}>;


export type ReplicaSetsQuery = { __typename?: 'Query', handleGetReplicaSets?: { __typename?: 'replicaset_ReplicaSetList', listMeta: { __typename?: 'types_ListMeta', totalItems: number }, replicaSets: Array<{ __typename?: 'replicaset_ReplicaSet', objectMeta: { __typename?: 'types_ObjectMeta', uid?: string | null, name?: string | null, namespace?: string | null, labels?: any | null, annotations?: any | null, creationTimestamp?: string | null }, podInfo: { __typename?: 'common_PodInfo', desired?: number | null, succeeded: number, current: number, running: number, pending: number, failed: number, warnings: Array<{ __typename?: 'common_Event', message: string } | null> } } | null> } | null };
export type ReplicaSetsQuery = { __typename?: 'Query', handleGetReplicaSets?: { __typename?: 'replicaset_ReplicaSetList', listMeta: { __typename?: 'types_ListMeta', totalItems: number }, replicaSets: Array<{ __typename?: 'replicaset_ReplicaSet', initContainerImages: Array<string | null>, containerImages: Array<string | null>, objectMeta: { __typename?: 'types_ObjectMeta', uid?: string | null, name?: string | null, namespace?: string | null, labels?: any | null, annotations?: any | null, creationTimestamp?: string | null }, podInfo: { __typename?: 'common_PodInfo', desired?: number | null, succeeded: number, current: number, running: number, pending: number, failed: number, warnings: Array<{ __typename?: 'common_Event', message: string } | null> } } | null> } | null };

export type ReplicationControllersQueryVariables = Exact<{
namespace: Scalars['String']['input'];
Expand All @@ -4859,7 +4859,7 @@ export type StatefulSetsQueryVariables = Exact<{
}>;


export type StatefulSetsQuery = { __typename?: 'Query', handleGetStatefulSetList?: { __typename?: 'statefulset_StatefulSetList', listMeta: { __typename?: 'types_ListMeta', totalItems: number }, statefulSets: Array<{ __typename?: 'statefulset_StatefulSet', objectMeta: { __typename?: 'types_ObjectMeta', uid?: string | null, name?: string | null, namespace?: string | null, labels?: any | null, annotations?: any | null, creationTimestamp?: string | null }, podInfo: { __typename?: 'common_PodInfo', desired?: number | null, succeeded: number, current: number, running: number, pending: number, failed: number, warnings: Array<{ __typename?: 'common_Event', message: string } | null> } } | null> } | null };
export type StatefulSetsQuery = { __typename?: 'Query', handleGetStatefulSetList?: { __typename?: 'statefulset_StatefulSetList', listMeta: { __typename?: 'types_ListMeta', totalItems: number }, statefulSets: Array<{ __typename?: 'statefulset_StatefulSet', initContainerImages: Array<string | null>, containerImages: Array<string | null>, objectMeta: { __typename?: 'types_ObjectMeta', uid?: string | null, name?: string | null, namespace?: string | null, labels?: any | null, annotations?: any | null, creationTimestamp?: string | null }, podInfo: { __typename?: 'common_PodInfo', desired?: number | null, succeeded: number, current: number, running: number, pending: number, failed: number, warnings: Array<{ __typename?: 'common_Event', message: string } | null> } } | null> } | null };

export const ListMetaFragmentDoc = gql`
fragment ListMeta on types_ListMeta {
Expand Down Expand Up @@ -6019,6 +6019,8 @@ export const DaemonSetsDocument = gql`
podInfo @type(name: "common_PodInfo") {
...PodInfo
}
initContainerImages
containerImages
}
}
}
Expand Down Expand Up @@ -6272,6 +6274,8 @@ export const ReplicaSetsDocument = gql`
podInfo @type(name: "common_PodInfo") {
...PodInfo
}
initContainerImages
containerImages
}
}
}
Expand Down Expand Up @@ -6398,6 +6402,8 @@ export const StatefulSetsDocument = gql`
podInfo @type(name: "common_PodInfo") {
...PodInfo
}
initContainerImages
containerImages
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions assets/src/graph-kubernetes/workloads/daemonset.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ query DaemonSets(
podInfo @type(name: "common_PodInfo") {
...PodInfo
}
initContainerImages
containerImages
}
}
}
2 changes: 2 additions & 0 deletions assets/src/graph-kubernetes/workloads/replicaset.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ query ReplicaSets(
podInfo @type(name: "common_PodInfo") {
...PodInfo
}
initContainerImages
containerImages
}
}
}
2 changes: 2 additions & 0 deletions assets/src/graph-kubernetes/workloads/statefulset.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ query StatefulSets(
podInfo @type(name: "common_PodInfo") {
...PodInfo
}
initContainerImages
containerImages
}
}
}

0 comments on commit 04457f3

Please sign in to comment.