-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add pod disruption budgets view (#79)
## Description Add api and view for pod disruption budgets ## Related Issue - #48
- Loading branch information
1 parent
d04d50b
commit a2f17b3
Showing
7 changed files
with
102 additions
and
7 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
19 changes: 19 additions & 0 deletions
19
ui/src/lib/features/k8s/cluster-ops/pod-disruption-budgets/component.svelte
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,19 @@ | ||
<!-- SPDX-License-Identifier: Apache-2.0 --> | ||
<!-- SPDX-FileCopyrightText: 2024-Present The UDS Authors --> | ||
|
||
<script lang="ts"> | ||
import { DataTable } from '$components' | ||
import { createStore, type Columns } from './store' | ||
export let columns: Columns = [ | ||
['name', 'emphasize'], | ||
['namespace'], | ||
['min_available'], | ||
['max_unavailable'], | ||
['current_healthy'], | ||
['desired_healthy'], | ||
['age'], | ||
] | ||
</script> | ||
|
||
<DataTable {columns} {createStore} /> |
29 changes: 29 additions & 0 deletions
29
ui/src/lib/features/k8s/cluster-ops/pod-disruption-budgets/component.test.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,29 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2024-Present The UDS Authors | ||
|
||
import '@testing-library/jest-dom' | ||
|
||
import { testK8sTableWithCustomColumns, testK8sTableWithDefaults } from '$features/k8s/test-helper' | ||
import Component from './component.svelte' | ||
import { createStore } from './store' | ||
|
||
suite('PriorityClassesTable Component', () => { | ||
beforeEach(() => { | ||
vi.clearAllMocks() | ||
}) | ||
|
||
testK8sTableWithDefaults(Component, { | ||
createStore, | ||
columns: [ | ||
['name', 'emphasize'], | ||
['namespace'], | ||
['min_available'], | ||
['max_unavailable'], | ||
['current_healthy'], | ||
['desired_healthy'], | ||
['age'], | ||
], | ||
}) | ||
|
||
testK8sTableWithCustomColumns(Component, { createStore }) | ||
}) |
36 changes: 36 additions & 0 deletions
36
ui/src/lib/features/k8s/cluster-ops/pod-disruption-budgets/store.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,36 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2024-Present The UDS Authors | ||
|
||
import type { V1PodDisruptionBudget as Resource } from '@kubernetes/client-node' | ||
|
||
import { ResourceStore, transformResource } from '$features/k8s/store' | ||
import { type ColumnWrapper, type CommonRow, type ResourceStoreInterface } from '$features/k8s/types' | ||
|
||
interface Row extends CommonRow { | ||
min_available: number | string | ||
max_unavailable: number | string | ||
current_healthy: number | ||
desired_healthy: number | ||
} | ||
|
||
export type Columns = ColumnWrapper<Row> | ||
|
||
export function createStore(): ResourceStoreInterface<Resource, Row> { | ||
// needs dense=true to get the min_available and max_unavailable fields from spec | ||
const url = `/api/v1/resources/cluster-ops/poddisruptionbudgets?dense=true` | ||
|
||
const transform = transformResource<Resource, Row>((r) => ({ | ||
min_available: r.spec?.minAvailable ?? 'N/A', | ||
max_unavailable: r.spec?.maxUnavailable ?? 'N/A', | ||
desired_healthy: r.status?.desiredHealthy ?? 0, | ||
current_healthy: r.status?.currentHealthy ?? 0, | ||
})) | ||
|
||
const store = new ResourceStore<Resource, Row>('name') | ||
|
||
return { | ||
...store, | ||
start: () => store.start(url, transform), | ||
sortByKey: store.sortByKey.bind(store), | ||
} | ||
} |
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
5 changes: 4 additions & 1 deletion
5
ui/src/routes/(resources)/cluster-ops/pod-disruption-budgets/+page.svelte
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
<!-- SPDX-License-Identifier: Apache-2.0 --> | ||
<!-- SPDX-FileCopyrightText: 2024-Present The UDS Authors --> | ||
<script> | ||
import { PodDisruptionBudgetsTable } from '$features/k8s' | ||
</script> | ||
|
||
<h1 class="text-white text-5xl">Pod Disruption Budgets</h1> | ||
<PodDisruptionBudgetsTable /> |