首页 > 其他分享 >k8s版本v1.24,kubectl top pod 报错:error: Metrics API not available

k8s版本v1.24,kubectl top pod 报错:error: Metrics API not available

时间:2023-09-28 13:38:26浏览次数:86  
标签:available kubectl name system server metrics 报错 io k8s


k8s版本:v1.24.4
kubectl top pod 报错:error: Metrics API not available

报错 Readiness probe failed: HTTP probe failed with statuscode: 500

vim custom-resources.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    k8s-app: metrics-server
    rbac.authorization.k8s.io/aggregate-to-admin: "true"
    rbac.authorization.k8s.io/aggregate-to-edit: "true"
    rbac.authorization.k8s.io/aggregate-to-view: "true"
  name: system:aggregated-metrics-reader
rules:
- apiGroups:
  - metrics.k8s.io
  resources:
  - pods
  - nodes
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    k8s-app: metrics-server
  name: system:metrics-server
rules:
- apiGroups:
  - ""
  resources:
  - nodes/metrics
  verbs:
  - get
- apiGroups:
  - ""
  resources:
  - pods
  - nodes
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server-auth-reader
  namespace: kube-system
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: extension-apiserver-authentication-reader
subjects:
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server:system:auth-delegator
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: system:auth-delegator
subjects:
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    k8s-app: metrics-server
  name: system:metrics-server
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: system:metrics-server
subjects:
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: v1
kind: Service
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
spec:
  ports:
  - name: https
    port: 443
    protocol: TCP
    targetPort: https
  selector:
    k8s-app: metrics-server
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
spec:
  selector:
    matchLabels:
      k8s-app: metrics-server
  strategy:
    rollingUpdate:
      maxUnavailable: 0
  template:
    metadata:
      labels:
        k8s-app: metrics-server
    spec:
      containers:
      - args:
        - --cert-dir=/tmp
        - --secure-port=4443
        - --kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP
        - --kubelet-use-node-status-port
        - --metric-resolution=15s
        - --kubelet-insecure-tls
        image: registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server:v0.6.1
          #image: k8s.gcr.io/metrics-server/metrics-server:v0.6.1
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /livez
            port: https
            scheme: HTTPS
          periodSeconds: 10
        name: metrics-server
        ports:
        - containerPort: 4443
          name: https
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /readyz
            port: https
            scheme: HTTPS
          initialDelaySeconds: 20
          periodSeconds: 10
        resources:
          requests:
            cpu: 100m
            memory: 200Mi
        securityContext:
          allowPrivilegeEscalation: false
          readOnlyRootFilesystem: true
          runAsNonRoot: true
          runAsUser: 1000
        volumeMounts:
        - mountPath: /tmp
          name: tmp-dir
      nodeSelector:
        kubernetes.io/os: linux
      priorityClassName: system-cluster-critical
      serviceAccountName: metrics-server
      volumes:
      - emptyDir: {}
        name: tmp-dir
---
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
  labels:
    k8s-app: metrics-server
  name: v1beta1.metrics.k8s.io
spec:
  group: metrics.k8s.io
  groupPriorityMinimum: 100
  insecureSkipTLSVerify: true
  service:
    name: metrics-server
    namespace: kube-system
  version: v1beta1
  versionPriority: 100

#执行
kubectl apply -f custom-resources.yaml

#查看pod
kubectl get pod -A |grep me


标签:available,kubectl,name,system,server,metrics,报错,io,k8s
From: https://blog.51cto.com/dxbp/7638080

相关文章

  • weblogic乱码报错解决思路
    目录1.集群备份weblogic虚拟机快照备份2.查看主节点控制台面板状态3.尝试启动程序失败4.查看162.主节点日志5.发现程序中乱码6.修改乱码名称7.尝试启动,新的报错还是显示乱码8.修改乱码9.点击更新程序,继续报错9.1依然是乱码10.更新,程序部署路径,换新程序,11.删除程序,处理程序中的乱码......
  • Hydration completed but contains mismatches 报错,如何解决?
    最近在用vue3+node+TS+vite在搭建SSR服务器端渲染项目时候,遇到问题Hydrationcompletedbutcontainsmismatches?字面意思就是客户端激活已完成,但是存在不匹配;若是第一次遇到这个问题,貌似还不是很懂?所谓客户端激活指的是Vue在浏览器端接管由服务器发送的静态HTML,将其变......
  • git 报错Access denied
    remote:[session-614483a1]Accessdeniedfatal:unabletoaccess'https://gitee.com/**/':TherequestedURLreturnederror:403  解决办法: gitconfiguser.name"newname"gitconfigcredential.username"newname"或者删除本地钥匙串......
  • java.lang.IllegalStateException: javax.websocket.server.ServerContainer not avai
    spring项目能正常运行,但是单元测试报错错误原因注册WebSocket的Bean与springboot内带tomcat冲突解决办法1.注释该类里面的代码(不推荐)2.@springBootTest注解添加webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT@SpringBootTest注解中,给出了webEnvironment参......
  • SpringBoot启动报错
    问题描述按照以往的代码进行SpringBoot的相应部署,但是爆出来这个错误:问题解决里面说找不到我定义的bean实体类,那就加上这么一条注解,让他能够找到实体类:然后启动:并在浏览器里面查看一下:ok!问题解决!......
  • mojo编程语言:编译后的mojo二进制执行文件调用python库报错——设置MOJO_PYTHON_LIBRAR
    代码:frompythonimportPythonfnf()raises:#ThisisequivalenttoPython's`importnumpyasnp`letnp=Python.import_module("numpy")leta=np.array([1,2,3])print(a)fnmain()raises:f() mojo编译后执行,报错:Moj......
  • Webpack报错Error: error:0308010C:digital envelope routines::unsupported处理
    在学习组件库流程打包的时候报错找不到module,后来改了版本又报错Error:error:0308010C:digitalenveloperoutines::unsupported报错原因:node17+版本对发布的OpenSSL3.0,而OpenSSL3.0对允许算法和密钥大小增加了严格的限制,可能会对生态系统造成一些影响.解决方案:在网上搜索......
  • 编程语言mojo报错:error: cannot call function that may raise in a context that can
    代码:frompythonimportPythonfnmain():#fnmain()raises:#ThisisequivalenttoPython's`importnumpyasnp`letnp=Python.import_module("numpy")leta=np.array([1,2,3])print(a) 运行报错:[02:19:48](mojo)dev......
  • 导入mysql文件报错
    mysql报错:「ERR」1273-Unknowncollation:'utf8mb4_0900_ai_ci'专注数据库知识分享2022-09-2719:05甘肃#MySQL专栏#mysql导入sql文件报错:[ERR]1273-Unknowncollation:'utf8mb4_0900_ai_ci'大致原因:sql对应的mysql版本高于当前要导入的mysql库的版本,引发......
  • java程序,如何打印详细报错堆栈信息
    try{System.out.println(1/0);}catch(finalExceptione){log.error("ERROR","Errorfound:",e);log.error("ERROR","Errorfound:"+e.getMessage());log.error("ERROR","Errorfo......