4.6 KiB
4.6 KiB
Kubernetes 服务端口参考
服务端口映射
Web UI 服务
| 服务 | 本地端口 | 集群端口 | 访问地址 | 认证方式 |
|---|---|---|---|---|
| Grafana | 30300 | 3000 | http://localhost:30300 | admin / admin123 |
| Prometheus | 30900 | 9090 | http://localhost:30900 | 无 |
| Kubernetes Dashboard | 9443 | 443 | https://localhost:9443 | Token |
| ArgoCD | 30080 | 8080 | http://localhost:30080 | admin / admin123 |
| Harbor | 8080 / 8443 | - | http://192.168.1.83:8080 | admin / admin123 |
数据库服务
| 服务 | 命名空间 | Service Port | 说明 |
|---|---|---|---|
| PostgreSQL | data | 5432 | 主数据库 |
| MySQL | data | 3306 | 应用数据库 |
| Redis | data | 6379 | 缓存服务 |
Exporter 服务(Metrics)
| Exporter | 命名空间 | Port | 说明 |
|---|---|---|---|
| PostgreSQL Exporter | data | 9187 | PostgreSQL 指标 |
| MySQL Exporter | data | 9104 | MySQL 指标(增强版,27 collectors) |
| Redis Exporter | data | 9121 | Redis 指标 |
| Node Exporter | monitoring | 9100 | 节点指标 |
| kube-state-metrics | kube-system | 8080 | K8s 对象状态 |
可观测性栈
| 服务 | 命名空间 | Port | 用途 |
|---|---|---|---|
| Loki | logging | 3100 | 日志聚合 |
| Promtail | logging | 3101 | 日志采集 |
| Tempo | tracing | 3200 | 链路追踪 HTTP |
| Tempo | tracing | 9411 | Zipkin 兼容 |
| OTel Collector | tracing | 4317 | OTLP gRPC |
| OTel Collector | tracing | 4318 | OTLP HTTP |
端口转发命令
Grafana
# 通过 NodePort 访问(推荐)
open http://localhost:30300
# 或通过端口转发
kubectl port-forward -n monitoring svc/grafana 3000:3000
Kubernetes Dashboard
# 使用 9443 端口(8443 被 Harbor 占用)
kubectl port-forward -n kubernetes-dashboard svc/kubernetes-dashboard 9443:443
open https://localhost:9443
Prometheus
# 通过 NodePort 访问(推荐)
open http://localhost:30900
# 或通过端口转发
kubectl port-forward -n monitoring svc/prometheus 9090:9090
ArgoCD
# 通过 NodePort 访问
open http://localhost:30080
# 或通过端口转发
kubectl port-forward -n argocd svc/argocd-server 8080:8080
PostgreSQL(仅限集群内访问)
# 端口转发到本地(用于调试)
kubectl port-forward -n data svc/postgres-postgresql 5432:5432
# 连接
psql -h localhost -U postgres -d postgres
MySQL(仅限集群内访问)
# 端口转发到本地(用于调试)
kubectl port-forward -n data svc/mysql 3306:3306
# 连接
mysql -h 127.0.0.1 -P 3306 -u root -p
Redis(仅限集群内访问)
# 端口转发到本地(用于调试)
kubectl port-forward -n data svc/redis-master 6379:6379
# 连接
redis-cli -h localhost -p 6379
端口冲突说明
8443 端口冲突
问题: Kubernetes Dashboard 默认使用 8443 端口,但该端口已被 Harbor 占用。
解决方案: Dashboard 改用 9443 端口进行端口转发。
相关服务占用:
- 8443: Harbor HTTPS 端口
- 8444: OrbStack 保留端口
- 9443: Kubernetes Dashboard(本地端口转发)
Harbor 端口占用
Harbor 使用的端口:
- 8080: HTTP 访问 (http://192.168.1.83:8080)
- 8443: HTTPS 访问 (https://192.168.1.83:8443)
快速访问脚本
Dashboard 一键访问
cd /Users/brunogao/work/codes/tools/macos/k8s
./access-dashboard.sh
自动完成:
- 检查 Dashboard 状态
- 获取 Token
- 启动端口转发(9443:443)
- 打开浏览器
服务发现
查看所有 Services
kubectl get svc --all-namespaces | grep -E "NodePort|LoadBalancer"
查看某个 Service 详情
kubectl describe svc <service-name> -n <namespace>
查看端口映射
kubectl get svc <service-name> -n <namespace> -o jsonpath='{.spec.ports[*]}'
网络策略
重要: 数据库服务(PostgreSQL, MySQL, Redis)仅允许集群内访问,不对外暴露。
如需从本地访问:
- 使用
kubectl port-forward(临时调试) - 使用
kubectl exec进入 Pod 内部 - 通过应用层代理访问
相关文档
- Dashboard 访问: DASHBOARD-ACCESS-GUIDE.md
- 主 README: README.md
- 企业级增强报告: ENTERPRISE-K8S-IMPLEMENTATION-REPORT.md
最后更新: 2025-12-24 集群版本: Kubernetes v1.33.5+orb1