k8s 内部集群怎么查
时间: 2023-05-18 12:05:32 浏览: 61
k8s 内部集群可以通过以下方式进行查看:
1. 使用 kubectl 命令行工具
可以使用 kubectl 命令行工具来查看 k8s 内部集群的状态和信息。例如,可以使用以下命令查看当前集群中的所有节点:
```
kubectl get nodes
```
2. 使用 Kubernetes Dashboard
Kubernetes Dashboard 是一个基于 Web 的用户界面,可以用于查看 k8s 内部集群的状态和信息。可以通过以下命令安装 Kubernetes Dashboard:
```
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
```
安装完成后,可以通过以下命令启动 Kubernetes Dashboard:
```
kubectl proxy
```
然后在浏览器中访问 http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/,即可进入 Kubernetes Dashboard。
3. 使用 Prometheus 和 Grafana
可以使用 Prometheus 和 Grafana 来监控和可视化 k8s 内部集群的状态和信息。可以通过以下命令安装 Prometheus 和 Grafana:
```
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.41.2/deploy/static/provider/baremetal/deploy.yaml
```
安装完成后,可以通过以下命令启动 Prometheus 和 Grafana:
```
kubectl port-forward -n monitoring prometheus-prometheus-0 9090
kubectl port-forward -n monitoring grafana-7f9c7f7f6c-8l8jz 3000
```
然后在浏览器中访问 http://localhost:9090/,即可进入 Prometheus;访问 http://localhost:3000/,即可进入 Grafana。