2022-05-31 16:12:04 +08:00
|
|
|
apiVersion: v1
|
|
|
|
|
kind: ConfigMap
|
|
|
|
|
metadata:
|
|
|
|
|
name: test-component-pod-view
|
|
|
|
|
namespace: vela-system
|
|
|
|
|
data:
|
|
|
|
|
template: |
|
|
|
|
|
import (
|
|
|
|
|
"vela/ql"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parameter: {
|
|
|
|
|
appName: string
|
|
|
|
|
appNs: string
|
|
|
|
|
name?: string
|
|
|
|
|
cluster?: string
|
|
|
|
|
clusterNs?: string
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 19:44:27 +08:00
|
|
|
result: ql.#CollectPods & {
|
2022-05-31 16:12:04 +08:00
|
|
|
app: {
|
|
|
|
|
name: parameter.appName
|
|
|
|
|
namespace: parameter.appNs
|
|
|
|
|
filter: {
|
|
|
|
|
if parameter.cluster != _|_ {
|
|
|
|
|
cluster: parameter.cluster
|
|
|
|
|
}
|
|
|
|
|
if parameter.clusterNs != _|_ {
|
|
|
|
|
clusterNamespace: parameter.clusterNs
|
|
|
|
|
}
|
|
|
|
|
if parameter.name != _|_ {
|
|
|
|
|
components: [parameter.name]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 19:44:27 +08:00
|
|
|
if result.err == _|_ {
|
|
|
|
|
status: {
|
|
|
|
|
podList: [ for pod in result.list if pod.object != _|_ {
|
|
|
|
|
cluster: pod.cluster
|
|
|
|
|
workload: pod.workload
|
|
|
|
|
component: pod.component
|
|
|
|
|
metadata: {
|
|
|
|
|
name: pod.object.metadata.name
|
|
|
|
|
namespace: pod.object.metadata.namespace
|
|
|
|
|
creationTime: pod.object.metadata.creationTimestamp
|
|
|
|
|
labels: pod.object.metadata.labels
|
|
|
|
|
version: {
|
|
|
|
|
if pod.publishVersion != _|_ {
|
|
|
|
|
publishVersion: pod.publishVersion
|
2022-05-31 16:12:04 +08:00
|
|
|
}
|
2022-08-01 19:44:27 +08:00
|
|
|
if pod.deployVersion != _|_ {
|
|
|
|
|
deployVersion: pod.deployVersion
|
2022-05-31 16:12:04 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-01 19:44:27 +08:00
|
|
|
status: {
|
|
|
|
|
phase: pod.object.status.phase
|
|
|
|
|
// refer to https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase
|
|
|
|
|
if phase != "Pending" && phase != "Unknown" {
|
|
|
|
|
podIP: pod.object.status.podIP
|
|
|
|
|
hostIP: pod.object.status.hostIP
|
|
|
|
|
nodeName: pod.object.spec.nodeName
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}]
|
2022-05-31 16:12:04 +08:00
|
|
|
}
|
2022-08-01 19:44:27 +08:00
|
|
|
}
|
2022-05-31 16:12:04 +08:00
|
|
|
|
2022-08-01 19:44:27 +08:00
|
|
|
if result.err != _|_ {
|
2022-05-31 16:12:04 +08:00
|
|
|
status: {
|
2022-08-01 19:44:27 +08:00
|
|
|
error: result.err
|
2022-05-31 16:12:04 +08:00
|
|
|
}
|
|
|
|
|
}
|