提交 1a6851b0 编写于 作者: M Marcin Maciaszczyk 提交者: GitHub

Add QoS class info to pod detail view (#2486)

* Add QoS class info to pod detail view

* Update info.html
上级 20786d7d
......@@ -674,6 +674,7 @@
<translation id="3180983899887518304" key="MSG_POD_DETAIL_DETAIL_3" desc="Subtitle at the top of the container details.">Init Containers</translation>
<translation id="855512770998820017" key="MSG_POD_DETAIL_INFO_0" desc="Header in a detail view">Details</translation>
<translation id="1457675883548195036" key="MSG_POD_DETAIL_INFO_1" desc="Label \'Status\' for the pod status in details part (left) of the pod details view.">Status</translation>
<translation id="8935630379646428748" key="MSG_POD_DETAIL_INFO_2" desc="Label \'QoS Class\' for the pod QoS class in the pod details view.">QoS Class</translation>
<translation id="694126564552626450" key="MSG_POD_DETAIL_INFO_3" desc="Subtitle \'Network\' at the top of the column about network connectivity (right) at the pod detail view.">Network</translation>
<translation id="7855013997463493128" key="MSG_POD_DETAIL_INFO_4" desc="Label \'Node\' for the node a pods is running on, appears in the connectivity part (right) of the pod details view.">Node</translation>
<translation id="7683783814970718475" key="MSG_POD_DETAIL_INFO_5" desc="Label \'IP\' for the pod internal IP, appears in the connectivity part (right) of the pod details view.">IP</translation>
......
......@@ -680,6 +680,7 @@
<translation id="3180983899887518304" key="MSG_POD_DETAIL_DETAIL_3" desc="Subtitle at the top of the container details.">初期コンテナ</translation>
<translation id="855512770998820017" key="MSG_POD_DETAIL_INFO_0" desc="Header in a detail view">詳細</translation>
<translation id="1457675883548195036" key="MSG_POD_DETAIL_INFO_1" desc="Label \'Status\' for the pod status in details part (left) of the pod details view.">状態</translation>
<translation id="8935630379646428748" key="MSG_POD_DETAIL_INFO_2" desc="Label \'QoS Class\' for the pod QoS class in the pod details view.">QoS Class</translation>
<translation id="694126564552626450" key="MSG_POD_DETAIL_INFO_3" desc="Subtitle \'Network\' at the top of the column about network connectivity (right) at the pod detail view.">ネットワーク</translation>
<translation id="7855013997463493128" key="MSG_POD_DETAIL_INFO_4" desc="Label \'Node\' for the node a pods is running on, appears in the connectivity part (right) of the pod details view.">ノード</translation>
<translation id="7683783814970718475" key="MSG_POD_DETAIL_INFO_5" desc="Label \'IP\' for the pod internal IP, appears in the connectivity part (right) of the pod details view.">IP</translation>
......
......@@ -672,6 +672,7 @@
<translation id="3180983899887518304" key="MSG_POD_DETAIL_DETAIL_3" desc="Subtitle at the top of the container details.">初始化容器</translation>
<translation id="855512770998820017" key="MSG_POD_DETAIL_INFO_0" desc="Header in a detail view">詳細資訊</translation>
<translation id="1457675883548195036" key="MSG_POD_DETAIL_INFO_1" desc="Label \'Status\' for the pod status in details part (left) of the pod details view.">狀態</translation>
<translation id="8935630379646428748" key="MSG_POD_DETAIL_INFO_2" desc="Label \'QoS Class\' for the pod QoS class in the pod details view.">QoS Class</translation>
<translation id="694126564552626450" key="MSG_POD_DETAIL_INFO_3" desc="Subtitle \'Network\' at the top of the column about network connectivity (right) at the pod detail view.">網路</translation>
<translation id="7855013997463493128" key="MSG_POD_DETAIL_INFO_4" desc="Label \'Node\' for the node a pods is running on, appears in the connectivity part (right) of the pod details view.">節點</translation>
<translation id="7683783814970718475" key="MSG_POD_DETAIL_INFO_5" desc="Label \'IP\' for the pod internal IP, appears in the connectivity part (right) of the pod details view.">IP</translation>
......
......@@ -674,6 +674,7 @@
<translation id="3180983899887518304" key="MSG_POD_DETAIL_DETAIL_3" desc="Subtitle at the top of the container details.">初始化容器</translation>
<translation id="855512770998820017" key="MSG_POD_DETAIL_INFO_0" desc="Header in a detail view">详情</translation>
<translation id="1457675883548195036" key="MSG_POD_DETAIL_INFO_1" desc="Label \'Status\' for the pod status in details part (left) of the pod details view.">状态</translation>
<translation id="8935630379646428748" key="MSG_POD_DETAIL_INFO_2" desc="Label \'QoS Class\' for the pod QoS class in the pod details view.">QoS Class</translation>
<translation id="694126564552626450" key="MSG_POD_DETAIL_INFO_3" desc="Subtitle \'Network\' at the top of the column about network connectivity (right) at the pod detail view.">网络</translation>
<translation id="7855013997463493128" key="MSG_POD_DETAIL_INFO_4" desc="Label \'Node\' for the node a pods is running on, appears in the connectivity part (right) of the pod details view.">节点</translation>
<translation id="7683783814970718475" key="MSG_POD_DETAIL_INFO_5" desc="Label \'IP\' for the pod internal IP, appears in the connectivity part (right) of the pod details view.">IP</translation>
......
......@@ -28,49 +28,27 @@ import (
"github.com/kubernetes/dashboard/src/app/backend/resource/controller"
"github.com/kubernetes/dashboard/src/app/backend/resource/dataselect"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
res "k8s.io/apimachinery/pkg/api/resource"
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes"
)
// PodDetail is a presentation layer view of Kubernetes PodDetail resource. This means it is
// PodDetail plus additional augmented data we can get from other sources (like services that
// target it).
// PodDetail is a presentation layer view of Kubernetes Pod resource.
type PodDetail struct {
ObjectMeta api.ObjectMeta `json:"objectMeta"`
TypeMeta api.TypeMeta `json:"typeMeta"`
// Status of the Pod. See Kubernetes API for reference.
PodPhase v1.PodPhase `json:"podPhase"`
// IP address of the Pod.
PodIP string `json:"podIP"`
// Name of the Node this Pod runs on.
NodeName string `json:"nodeName"`
// Count of containers restarts.
RestartCount int32 `json:"restartCount"`
// Reference to the Controller
Controller controller.ResourceOwner `json:"controller"`
// List of container of this pod.
Containers []Container `json:"containers"`
// List of initContainer of this pod.
InitContainers []Container `json:"initContainers"`
// Metrics collected for this resource
Metrics []metricapi.Metric `json:"metrics"`
// Conditions of this pod.
Conditions []common.Condition `json:"conditions"`
// Events is list of events associated with a pod.
EventList common.EventList `json:"eventList"`
ObjectMeta api.ObjectMeta `json:"objectMeta"`
TypeMeta api.TypeMeta `json:"typeMeta"`
PodPhase v1.PodPhase `json:"podPhase"`
PodIP string `json:"podIP"`
NodeName string `json:"nodeName"`
RestartCount int32 `json:"restartCount"`
QOSClass string `json:"qosClass"`
Controller controller.ResourceOwner `json:"controller"`
Containers []Container `json:"containers"`
InitContainers []Container `json:"initContainers"`
Metrics []metricapi.Metric `json:"metrics"`
Conditions []common.Condition `json:"conditions"`
EventList common.EventList `json:"eventList"`
// List of non-critical errors, that occurred during resource retrieval.
Errors []error `json:"errors"`
......@@ -108,9 +86,9 @@ type EnvVar struct {
ValueFrom *v1.EnvVarSource `json:"valueFrom"`
}
// GetPodDetail returns the details (PodDetail) of a named Pod from a particular namespace.
// TODO(maciaszczykm): Owner reference should be used instead of created by annotation.
func GetPodDetail(client kubernetes.Interface, metricClient metricapi.MetricClient, namespace, name string) (*PodDetail, error) {
// GetPodDetail returns the details of a named Pod from a particular namespace.
func GetPodDetail(client kubernetes.Interface, metricClient metricapi.MetricClient, namespace, name string) (
*PodDetail, error) {
log.Printf("Getting details of %s pod in %s namespace", name, namespace)
channels := &common.ResourceChannels{
......@@ -188,15 +166,6 @@ func getPodController(client kubernetes.Interface, nsQuery *common.NamespaceQuer
return
}
// isNotFoundError returns true when the given error is 404-NotFound error.
func isNotFoundError(err error) bool {
statusErr, ok := err.(*errors.StatusError)
if !ok {
return false
}
return statusErr.ErrStatus.Code == 404
}
func extractContainerInfo(containerList []v1.Container, pod *v1.Pod, configMaps *v1.ConfigMapList, secrets *v1.SecretList) []Container {
containers := make([]Container, 0)
for _, container := range containerList {
......@@ -234,6 +203,7 @@ func toPodDetail(pod *v1.Pod, metrics []metricapi.Metric, configMaps *v1.ConfigM
PodPhase: pod.Status.Phase,
PodIP: pod.Status.PodIP,
RestartCount: getRestartCount(*pod),
QOSClass: string(pod.Status.QOSClass),
NodeName: pod.Spec.NodeName,
Controller: controller,
Containers: extractContainerInfo(pod.Spec.Containers, pod, configMaps, secrets),
......
......@@ -829,6 +829,7 @@ backendApi.PodStatus;
* podStatus: !backendApi.PodStatus,
* podIP: string,
* restartCount: number,
* qosClass: string,
* metrics: backendApi.PodMetrics,
* warnings: !Array<!backendApi.Event>,
* nodeName: string
......
......@@ -22,8 +22,11 @@ limitations under the License.
<kd-info-card-entry title="[[Status|Label 'Status' for the pod status in details part (left) of the pod details view.]]">
{{::$ctrl.pod.podPhase}}
</kd-info-card-entry>
<kd-info-card-entry title="[[QoS Class|Label 'QoS Class' for the pod QoS class in the pod details view.]]">
<span ng-if="$ctrl.pod.qosClass">{{::$ctrl.pod.qosClass}}</span>
<span ng-if="!$ctrl.pod.qosClass">-</span>
</kd-info-card-entry>
</kd-info-card-section>
<kd-info-card-section name="[[Network|Subtitle 'Network' at the top of the column about network connectivity (right) at the pod detail view.]]">
<kd-info-card-entry title="[[Node|Label 'Node' for the node a pods is running on, appears in the connectivity part (right) of the pod details view.]]">
<a href="{{$ctrl.getNodeDetailsHref()}}">{{::$ctrl.pod.nodeName}}</a>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册