使用 ArgoCD 监控 kube-prometheus-stack (prometheus+grafana)

前提条件 tí

使用kind进行设置的内容省略如下所示,请参考下方。

示例:部署 kube-prometheus-stack。

按照以下的清单并使用GUI设置每个项,或使用kubectl apply部署,以与kubernetes-dashboard的部署步骤※相同。

※:https://qiita.com/KO_YAmajun/items/dc24e03275eab7e3f9af#%E3%82%B5%E3%83%B3%E3%83%97%E3%83%ABkubernetes-dashboard%E3%81%AE%E3%83%87%E3%83%97%E3%83%AD%E3%82%A4

※:https://qiita.com/KO_YAmajun/items/dc24e03275eab7e3f9af#%E3%82%B5%E3%83%B3%E3%83%97%E3%83%ABkubernetes-dashboard%E3%81%AE%E3%83%87%E3%83%97%E3%83%AD%E3%82%A4

project: default
source:
  repoURL: 'https://prometheus-community.github.io/helm-charts'
  targetRevision: 16.11.0
  helm:
    valueFiles:
      - values.yaml
    parameters:
      - name: prometheusOperator.admissionWebhooks.failurePolicy
        value: Ignore
  chart: kube-prometheus-stack
destination:
  server: 'https://kubernetes.default.svc'
  namespace: prometheus-community
syncPolicy:
  syncOptions:
    - CreateNamespace=true

端口转发

按照 argoCD 文章中的操作,只需进行端口转发即可。
grafana 的默认端口是3000,但下面的服务端口是80,因此替换 argoCD 的端口转发步骤,执行18080:80的转发。
https://qiita.com/KO_YAmajun/items/dc24e03275eab7e3f9af#argocd-ui%E6%8E%A5%E7%B6%9A

连接

PS C:\Users\aruki\Desktop\dev\kind\dashboard> kubectl get svc -A
NAMESPACE              NAME                                                TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                        AGE
argocd                 argocd-server                                       LoadBalancer   10.96.98.229    <pending>     80:31078/TCP,443:30231/TCP     3h23m
prometheus-stack       prometheus-community-grafana                        ClusterIP      10.96.247.200   <none>        80/TCP                         102m

最终,按照预期将被转发到3000端口。

kubectl port-forward svc/kube-prometheus-stack-grafana -n prometheus-community 18080:80
#>Forwarding from 127.0.0.1:18080 -> 3000
#>Forwarding from [::1]:18080 -> 3000

登录到Grafana

ID:管理员
密码:prom-operator

用户ID:admin
密码:prom-operator

身份证号码:管理员
密码:prom-operator

身份证件:admin
密码:prom-operator

帐户ID:管理员
密码:prom-operator

最终,促使通过 Prometheus 可如预期地获取到各个资源的指标数据。

image.png

此外,实例的IP与INTERNAL-IP相匹配。

kubectl get nodes -o wide
#>NAME                 STATUS   ROLES                  AGE     VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE       #>KERNEL-VERSION                   CONTAINER-RUNTIME
#>kind-control-plane   Ready    control-plane,master   3h35m   v1.21.1   172.18.0.7    <none>        Ubuntu 21.04  5.4.72-microsoft-standard-WSL2   containerd://1.5.2
#>kind-worker          Ready    <none>                 3h35m   v1.21.1   172.18.0.4    <none>        Ubuntu 21.04  5.4.72-microsoft-standard-WSL2   containerd://1.5.2
#>kind-worker2         Ready    <none>                 3h35m   v1.21.1   172.18.0.3    <none>        Ubuntu 21.04  5.4.72-microsoft-standard-WSL2   containerd://1.5.2
#>kind-worker3         Ready    <none>                 3h35m   v1.21.1   172.18.0.6    <none>        Ubuntu 21.04  5.4.72-microsoft-standard-WSL2   containerd://1.5.2
#>kind-worker4         Ready    <none>                 3h35m   v1.21.1   172.18.0.5    <none>        Ubuntu 21.04  5.4.72-microsoft-standard-WSL2   containerd://1.5.2
#>kind-worker5         Ready    <none>                 3h35m   v1.21.1   172.18.0.2    <none>        Ubuntu 21.04  5.4.72-microsoft-standard-WSL2   containerd://1.5.2

在Kind环境中,即使使用与Kubernetes无关的资源,nodes的内存使用也会增加。似乎是获取实例所属硬件的实际情况。

image.png
广告
将在 10 秒后关闭
bannerAds