运行态观测

nae pods

Pod 列表(原始 k8s Pod 对象,下为节选)。

nae pods myweb
[
  {
    "metadata": { "name": "app-42-myweb-7d6c9b8f5-2xqzr", "namespace": "tenant-8" },
    "status": {
      "phase": "Running",
      "podIP": "10.42.0.37",
      "containerStatuses": [
        { "name": "app", "ready": true, "restartCount": 0 }
      ]
    }
  }
]

nae events

事件 / 时间线(倒序,--limit 默认 100)。

nae events myweb --limit 50
[
  { "ID": 320, "AppID": 42, "Type": "started", "Message": "应用已启动", "Operator": "user#8", "CreatedAt": "2026-06-22T10:00:05Z" },
  { "ID": 319, "AppID": 42, "Type": "deploy_succeeded", "Message": "部署成功", "Operator": "system", "CreatedAt": "2026-06-22T09:51:10Z" }
]

nae metrics

各 Pod 实时资源用量(原始 k8s metrics 对象,下为节选)。

nae metrics myweb
[
  {
    "metadata": { "name": "app-42-myweb-7d6c9b8f5-2xqzr", "namespace": "tenant-8" },
    "timestamp": "2026-06-22T10:05:00Z",
    "window": "30s",
    "containers": [
      { "name": "app", "usage": { "cpu": "12m", "memory": "84Mi" } }
    ]
  }
]

nae logs

应用日志(缺省自动取首个 Pod;--follow 持续跟随,Ctrl-C 结束)。输出为纯文本行,不是 JSON。

nae logs myweb --tail 200          # 取末 200 行后退出
nae logs myweb --follow            # 持续跟随
nae logs myweb --pod <pod> --container <c>
2026-06-22T10:05:01Z INFO  server listening on :8080
2026-06-22T10:05:12Z INFO  GET /healthz 200

nae exec

在应用容器内执行一条命令(非交互)。命令写在 -- 之后;缺省取首个运行中的 Pod。CLI 把命令的 stdout/stderr 原样输出,进程退出码 = 远端命令退出码。需要容器内有对应的可执行文件(scratch/distroless 无 shell 时执行会失败)。交互式终端请用网页端「终端」。

nae exec myweb -- ls -la /app
nae exec myweb --pod <pod> -- env

底层端点返回如下(CLI 已据此直出文本与退出码):

{
  "pod": "app-42-myweb-7d6c9b8f5-2xqzr",
  "stdout": "total 8\ndrwxr-xr-x 2 root root 4096 Jun 22 10:00 .\n",
  "stderr": "",
  "exit_code": 0
}