文档中心
学习如何使用 NXTCTL 管理你的 Kubernetes 集群
快速开始
1
下载安装
从官方下载页面获取适合你系统的二进制文件
# 下载后解压到系统路径
# Linux/macOS
chmod +x nxtctl
sudo mv nxtctl /usr/local/bin/
# Windows
# 解压后将 nxtctl.exe 添加到 PATH 环境变量
2
验证安装
确认 NXTCTL 已正确安装
nxtctl version
3
查看帮助
查看可用的命令和选项
nxtctl --help
4
开始使用
执行你的第一个命令 - 体验强大的链路追踪功能
nxtctl span 7673ca1c574fe908 --html
命令参考
logs
查询 Kubernetes 集群日志(流式实时搜索)
示例用法:
nxtctl logs -c dev -a user-service -k "error" "timeout" -B 2 -A 3
可用选项:
-c, --cluster
集群名称-a, --app
应用名称-k, --keyword
搜索关键词(支持多个)-A, --after
显示匹配后的行数-B, --before
显示匹配前的行数--zgrep
搜索压缩文件--stream
启用流式输出
span
查询分布式链路 span 详情(跨租户搜索)
示例用法:
nxtctl span 7673ca1c574fe908 --html
可用选项:
<span_id>
span ID(必填)--html
以 HTML 格式输出--no-progress
隐藏租户查询进度条
inspect
基于 Prometheus 的系统巡检工具
示例用法:
nxtctl inspect --config config.yaml --format pdf
可用选项:
--config
配置文件路径--output
报告输出目录--format
输出格式 (html/json/md/pdf/self-contained-html)--type
指定检查的指标类型--history
显示历史报告列表--generate-only
仅生成报告,不打开
pass
生成安全密码(支持 UUID 格式)
示例用法:
nxtctl pass 16 --no-special
可用选项:
[length]
密码长度(可选,默认12)--uuid
生成 UUID 样式密码--no-special
不包含特殊字符--numbers
包含数字--complexity
确保复杂度
rio
里约接口请求监控和分析
示例用法:
nxtctl rio timeout 10m 10
可用选项:
timeout <duration> <count>
监控超时请求long <duration> <count>
监控耗时请求<duration>
时间范围 (如<count>
显示数量
trace
查询链路追踪信息
示例用法:
nxtctl trace yw dzsj true 24h 3000
可用选项:
<region>
区域 (yw/hlw)<cluster>
集群名称<error_only>
仅显示错误 (true/false)<duration>
时间范围<min_duration_ms>
最小耗时(毫秒)
list
列出 Kubernetes 集群资源
示例用法:
nxtctl list -c dzsj -t deployments
可用选项:
-c, --cluster
集群名称-t, --type
资源类型 (deployments/pods)-n, --namespace
命名空间
nali
IP 地址归属地查询
示例用法:
nxtctl nali 8.8.8.8
可用选项:
<ip_address>
IP 地址(必填)
shot
命令执行截图和分享工具
示例用法:
nxtctl shot kubectl get pods --phone 13888888888
可用选项:
[command]
要截图的命令(可选)--phone
分享到指定手机号
配置说明
配置文件位置
系统配置:
/etc/nxtctl/config.toml
用户配置:
$HOME/.config/nxtctl/config.toml
Inspect 巡检配置示例
prometheus: "http://prometheus-server:9090"
project_name: "我的项目"
metric_types:
- type: "基础资源使用情况"
metrics:
- name: "CPU使用率"
query: "100 * (1 - avg(rate(node_cpu_seconds_total{mode='idle'}[5m])))"
threshold: 80
threshold_type: "greater"
unit: "%"
- name: "内存使用率"
query: "100 * (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes))"
threshold: 85
threshold_type: "greater"
unit: "%"
环境变量
PROMETHEUS_URL
Prometheus 服务器地址KUBECONFIG
Kubernetes 配置文件路径常见问题
如何添加新的集群配置?
NXTCTL 内置了常用的集群配置。如需添加新集群,可以通过环境变量 KUBECONFIG 指定自定义的配置文件。
日志查询速度慢怎么办?
可以使用更精确的应用名称和关键词过滤,减少搜索范围。同时确保集群网络连接稳定。
Inspect 巡检报告不准确?
检查 Prometheus 配置和查询语句是否正确,确保阈值设置合理。可以通过配置文件调整监控指标。