Add stateful set scale slider (#1406)

Signed-off-by: vshakirova <vshakirova@mirantis.com>
This commit is contained in:
vshakirova authored and GitHub committed 2020-11-25 15:21:54 +03:00
1 parent c93ee4ea6d
commit 5b484ca692
10 files changed
+476 -10

No files matched your search

+29 -1
View File
@@ -4,6 +4,29 @@ import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
import { autobind } from "../../utils";
import { KubeApi } from "../kube-api";
export class StatefulSetApi extends KubeApi<StatefulSet> {
protected getScaleApiUrl(params: { namespace: string; name: string }) {
return this.getUrl(params) + "/scale";
}
getReplicas(params: { namespace: string; name: string }): Promise<number> {
return this.request
.get(this.getScaleApiUrl(params))
.then(({ status }: any) => status?.replicas);
}
scale(params: { namespace: string; name: string }, replicas: number) {
return this.request.put(this.getScaleApiUrl(params), {
data: {
metadata: params,
spec: {
replicas
}
}
});
}
}
@autobind()
export class StatefulSet extends WorkloadKubeObject {
static kind = "StatefulSet";
@@ -67,17 +90,22 @@ export class StatefulSet extends WorkloadKubeObject {
observedGeneration: number;
replicas: number;
currentReplicas: number;
readyReplicas: number;
currentRevision: string;
updateRevision: string;
collisionCount: number;
};
getReplicas() {
return this.spec.replicas || 0;
}
getImages() {
const containers: IPodContainer[] = get(this, "spec.template.spec.containers", []);
return [...containers].map(container => container.image);
}
}
export const statefulSetApi = new KubeApi({
export const statefulSetApi = new StatefulSetApi({
objectConstructor: StatefulSet,
});