首页 > 其他分享 >K8S错误整理

K8S错误整理

时间:2023-09-28 12:35:08浏览次数:39  
标签:k8s name 错误 system server metrics io 整理 K8S


目录

1.calico-node报错Readiness probe failed: calico/node is not ready: BIRD is not ready

2.error: Metrics API not available

a.k8s版本:v1.24.4

b.k8s 1.20

3.Unable to update cni config: no networks found in /etc/cni/net.d



 

1.calico-node报错Readiness probe failed: calico/node is not ready: BIRD is not ready

kubectl -n calico-system edit daemonsets.apps calico-node

#需要添加annotations:
unsupported.operator.tigera.io/ignore: "true"

K8S错误整理_HTTPS

kubectl edit ds calico-node -n calico-system

- name: IP_AUTODETECTION_METHOD
              value: "interface=ens33"  # ens33 根据实际网卡开头配置

2.error: Metrics API not available

a.k8s版本:v1.24.4

kubectl top pod 报错:error: Metrics API not available

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

vim top.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 top.yaml

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

b.k8s 1.20

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:
  - pods
  - nodes
  - nodes/stats
  - namespaces
  - configmaps
  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
        - --kubelet-insecure-tls
        - --secure-port=4443
        - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
        - --kubelet-use-node-status-port
        #这里可以自己把metrics-server做到自己的阿里云镜像里面,并把下面替换成自己的镜像地址
        image: registry.cn-hangzhou.aliyuncs.com/lfy_k8s_images/metrics-server:v0.4.3
        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
          periodSeconds: 10
        securityContext:
          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

3.Unable to update cni config: no networks found in /etc/cni/net.d

 解决为kubeadm添加变量

vi /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf

Environment="KUBELET_NETWORK_ARGS=--network-plugin=cni --cni-conf-dir=/etc/cni/ --cni-bin-dir=/opt/cni/bin"

标签:k8s,name,错误,system,server,metrics,io,整理,K8S
From: https://blog.51cto.com/dxbp/7638045

相关文章

  • K8s Pod与宿主机时区不同步
    目录本机替换上海时间一、通过定制Dockerfile添加时区二、通过将时区文件挂在到Pod中三、通过环境变量定义时区四、修改k8s表空间时区本机替换上海时间sudotimedatectlset-timezoneAsia/Shanghai&&sudontpdatetime.windows.com一、通过定制Dockerfile添加时区$catDockerf......
  • C#正则表达式整理备忘
    有一段时间,正则表达式学习很火热很潮流,当时在CSDN一天就能看到好几个正则表达式的帖子,那段时间借助论坛以及WroxPress出版的《C#字符串和正则表达式参考手册》学习了一些基础的知识,同时也为我在CSDN大概赚了1000分,今天想起来,去找《C#字符串和正则表达式参考手册》时,已经不知所踪了......
  • .NET开发者常会忽略的几个错误
    在运用Visiolstudio.NET开发Web应用程式中,开发者常常会遇到一些问题:如我开发好的程式,在开发环境下测试没问题,怎么一搬到应用环境下,就会有问题?不是程式的无法运行,就是程式的效率慢的同蜗牛在爬,这种情况在.NET的新手中尤其常见。我不知道为什么,一些介绍.NET开发的书本里引用的......
  • thinkPHP框架在nginx环境中提示404错误的几种情况与解决方法
    一、未设置伪静态解决方法:在项目public目录下新建文件,命名为nginx.htaccess,文件内容如下:location/{indexindex.htmlindex.htmindex.php;autoindexoff;if(!-e$request_filename){rewrite^(.*)$/index.php?s=/$1last;break;......
  • 关于MMEngine随机性的一些整理
    1、随机性来自哪里?(1)torch算法的随机数种子实现defset_random_seed(seed:Optional[int]=None,deterministic:bool=False,diff_rank_seed:bool=False)->int:"""Setrandomseed.Args:seed(in......
  • ajax调用后台controller方法时报415 (Unsupported Media Type)错误
    spring mvc 下,ajax调用后台controller方法时报415(UnsupportedMediaType)错误错误:ajax的post方法调用后台controller方法时报错:415(UnsupportedMediaType)。下面是错误时的代码前端:varurl=“xxx/xxQuery.action”;var params={year:‘2017’}ajax(url,params,functio......
  • k8s 监控(二)监控集群组件和 pod
    原文链接:https://juejin.cn/post/6844903921207492621在上一篇文章中,我们已经在k8s中安装了Prometheus,并且收集了它自身的监控指标。而在这篇文章,我们将收集k8s所有组件和pod的监控指标。在这之前需要先修改下之前监控Prometheus自身使用的一个配置,因为它来源于promet......
  • k8s 监控(三)prometheus-adapter
    原文链接: https://juejin.cn/post/6844903967218991117kubernetesapiserver提供了两种api用于监控指标相关的操作:resourcemetricsAPI:被设计用来给k8s核心组件提供监控指标,例如kubectltop;custommetricsAPI:被设计用来给HPA控制器提供指标。kubernetesapiser......
  • k8s 监控(四)监控宿主机
    原文链接:https://juejin.cn/post/6844904057098731534k8s监控的第四篇文章,这篇文章讲的是监控宿主机的指标。官方和大部分使用者都会使用node_exporter完成此项工作,但是我更喜欢telegraf。原因在于node_exporter有以下几大痛点:指标太多,仅cpu而言,每个cpu核心都有6......
  • k8s ingress
    k8s环境搭建完毕后1.  kubectlapply-fhttps://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.2/deploy/static/provider/cloud/deploy.yaml  也可以copy这个文件下来,执行2.kubectlcreatedeploymentdemo--image=httpd--port=80kubect......