query workload pods in a graceful way, which supports paging
This commit is contained in:
@@ -175,6 +175,14 @@ func (ctl *PodCtl) generateObject(item v1.Pod) *Pod {
|
|||||||
createTime := item.CreationTimestamp.Time
|
createTime := item.CreationTimestamp.Time
|
||||||
containerStatus := item.Status.ContainerStatuses
|
containerStatus := item.Status.ContainerStatuses
|
||||||
containerSpecs := item.Spec.Containers
|
containerSpecs := item.Spec.Containers
|
||||||
|
var ownerKind, ownerName string
|
||||||
|
|
||||||
|
// For ReplicaSet,ReplicaController,DaemonSet,StatefulSet,Job,CronJob, k8s will automatically
|
||||||
|
// set ownerReference for pods, in case of setting ownerReference manually.
|
||||||
|
if item.OwnerReferences != nil && len(item.OwnerReferences) > 0 {
|
||||||
|
ownerKind = item.OwnerReferences[0].Kind
|
||||||
|
ownerName = item.OwnerReferences[0].Name
|
||||||
|
}
|
||||||
|
|
||||||
var containers Containers
|
var containers Containers
|
||||||
|
|
||||||
@@ -204,6 +212,8 @@ func (ctl *PodCtl) generateObject(item v1.Pod) *Pod {
|
|||||||
Annotation: MapString{item.Annotations},
|
Annotation: MapString{item.Annotations},
|
||||||
Containers: containers,
|
Containers: containers,
|
||||||
RestartCount: restartCount,
|
RestartCount: restartCount,
|
||||||
|
OwnerKind: ownerKind,
|
||||||
|
OwnerName: ownerName,
|
||||||
Labels: MapString{item.Labels},
|
Labels: MapString{item.Labels},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -219,6 +219,8 @@ type Pod struct {
|
|||||||
Containers Containers `gorm:"type:text" json:"containers,omitempty"`
|
Containers Containers `gorm:"type:text" json:"containers,omitempty"`
|
||||||
Annotation MapString `json:"annotations"`
|
Annotation MapString `json:"annotations"`
|
||||||
Labels MapString `json:"labels"`
|
Labels MapString `json:"labels"`
|
||||||
|
OwnerKind string `gorm:"column:ownerKind" json:"ownerKind,omitempty"`
|
||||||
|
OwnerName string `gorm:"column:ownerName" json:"ownerName,omitempty"`
|
||||||
RestartCount int `json:"restartCount"`
|
RestartCount int `json:"restartCount"`
|
||||||
CreateTime time.Time `gorm:"column:createTime" json:"createTime,omitempty"`
|
CreateTime time.Time `gorm:"column:createTime" json:"createTime,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user