gpt4 book ai didi

kubernetes - 如何安装 kube-state-metrics

转载 作者:行者123 更新时间:2023-12-04 14:54:55 26 4
gpt4 key购买 nike

我想收集 K8s 中 POD 的指标。 kube-state-metrics看起来挺好的。我无法关注 README .我打后 make container .有什么简单的方法可以部署kube-state-metrics .

更新 1

kubectl apply -f kubernetes .获得以下错误。我认为,版本不匹配。知道如何克服吗?

serviceaccount "kube-state-metrics" configured
service "kube-state-metrics" configured
Error from server (BadRequest): error when creating "kubernetes/kube-state-metrics-cluster-role-binding.yaml": ClusterRoleBinding in version "v1" cannot be handled as a ClusterRoleBinding: no kind "ClusterRoleBinding" is registered for version "rbac.authorization.k8s.io/v1"
Error from server (BadRequest): error when creating "kubernetes/kube-state-metrics-cluster-role.yaml": ClusterRole in version "v1" cannot be handled as a ClusterRole: no kind "ClusterRole" is registered for version "rbac.authorization.k8s.io/v1"
Error from server (BadRequest): error when creating "kubernetes/kube-state-metrics-deployment.yaml": Deployment in version "v1beta2" cannot be handled as a Deployment: no kind "Deployment" is registered for version "apps/v1beta2"
Error from server (BadRequest): error when creating "kubernetes/kube-state-metrics-role-binding.yaml": RoleBinding in version "v1" cannot be handled as a RoleBinding: no kind "RoleBinding" is registered for version "rbac.authorization.k8s.io/v1"
Error from server (BadRequest): error when creating "kubernetes/kube-state-metrics-role.yaml": Role in version "v1" cannot be handled as a Role: no kind "Role" is registered for version "rbac.authorization.k8s.io/v1"

最佳答案

你很接近。

同页有Kubernetes Deployment部分。

https://github.com/kubernetes/kube-state-metrics#kubernetes-deployment

克隆 github 存储库后,您只需运行:
kubectl apply -f kubernetes
您可以在此处仔细查看部署文件:

https://github.com/kubernetes/kube-state-metrics/tree/master/kubernetes

- - 更新 - -

如果您运行的是旧版本的 K8s,它仍然使用部署版本 v1beta1 并且没有 RBAC,请尝试以下(yaml 文件)示例:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kube-state-metrics-deployment
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: kube-state-metrics
version: "v0.4.1"
spec:
containers:
- name: kube-state-metrics
image: gcr.io/google_containers/kube-state-metrics:v0.4.1
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
annotations:
prometheus.io/scrape: 'true'
name: kube-state-metrics
labels:
k8s-app: kube-state-metrics
spec:
ports:
- name: http-metrics
port: 8080
protocol: TCP
selector:
k8s-app: kube-state-metrics

关于kubernetes - 如何安装 kube-state-metrics,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46920972/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com