/** * Copyright (c) 2021 OpenLens Authors * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ import "./deployment-details.scss"; import React from "react"; import kebabCase from "lodash/kebabCase"; import { disposeOnUnmount, observer } from "mobx-react"; import { DrawerItem } from "../drawer"; import { Badge } from "../badge"; import { Deployment } from "../../api/endpoints"; import { cssNames } from "../../utils"; import { PodDetailsTolerations } from "../+workloads-pods/pod-details-tolerations"; import { PodDetailsAffinities } from "../+workloads-pods/pod-details-affinities"; import { KubeEventDetails } from "../+events/kube-event-details"; import { podsStore } from "../+workloads-pods/pods.store"; import { KubeObjectDetailsProps } from "../kube-object"; import { ResourceMetrics, ResourceMetricsText } from "../resource-metrics"; import { deploymentStore } from "./deployments.store"; import { PodCharts, podMetricTabs } from "../+workloads-pods/pod-charts"; import { reaction } from "mobx"; import { PodDetailsList } from "../+workloads-pods/pod-details-list"; import { KubeObjectMeta } from "../kube-object/kube-object-meta"; import { kubeObjectDetailRegistry } from "../../api/kube-object-detail-registry"; import { ResourceType } from "../cluster-settings/components/cluster-metrics-setting"; import { ClusterStore } from "../../../common/cluster-store"; import { replicaSetStore } from "../+workloads-replicasets/replicasets.store"; import { DeploymentReplicaSets } from "./deployment-replicasets"; interface Props extends KubeObjectDetailsProps { } @observer export class DeploymentDetails extends React.Component { @disposeOnUnmount clean = reaction(() => this.props.object, () => { deploymentStore.reset(); }); componentDidMount() { podsStore.reloadAll(); replicaSetStore.reloadAll(); } componentWillUnmount() { deploymentStore.reset(); } render() { const { object: deployment } = this.props; if (!deployment) return null; const { status, spec } = deployment; const nodeSelector = deployment.getNodeSelectors(); const selectors = deployment.getSelectors(); const childPods = deploymentStore.getChildPods(deployment); const replicaSets = replicaSetStore.getReplicaSetsByOwner(deployment); const metrics = deploymentStore.metrics; const isMetricHidden = ClusterStore.getInstance().isMetricHidden(ResourceType.Deployment); return (
{!isMetricHidden && podsStore.isLoaded && ( deploymentStore.loadMetrics(deployment)} tabs={podMetricTabs} object={deployment} params={{ metrics }} > )} {`${spec.replicas} desired, ${status.updatedReplicas || 0} updated`},{" "} {`${status.replicas || 0} total, ${status.availableReplicas || 0} available`},{" "} {`${status.unavailableReplicas || 0} unavailable`} {selectors.length > 0 && { selectors.map(label => ) } } {nodeSelector.length > 0 && { nodeSelector.map(label => ( )) } } {spec.strategy.type} { deployment.getConditions().map(condition => { const { type, message, lastTransitionTime, status } = condition; return (

{message}

Last transition time: {lastTransitionTime}

)} /> ); }) }
); } } kubeObjectDetailRegistry.add({ kind: "Deployment", apiVersions: ["apps/v1"], components: { Details: (props: any) => } }); kubeObjectDetailRegistry.add({ kind: "Deployment", apiVersions: ["apps/v1"], priority: 5, components: { Details: (props: any) => } });