Add support for PodDisruptionBudgets (#452)

Signed-off-by: Dan Slinky <dan-slinky@cookpad.jp>
This commit is contained in:
Dan Slinky @ Cookpad authored and GitHub committed 2020-08-21 11:39:02 +03:00
1 parent 5163ede4f1
commit 81a0c432c6
11 files changed
+248 -1

No files matched your search

+1
View File
@@ -28,3 +28,4 @@ export * from "./storage-class.api"
export * from "./pod-metrics.api"
export * from "./podsecuritypolicy.api"
export * from "./selfsubjectrulesreviews.api"
export * from "./poddisruptionbudget.api"
@@ -0,0 +1,49 @@
import { autobind } from "../../utils";
import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api";
@autobind()
export class PodDisruptionBudget extends KubeObject {
static kind = "PodDisruptionBudget";
spec: {
minAvailable: string;
maxUnavailable: string;
selector: { matchLabels: { [app: string]: string } };
}
status: {
currentHealthy: number
desiredHealthy: number
disruptionsAllowed: number
expectedPods: number
}
getSelectors() {
const selector = this.spec.selector;
return KubeObject.stringifyLabels(selector ? selector.matchLabels : null);
}
getMinAvailable() {
return this.spec.minAvailable || "N/A";
}
getMaxUnavailable() {
return this.spec.maxUnavailable || "N/A";
}
getCurrentHealthy() {
return this.status.currentHealthy;
}
getDesiredHealthy() {
return this.status.desiredHealthy;
}
}
export const pdbApi = new KubeApi({
kind: PodDisruptionBudget.kind,
apiBase: "/apis/policy/v1beta1/poddisruptionbudgets",
isNamespaced: true,
objectConstructor: PodDisruptionBudget,
});