kube-state-metrics

#clone kube-state-metrics
[root@k8s-master ~]# git clone https://github.com/kubernetes/kube-state-metrics.git Cloning into 'kube-state-metrics'... remote: Enumerating objects: 1, done. remote: Counting objects: 100% (1/1), done. remote: Total 18700 (delta 0), reused 0 (delta 0), pack-reused 18699 Receiving objects: 100% (18700/18700), 15.96 MiB | 3.60 MiB/s, done. Resolving deltas: 100% (11775/11775), done.

#apply config
[root@k8s-master kube-state-metrics]# kubectl apply -f examples/standard clusterrolebinding.rbac.authorization.k8s.io/kube-state-metrics created clusterrole.rbac.authorization.k8s.io/kube-state-metrics created deployment.apps/kube-state-metrics created serviceaccount/kube-state-metrics created service/kube-state-metrics created [root@k8s-master kube-state-metrics]#

#create user
[root@k8s-master kube-state-metrics]# kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --user=root clusterrolebinding.rbac.authorization.k8s.io/cluster-admin-binding created

#check resources
[root@k8s-master kube-state-metrics]# kubectl get pods -o wide -A NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES default gnotiboot-6b856c4f44-4dt9x 1/1 Running 0 26d 10.244.1.41 k8s-node1 <none> <none> default gnotiboot-6b856c4f44-6drf2 1/1 Running 0 26d 10.244.1.45 k8s-node1 <none> <none> default gnotiboot-6b856c4f44-hlbt8 1/1 Running 0 26d 10.244.1.42 k8s-node1 <none> <none> default gnotiboot-6b856c4f44-nh4l7 1/1 Running 0 26d 10.244.1.44 k8s-node1 <none> <none> default gnotiboot-6b856c4f44-z76xd 1/1 Running 0 26d 10.244.1.43 k8s-node1 <none> <none> default gtomcat 1/1 Running 0 42d 10.244.1.13 k8s-node1 <none> <none> default nginx-f89759699-5vtq5 1/1 Running 0 44d 10.244.1.4 k8s-node1 <none> <none> default php-apache-5c4f475bf5-6ch8v 1/1 Running 0 28d 10.244.1.26 k8s-node1 <none> <none> kube-system coredns-66bff467f8-glbj5 1/1 Running 0 44d 10.244.0.3 k8s-master <none> <none> kube-system coredns-66bff467f8-s9zp2 1/1 Running 0 44d 10.244.0.2 k8s-master <none> <none> kube-system etcd-k8s-master 1/1 Running 4 44d 192.168.0.162 k8s-master <none> <none> kube-system kube-apiserver-k8s-master 1/1 Running 0 44d 192.168.0.162 k8s-master <none> <none> kube-system kube-controller-manager-k8s-master 1/1 Running 4 44d 192.168.0.162 k8s-master <none> <none> kube-system kube-proxy-s7kws 1/1 Running 0 44d 192.168.0.139 k8s-node1 <none> <none> kube-system kube-proxy-wd7dj 1/1 Running 0 44d 192.168.0.162 k8s-master <none> <none> kube-system kube-scheduler-k8s-master 1/1 Running 4 44d 192.168.0.162 k8s-master <none> <none> kube-system kube-state-metrics-6dc5b5b496-4znd5 0/1 Pending 0 4m18s <none> <none> <none> <none> kube-system metricbeat-759cc94485-4p2zs 0/1 Evicted 0 28d <none> k8s-node1 <none> <none> kube-system metricbeat-759cc94485-dn4fc 1/1 Running 1 6d23h 192.168.0.139 k8s-node1 <none> <none> kube-system metricbeat-759cc94485-fbzzl 0/1 Evicted 0 6d23h <none> k8s-node1 <none> <none> kube-system metricbeat-759cc94485-g6665 0/1 Evicted 0 6d23h <none> k8s-node1 <none> <none> kube-system metricbeat-759cc94485-h56hk 0/1 Evicted 0 6d23h <none> k8s-node1 <none> <none> kube-system metricbeat-759cc94485-n9cvz 0/1 Evicted 0 6d23h <none> k8s-node1 <none> <none> kube-system metricbeat-759cc94485-twg57 0/1 Evicted 0 6d23h <none> k8s-node1 <none> <none> kube-system metricbeat-8wdvl 1/1 Running 2 28d 192.168.0.139 k8s-node1 <none> <none> kube-system metrics-server-67c75d59f8-7dsrv 1/1 Running 1 28d 192.168.0.139 k8s-node1 <none> <none> kube-system tiller-deploy-66fccb9847-zrcd9 0/1 Pending 0 4h3m <none> <none> <none> <none> [root@k8s-master kube-state-metrics]#

#check resources
[root@k8s-master kube-state-metrics]# kubectl get svc -A NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE default gnoti-service LoadBalancer 10.98.79.19 192.168.0.162 8088:31555/TCP 26d default gnotiboot-docker-deployment ClusterIP 10.98.217.154 <none> 8088/TCP 27d default kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 44d default nginx NodePort 10.103.162.78 <none> 80:32412/TCP 44d default php-apache ClusterIP 10.96.104.103 <none> 80/TCP 28d kube-system kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 44d kube-system kube-state-metrics ClusterIP None <none> 8080/TCP,8081/TCP 5m58s kube-system metrics-server ClusterIP 10.106.5.120 <none> 443/TCP 28d kube-system tiller-deploy ClusterIP 10.110.198.187 <none> 44134/TCP 4h5m [root@k8s-master kube-state-metrics]#

#patch external ip
[root@k8s-master kube-state-metrics]# kubectl get pods -o wide -A NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES default gnotiboot-6b856c4f44-4dt9x 1/1 Running 0 26d 10.244.1.41 k8s-node1 <none> <none> default gnotiboot-6b856c4f44-6drf2 1/1 Running 0 26d 10.244.1.45 k8s-node1 <none> <none> default gnotiboot-6b856c4f44-hlbt8 1/1 Running 0 26d 10.244.1.42 k8s-node1 <none> <none> default gnotiboot-6b856c4f44-nh4l7 1/1 Running 0 26d 10.244.1.44 k8s-node1 <none> <none> default gnotiboot-6b856c4f44-z76xd 1/1 Running 0 26d 10.244.1.43 k8s-node1 <none> <none> default gtomcat 1/1 Running 0 42d 10.244.1.13 k8s-node1 <none> <none> default nginx-f89759699-5vtq5 1/1 Running 0 44d 10.244.1.4 k8s-node1 <none> <none> default php-apache-5c4f475bf5-6ch8v 1/1 Running 0 28d 10.244.1.26 k8s-node1 <none> <none> kube-system coredns-66bff467f8-glbj5 1/1 Running 0 44d 10.244.0.3 k8s-master <none> <none> kube-system coredns-66bff467f8-s9zp2 1/1 Running 0 44d 10.244.0.2 k8s-master <none> <none> kube-system etcd-k8s-master 1/1 Running 4 44d 192.168.0.162 k8s-master <none> <none> kube-system kube-apiserver-k8s-master 1/1 Running 0 44d 192.168.0.162 k8s-master <none> <none> kube-system kube-controller-manager-k8s-master 1/1 Running 4 44d 192.168.0.162 k8s-master <none> <none> kube-system kube-proxy-s7kws 1/1 Running 0 44d 192.168.0.139 k8s-node1 <none> <none> kube-system kube-proxy-wd7dj 1/1 Running 0 44d 192.168.0.162 k8s-master <none> <none> kube-system kube-scheduler-k8s-master 1/1 Running 4 44d 192.168.0.162 k8s-master <none> <none> kube-system kube-state-metrics-6dc5b5b496-4znd5 0/1 Pending 0 10m <none> <none> <none> <none> kube-system metricbeat-759cc94485-4p2zs 0/1 Evicted 0 28d <none> k8s-node1 <none> <none> kube-system metricbeat-759cc94485-dn4fc 1/1 Running 1 6d23h 192.168.0.139 k8s-node1 <none> <none> kube-system metricbeat-759cc94485-fbzzl 0/1 Evicted 0 6d23h <none> k8s-node1 <none> <none> kube-system metricbeat-759cc94485-g6665 0/1 Evicted 0 6d23h <none> k8s-node1 <none> <none> kube-system metricbeat-759cc94485-h56hk 0/1 Evicted 0 6d23h <none> k8s-node1 <none> <none> kube-system metricbeat-759cc94485-n9cvz 0/1 Evicted 0 6d23h <none> k8s-node1 <none> <none> kube-system metricbeat-759cc94485-twg57 0/1 Evicted 0 6d23h <none> k8s-node1 <none> <none> kube-system metricbeat-8wdvl 1/1 Running 2 28d 192.168.0.139 k8s-node1 <none> <none> kube-system metrics-server-67c75d59f8-7dsrv 1/1 Running 1 28d 192.168.0.139 k8s-node1 <none> <none> kube-system tiller-deploy-66fccb9847-zrcd9 0/1 Pending 0 4h9m <none> <none> <none> <none>
[root@k8s-master kube-state-metrics]# kubectl patch svc kube-state-metrics --namespace=kube-system -p '{"spec": {"type": "ClusterIP", "externalIPs":["192.168.0.162"]}}' service/kube-state-metrics patched
[root@k8s-master kube-state-metrics]# kubectl get svc -A NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE default gnoti-service LoadBalancer 10.98.79.19 192.168.0.162 8088:31555/TCP 26d default gnotiboot-docker-deployment ClusterIP 10.98.217.154 <none> 8088/TCP 27d default kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 44d default nginx NodePort 10.103.162.78 <none> 80:32412/TCP 44d default php-apache ClusterIP 10.96.104.103 <none> 80/TCP 28d kube-system kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 44d kube-system kube-state-metrics ClusterIP None 192.168.0.162 8080/TCP,8081/TCP 12m kube-system metrics-server ClusterIP 10.106.5.120 <none> 443/TCP 28d kube-system tiller-deploy ClusterIP 10.110.198.187 <none> 44134/TCP 4h11m
#set metricbeat.yml
root@nks-pool-159-w-3x0:~# cat /etc/metricbeat/modules.d/kubernetes.yml # Module: kubernetes # Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.7/metricbeat-module-kubernetes.html # Node metrics, from kubelet: #- module: kubernetes # metricsets: # - node # - system # - pod # - container # - volume # period: 10s # hosts: ["localhost:10250"] # ssl.verification_mode: "none" #bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token #ssl.verification_mode: "none" #ssl.certificate_authorities: # - /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt #username: "user" #password: "secret" # Enriching parameters: # add_metadata: true #labels.dedot: true #annotations.dedot: true # When used outside the cluster: #host: node_name # If kube_config is not set, KUBECONFIG environment variable will be checked # and if not present it will fall back to InCluster #kube_config: ~/.kube/config # State metrics from kube-state-metrics service: - module: kubernetes metricsets: - state_node - state_deployment - state_replicaset - state_statefulset - state_pod - state_container - state_cronjob - state_resourcequota - state_service - state_persistentvolume - state_persistentvolumeclaim - state_storageclass period: 5s hosts: ["198.18.0.26:8080/metrics"] add_metadata: true # Kubernetes events #- module: kubernetes # metricsets: # - event



댓글

이 블로그의 인기 게시물

[!] CDN: trunk URL couldn't be downloaded: https://cdn.cocoapods.org/CocoaPods-version.yml Response: URL using bad/illegal format or missing URL

starcraft map

Data Analysis with Superset - boardless chart