mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Full support for ReplicaSets (#1704)
Signed-off-by: vshakirova <vshakirova@mirantis.com>
This commit is contained in:
1 parent
d961d8b159
commit
d143b234b7
20 files changed
+677
-154
No files matched your search
@@ -67,7 +67,7 @@ export interface IPodContainer {
|
||||
image: string;
|
||||
command?: string[];
|
||||
args?: string[];
|
||||
ports: {
|
||||
ports?: {
|
||||
name?: string;
|
||||
containerPort: number;
|
||||
protocol: string;
|
||||
@@ -137,7 +137,7 @@ interface IContainerProbe {
|
||||
|
||||
export interface IPodContainerStatus {
|
||||
name: string;
|
||||
state: {
|
||||
state?: {
|
||||
[index: string]: object;
|
||||
running?: {
|
||||
startedAt: string;
|
||||
@@ -153,21 +153,28 @@ export interface IPodContainerStatus {
|
||||
reason: string;
|
||||
};
|
||||
};
|
||||
lastState: {
|
||||
lastState?: {
|
||||
[index: string]: object;
|
||||
running?: {
|
||||
startedAt: string;
|
||||
};
|
||||
waiting?: {
|
||||
reason: string;
|
||||
message: string;
|
||||
};
|
||||
terminated?: {
|
||||
startedAt: string;
|
||||
finishedAt: string;
|
||||
exitCode: number;
|
||||
reason: string;
|
||||
containerID: string;
|
||||
};
|
||||
};
|
||||
ready: boolean;
|
||||
restartCount: number;
|
||||
image: string;
|
||||
imageID: string;
|
||||
containerID: string;
|
||||
containerID?: string;
|
||||
started?: boolean;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@@ -196,28 +203,44 @@ export class Pod extends WorkloadKubeObject {
|
||||
}[];
|
||||
initContainers: IPodContainer[];
|
||||
containers: IPodContainer[];
|
||||
restartPolicy: string;
|
||||
terminationGracePeriodSeconds: number;
|
||||
dnsPolicy: string;
|
||||
restartPolicy?: string;
|
||||
terminationGracePeriodSeconds?: number;
|
||||
activeDeadlineSeconds?: number;
|
||||
dnsPolicy?: string;
|
||||
serviceAccountName: string;
|
||||
serviceAccount: string;
|
||||
priority: number;
|
||||
priorityClassName: string;
|
||||
nodeName: string;
|
||||
automountServiceAccountToken?: boolean;
|
||||
priority?: number;
|
||||
priorityClassName?: string;
|
||||
nodeName?: string;
|
||||
nodeSelector?: {
|
||||
[selector: string]: string;
|
||||
};
|
||||
securityContext: {};
|
||||
schedulerName: string;
|
||||
tolerations: {
|
||||
key: string;
|
||||
operator: string;
|
||||
effect: string;
|
||||
tolerationSeconds: number;
|
||||
securityContext?: {};
|
||||
imagePullSecrets?: {
|
||||
name: string;
|
||||
}[];
|
||||
affinity: IAffinity;
|
||||
hostNetwork?: boolean;
|
||||
hostPID?: boolean;
|
||||
hostIPC?: boolean;
|
||||
shareProcessNamespace?: boolean;
|
||||
hostname?: string;
|
||||
subdomain?: string;
|
||||
schedulerName?: string;
|
||||
tolerations?: {
|
||||
key?: string;
|
||||
operator?: string;
|
||||
effect?: string;
|
||||
tolerationSeconds?: number;
|
||||
value?: string;
|
||||
}[];
|
||||
hostAliases?: {
|
||||
ip: string;
|
||||
hostnames: string[];
|
||||
};
|
||||
affinity?: IAffinity;
|
||||
};
|
||||
status: {
|
||||
status?: {
|
||||
phase: string;
|
||||
conditions: {
|
||||
type: string;
|
||||
@@ -230,7 +253,7 @@ export class Pod extends WorkloadKubeObject {
|
||||
startTime: string;
|
||||
initContainerStatuses?: IPodContainerStatus[];
|
||||
containerStatuses?: IPodContainerStatus[];
|
||||
qosClass: string;
|
||||
qosClass?: string;
|
||||
reason?: string;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,51 +1,78 @@
|
||||
import get from "lodash/get";
|
||||
import { autobind } from "../../utils";
|
||||
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
|
||||
import { IPodContainer } from "./pods.api";
|
||||
import { WorkloadKubeObject } from "../workload-kube-object";
|
||||
import { IPodContainer, Pod } from "./pods.api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
|
||||
export class ReplicaSetApi extends KubeApi<ReplicaSet> {
|
||||
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 ReplicaSet extends WorkloadKubeObject {
|
||||
static kind = "ReplicaSet";
|
||||
static namespaced = true;
|
||||
static apiBase = "/apis/apps/v1/replicasets";
|
||||
|
||||
spec: {
|
||||
replicas?: number;
|
||||
selector?: {
|
||||
matchLabels: {
|
||||
[key: string]: string;
|
||||
};
|
||||
};
|
||||
containers?: IPodContainer[];
|
||||
selector: { matchLabels: { [app: string]: string } };
|
||||
template?: {
|
||||
spec?: {
|
||||
affinity?: IAffinity;
|
||||
nodeSelector?: {
|
||||
[selector: string]: string;
|
||||
metadata: {
|
||||
labels: {
|
||||
app: string;
|
||||
};
|
||||
tolerations: {
|
||||
key: string;
|
||||
operator: string;
|
||||
effect: string;
|
||||
tolerationSeconds: number;
|
||||
}[];
|
||||
containers: IPodContainer[];
|
||||
};
|
||||
spec?: Pod["spec"];
|
||||
};
|
||||
restartPolicy?: string;
|
||||
terminationGracePeriodSeconds?: number;
|
||||
dnsPolicy?: string;
|
||||
schedulerName?: string;
|
||||
minReadySeconds?: number;
|
||||
};
|
||||
status: {
|
||||
replicas: number;
|
||||
fullyLabeledReplicas: number;
|
||||
readyReplicas: number;
|
||||
availableReplicas: number;
|
||||
observedGeneration: number;
|
||||
fullyLabeledReplicas?: number;
|
||||
readyReplicas?: number;
|
||||
availableReplicas?: number;
|
||||
observedGeneration?: number;
|
||||
conditions?: {
|
||||
type: string;
|
||||
status: string;
|
||||
lastUpdateTime: string;
|
||||
lastTransitionTime: string;
|
||||
reason: string;
|
||||
message: string;
|
||||
}[];
|
||||
};
|
||||
|
||||
getDesired() {
|
||||
return this.spec.replicas || 0;
|
||||
}
|
||||
|
||||
getCurrent() {
|
||||
return this.status.availableReplicas || 0;
|
||||
}
|
||||
|
||||
getReady() {
|
||||
return this.status.readyReplicas || 0;
|
||||
}
|
||||
|
||||
getImages() {
|
||||
const containers: IPodContainer[] = get(this, "spec.template.spec.containers", []);
|
||||
|
||||
@@ -53,6 +80,6 @@ export class ReplicaSet extends WorkloadKubeObject {
|
||||
}
|
||||
}
|
||||
|
||||
export const replicaSetApi = new KubeApi({
|
||||
export const replicaSetApi = new ReplicaSetApi({
|
||||
objectConstructor: ReplicaSet,
|
||||
});
|
||||
Reference in new issue
Block a user