Kubernetes 1.13.2 部署metrics-server

暨成双
2023-12-01

查看Kubernetes版本

kubectl version
----------------------------------------------------------------------------
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.2", GitCommit:"cff46ab41ff0bb44d8584413b598ad8360ec1def", GitTreeState:"clean", BuildDate:"2019-01-10T23:35:51Z", GoVersion:"go1.11.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.2", GitCommit:"cff46ab41ff0bb44d8584413b598ad8360ec1def", GitTreeState:"clean", BuildDate:"2019-01-10T23:28:14Z", GoVersion:"go1.11.4", Compiler:"gc", Platform:"linux/amd64"}

注意:

For Calico to work correctly, you need to pass --pod-network-cidr=192.168.0.0/16 to kubeadm init or update the calico.yml file to match your Pod network. Note that Calico works on amd64 only.

1,下载github代码

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

2,修改metrics-server-deployment.yaml

开始修改

vi metrics-server/deploy/1.8+/metrics-server-deployment.yaml

在containers下追加如下代码,

args:
        - --kubelet-insecure-tls
        - --kubelet-preferred-address-types=InternalIP

修改后的完整代码,

---
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
        volumeMounts:
        - name: tmp-dir
          mountPath: /tmp
        args:
        - --kubelet-insecure-tls
        - --kubelet-preferred-address-types=InternalIP

3,apply yaml文件

kubectl apply -f metrics-server/deploy/1.8+/

4,查看结果

kubectl top nodes
----------------------------------------------------------
NAME         CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
k8s-master   486m         24%    1853Mi          51%       
k8s-node     146m         7%     1855Mi          51%       
kubectl top pods --all-namespaces
-----------------------------------------------------------------------------------
NAMESPACE     NAME                                       CPU(cores)   MEMORY(bytes)   
default       nginx-77c5cd5446-k2l45                     0m           2Mi             
kube-system   calico-etcd-k5bkd                          10m          12Mi            
kube-system   calico-kube-controllers-6c6566b687-qmw4x   6m           15Mi            
kube-system   calico-node-7brzm                          39m          30Mi            
kube-system   calico-node-8gzhp                          41m          33Mi            
kube-system   coredns-86c58d9df4-4cgzk                   6m           11Mi            
kube-system   coredns-86c58d9df4-jpwjw                   7m           11Mi            
kube-system   etcd-k8s-master                            32m          70Mi            
kube-system   kube-apiserver-k8s-master                  73m          412Mi           
kube-system   kube-controller-manager-k8s-master         62m          78Mi            
kube-system   kube-proxy-kt28z                           7m           15Mi            
kube-system   kube-proxy-zfmqb                           7m           12Mi            
kube-system   kube-scheduler-k8s-master                  27m          16Mi            
kube-system   metrics-server-76db6db868-f827l            2m           14Mi 

 

 类似资料: