mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Restart deployment (#1175)
Signed-off-by: Pavel Ashevskii <pashevskii@mirantis.com>
This commit is contained in:
1 parent
f9578ba407
commit
d074e0499f
6 files changed
+79
-7
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import moment from "moment";
|
||||
|
||||
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
|
||||
import { autobind } from "../../utils";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@@ -23,6 +25,25 @@ export class DeploymentApi extends KubeApi<Deployment> {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
restart(params: { namespace: string; name: string }) {
|
||||
return this.request.patch(this.getUrl(params), {
|
||||
data: {
|
||||
spec: {
|
||||
template: {
|
||||
metadata: {
|
||||
annotations: {"kubectl.kubernetes.io/restartedAt" : moment.utc().format()}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'application/strategic-merge-patch+json'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@@ -38,6 +59,7 @@ export class Deployment extends WorkloadKubeObject {
|
||||
metadata: {
|
||||
creationTimestamp?: string;
|
||||
labels: { [app: string]: string };
|
||||
annotations?: { [app: string]: string };
|
||||
};
|
||||
spec: {
|
||||
containers: {
|
||||
|
||||
@@ -64,7 +64,7 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
||||
}
|
||||
|
||||
patch<T = D>(path: string, params?: P, reqInit: RequestInit = {}) {
|
||||
return this.request<T>(path, params, { ...reqInit, method: "patch" });
|
||||
return this.request<T>(path, params, { ...reqInit, method: "PATCH" });
|
||||
}
|
||||
|
||||
del<T = D>(path: string, params?: P, reqInit: RequestInit = {}) {
|
||||
|
||||
@@ -4,11 +4,12 @@ import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { RouteComponentProps } from "react-router";
|
||||
import { t, Trans } from "@lingui/macro";
|
||||
import { Deployment } from "../../api/endpoints";
|
||||
import { Deployment, deploymentApi } from "../../api/endpoints";
|
||||
import { KubeObjectMenuProps } from "../kube-object/kube-object-menu";
|
||||
import { MenuItem } from "../menu";
|
||||
import { Icon } from "../icon";
|
||||
import { DeploymentScaleDialog } from "./deployment-scale-dialog";
|
||||
import { ConfirmDialog } from "../confirm-dialog";
|
||||
import { deploymentStore } from "./deployments.store";
|
||||
import { replicaSetStore } from "../+workloads-replicasets/replicasets.store";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
@@ -22,6 +23,8 @@ import kebabCase from "lodash/kebabCase";
|
||||
import orderBy from "lodash/orderBy";
|
||||
import { KubeEventIcon } from "../+events/kube-event-icon";
|
||||
import { kubeObjectMenuRegistry } from "../../../extensions/registries/kube-object-menu-registry";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { Notifications } from "../notifications";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@@ -96,10 +99,34 @@ export class Deployments extends React.Component<Props> {
|
||||
export function DeploymentMenu(props: KubeObjectMenuProps<Deployment>) {
|
||||
const { object, toolbar } = props;
|
||||
return (
|
||||
<MenuItem onClick={() => DeploymentScaleDialog.open(object)}>
|
||||
<Icon material="open_with" title={_i18n._(t`Scale`)} interactive={toolbar}/>
|
||||
<span className="title"><Trans>Scale</Trans></span>
|
||||
</MenuItem>
|
||||
<>
|
||||
<MenuItem onClick={() => DeploymentScaleDialog.open(object)}>
|
||||
<Icon material="open_with" title={_i18n._(t`Scale`)} interactive={toolbar}/>
|
||||
<span className="title"><Trans>Scale</Trans></span>
|
||||
</MenuItem>
|
||||
<MenuItem onClick={() => ConfirmDialog.open({
|
||||
ok: async () =>
|
||||
{
|
||||
try {
|
||||
await deploymentApi.restart({
|
||||
namespace: object.getNs(),
|
||||
name: object.getName(),
|
||||
})
|
||||
} catch (err) {
|
||||
Notifications.error(err);
|
||||
}
|
||||
},
|
||||
labelOk: _i18n._(t`Restart`),
|
||||
message: (
|
||||
<p>
|
||||
<Trans>Are you sure you want to restart deployment <b>{object.getName()}</b>?</Trans>
|
||||
</p>
|
||||
),
|
||||
})}>
|
||||
<Icon material="autorenew" title={_i18n._(t`Restart`)} interactive={toolbar}/>
|
||||
<span className="title"><Trans>Restart</Trans></span>
|
||||
</MenuItem>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -110,4 +137,3 @@ kubeObjectMenuRegistry.add({
|
||||
MenuItem: DeploymentMenu
|
||||
}
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user