成都网站建设设计

将想法与焦点和您一起共享

metrics-server的示例分析

今天就跟大家聊聊有关metrics-server的示例分析,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

成都创新互联公司主要业务有网站营销策划、网站设计制作、成都网站制作、微信公众号开发、成都小程序开发H5页面制作、程序开发等业务。一次合作终身朋友,是我们奉行的宗旨;我们不仅仅把客户当客户,还把客户视为我们的合作伙伴,在开展业务的过程中,公司还积累了丰富的行业经验、成都全网营销推广资源和合作伙伴关系资源,并逐渐建立起规范的客户服务和保障体系。 

1 下载项目

git clone https://github.com/kubernetes-incubator/metrics-server.git

2 修改配置文件

cd /root/metrics-server/deploy/1.8+



[root@master 1.8+]# vim metrics-server-deployment.yaml 

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: metrics-server
  namespace: kube-system
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: metrics-server
  namespace: kube-system
  labels:
    k8s-app: metrics-server
spec:
  selector:
    matchLabels:
      k8s-app: metrics-server
  template:
    metadata:
      name: metrics-server
      labels:
        k8s-app: metrics-server
    spec:
      serviceAccountName: metrics-server
      volumes:
      # mount in tmp so we can safely use from-scratch images and/or read-only containers
      - name: tmp-dir
        emptyDir: {}
      containers:
      - name: metrics-server
        image: k8s.gcr.io/metrics-server-amd64:v0.3.1
        imagePullPolicy: Always
        command:
        - /metrics-server
        - --kubelet-insecure-tls
        - --kubelet-preferred-address-types=InternalIP
        volumeMounts:
        - name: tmp-dir
          mountPath: /tmp



增加配置
        command:
        - /metrics-server
        - --kubelet-insecure-tls
        - --kubelet-preferred-address-types=InternalIP

3 应用配置文件

 kubectl apply -f .

4 查看pod

# kubectl get pod -n kube-system
NAME                              READY   STATUS    RESTARTS   AGE
calico-node-j85f7                 2/2     Running   2          3h7m
calico-node-tbvs4                 2/2     Running   2          3h4m
calico-node-zwsts                 2/2     Running   2          3h5m
calico-typha-55968bfd7b-zv9vc     1/1     Running   1          3h7m
coreDNS-fb8b8dccf-227fk           1/1     Running   0          54m
coredns-fb8b8dccf-xwscm           1/1     Running   0          54m
etcd-master                       1/1     Running   1          3h21m
kube-apiserver-master             1/1     Running   1          3h21m
kube-controller-manager-master    1/1     Running   1          3h21m
kube-proxy-ltwbd                  1/1     Running   0          55m
kube-proxy-qgrvg                  1/1     Running   0          55m
kube-proxy-xnd45                  1/1     Running   0          55m
kube-scheduler-master             1/1     Running   1          3h21m
metrics-server-58db9f9647-sxtv9   1/1     Running   0          6m42s

5 使用

# kubectl top node
NAME     CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
master   189m         4%     911Mi           24%       
node1    98m          2%     432Mi           5%        
node2    117m         2%     442Mi           5%        
# kubectl top pods
NAME                       CPU(cores)   MEMORY(bytes)   
net-test-7d6d58cc8-8r28m   0m           1Mi             
net-test-7d6d58cc8-k5qdm   0m           1Mi             
# kubectl top pods -n kube-system
NAME                              CPU(cores)   MEMORY(bytes)   
calico-node-j85f7                 29m          59Mi            
calico-node-tbvs4                 25m          61Mi            
calico-node-zwsts                 27m          60Mi            
calico-typha-55968bfd7b-zv9vc     9m           29Mi            
coredns-fb8b8dccf-227fk           4m           13Mi            
coredns-fb8b8dccf-xwscm           4m           13Mi            
etcd-master                       25m          69Mi            
kube-apiserver-master             34m          270Mi           
kube-controller-manager-master    16m          57Mi            
kube-proxy-ltwbd                  1m           17Mi            
kube-proxy-qgrvg                  1m           17Mi            
kube-proxy-xnd45                  1m           18Mi            
kube-scheduler-master             2m           15Mi            
metrics-server-58db9f9647-sxtv9   2m           14Mi

查看Metrics API数据

启动一个代理以便curl api

kubectl proxy --port=8080

#直接查看接口数据:
#可获取的资源:nodes和pods
# curl localhost:8080/apis/metrics.k8s.io/v1beta1

 curl localhost:8080/apis/metrics.k8s.io/v1beta1/
{
  "kind": "APIResourceList",
  "apiVersion": "v1",
  "groupVersion": "metrics.k8s.io/v1beta1",
  "resources": [
    {
      "name": "nodes",
      "singularName": "",
      "namespaced": false,
      "kind": "NodeMetrics",
      "verbs": [
        "get",
        "list"
      ]
    },
    {
      "name": "pods",
      "singularName": "",
      "namespaced": true,
      "kind": "PodMetrics",
      "verbs": [
        "get",
        "list"
      ]
    }
  ]
}

看完上述内容,你们对metrics-server的示例分析有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注创新互联行业资讯频道,感谢大家的支持。


分享文章:metrics-server的示例分析
文章起源:http://chengdu.cdxwcx.cn/article/iechgo.html