Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install kube-state-metrics

I want to collect metrics for PODs in K8s. kube-state-metrics looks good. I was not able to follow the README. I struck after make container. Is there any simple way to deploy the kube-state-metrics.

UPDATE1

Ran kubectl apply -f kubernetes. Getting below errors. I thinks, version mismatch. Any idea how to overcome?

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"
like image 312
Veerendra Avatar asked Oct 24 '17 22:10

Veerendra


1 Answers

You're close.

Same page has a Kubernetes Deployment section.

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

Once you clone the github repository you simple run:

kubectl apply -f kubernetes

You can take a closer look at the deployment files here:

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

--- UPDATE ---

If you're running an older version of K8s, which still uses Deployment version v1beta1 and no RBAC try the following (yaml file) example:

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
like image 159
Christian Will Avatar answered Nov 08 '22 07:11

Christian Will