当前位置:   article > 正文

k8s问题记录与解决_unable to read config from "kubeadm.yaml" : open k

unable to read config from "kubeadm.yaml" : open kubeadm.yaml: no such file

一、问题:error: open /var/lib/kubelet/config.yaml: no such file or directory
  解决:关键文件缺失,多发生于没有做 kubeadm init就运行了systemctl start kubelet。 要先成功运行kubeadm init

二、kubelet.service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.
  解决:打开/etc/systemd/system/kubelet.service.d/10-kubeadm.conf 中的配置:
    [root@k8s-master ~]# cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
    # Note: This dropin only works with kubeadm and kubelet v1.11+
    [Service]
    Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
    Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
    # This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
    EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
    # This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
    # the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
    EnvironmentFile=-/etc/sysconfig/kubelet
    要打开注释此# ExecStart=
    ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS

三、journalctl -f -u kubelet (-f是 --follow, -u是过滤出kubelet日志)
    centos7 查看日志

四、kubeadm安装的k8s,重新安装k8s-mst
    检查 /etc/systemd/system/kubelet.service.d/10-kubeadm.conf 中的配置
    systemctl restart kubelet
    kubeadm reset
    kubeadm init --kubernetes-version=v1.13.4 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=Swap
    其他节点执行
    kubeadm reset
    kubeadm join ...命令

五、kubeadm 生成的token过期后,集群增加节点
    参考:https://www.jianshu.com/p/a5e379638577

六、[reset] unmounting mounted directories in "/var/lib/kubelet" 卡主
    重启机器,重新执行命令

-------------------20190518 update-------------------

七、master所在虚机重启后,kube-master1 kubelet[34770]: E0419 13:52:09.511348   34770 kubelet.go:2266] node "kube-master1" not found,并发现获取到的ip地址为空,ifconfig命令去查看网卡配置情况,却发现根本没有配置eth0/ens33网卡

解决:依次systemctl stop kubelet、systemctl stop docker、systemctl restart network、systemctl restart docker、systemctl restart kubelet、ifconfig、kubectl get node

-------------------20190614 update-------------------

八、kubelet, k8s-node1  Failed create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "1b7fb9d83e89dbe2815cc10fb1daf342162cb74da30568c0a59585e1dc9329a4" network for pod "wxapp-redis-1": NetworkPlugin cni failed to set up pod "wxapp-redis-1_pnup" network: failed to set bridge addr: "cni0" already has an IP address different from 10.244.1.1/24

解决:到有问题的机器,执行如下命令:

[root@k8s-node1 redis]# cd /var/lib/cni/flannel/
[root@k8s-node1 flannel]# ll
total 32
-rw-------. 1 root root 206 Apr 19 11:30 0727fe1a742f28b9a5d5d3188496bdc0aec220599caf6ce8c28f1b9c8ef1b8d4
-rw-------. 1 root root 206 Apr 19 14:30 13776cebe870d3f58982a123e2e32a4a89780c421db1bc425f13f13756822f81
-rw-------. 1 root root 206 Apr 19 11:30 1f249dd31dae8177a4fa5d3009eec7a36a4dccd8a836975f1d798adf43afda51
-rw-------. 1 root root 206 Apr 19 14:34 317e1ce2f78fddd1b36879be5dff169d27fefd4ca191dcd9d85781ab65cc14d8
-rw-------. 1 root root 187 Jun 14 10:05 5b104d16ea2042bd67f8958b8042fff01de3ba6a69f1a62f4b3ded81955c24bb
-rw-------. 1 root root 206 Apr 23 15:30 5bfe39c5fb73ecb09b7343260b8fc2526bb99b7d00a216ab0c76d87d247f3bc0
-rw-------. 1 root root 187 Jun 14 10:05 85de9489e5a4b5091bc40b5dc216a9f15fdb9aa077a28df32cfef97f8abd0c81
-rw-------. 1 root root 206 Apr 19 11:30 db015f887bbedf2ad7731aaa4a321183594a1d2c9b95398bb25f61ad5b052092
[root@k8s-node1 flannel]# systemctl stop docker
[root@k8s-node1 flannel]# systemctl stop kubelet
[root@k8s-node1 flannel]# systemctl stop kube-proxy

Failed to stop kube-proxy.service: Unit kube-proxy.service not loaded.
[root@k8s-node1 flannel]# rm -rf /var/lib/cni/flannel/ && rm -rf /var/lib/cni/networks/cbr0/ && ip link delete cni0
[root@k8s-node1 flannel]# rm -rf /var/lib/cni/networks/cni0/*
[root@k8s-node1 flannel]# systemctl start docker
[root@k8s-node1 flannel]# systemctl start kubelet

-------------------20190622 update-------------------

九、转(kubernetes --> kube-dns 安装 https://blog.csdn.net/zhuchuangang/article/details/76093887 https://www.cnblogs.com/chimeiwangliang/p/8809280.html

十、转(kubernetes中网络报错问题排查 http://www.mamicode.com/info-detail-2315259.html

-------------------20200523 update-------------------

十一、May 23 06:21:59 master dockerd-current[14690]: time="2020-05-23T06:21:59.555312805-04:00" level=error msg="Create container failed with error: oci runtime error: container_linux.go:235: starting container process caused \"process_linux.go:258: applying cgroup configuration for process caused \\\"Cannot set property TasksAccounting, or unknown property.\\\"\"\n"
May 23 06:21:59 master kubelet[21888]: E0523 06:21:59.654065   21888 kubelet.go:2266] node "master" not found

May 23 06:21:59 master kubelet[21888]: E0523 06:21:59.754397   21888 kubelet.go:2266] node "master" not found
May 23 06:21:59 master kubelet[21888]: E0523 06:21:59.855185   21888 kubelet.go:2266] node "master" not found
Docker创建容器报错:Cannot set property TasksAccounting, or unknown property.
最近又新配了一个服务器,想用docker简单的配置一下mysql,没想到创建容器时报错:
Error response from daemon: oci runtime error: container_linux.go:235: starting container process caused “process_linux.go:258: applying cgroup configuration for process caused “Cannot set property TasksAccounting, or unknown property.””
问题原因:主要原因还是centos系统版本兼容性问题,如果将系统做更新升级,即可解决。
执行:yum update后在执行以下操作:

  1. [root@web03 .kube]# yum remove -y kubectl.x86_64 kubeadm.x86_64 kubelet.x86_64
  2. Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
  3. ...
  4. Complete!
  5. [root@web03 .kube]# yum list installed |grep kube
  6. cri-tools.x86_64 1.13.0-0 @kubernetes
  7. kubectl.x86_64 1.13.4-0 @kubernetes
  8. [root@web03 .kube]# yum install -y kubelet-1.13.4-0.x86_64
  9. Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
  10. ...
  11. Complete!
  12. [root@web03 .kube]# yum install -y kubeadm-1.13.4-0.x86_64
  13. Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
  14. ...
  15. Complete!
  16. [root@web03 .kube]# yum list installed |grep kube
  17. cri-tools.x86_64 1.13.0-0 @kubernetes
  18. kubeadm.x86_64 1.13.4-0 @kubernetes
  19. kubectl.x86_64 1.13.4-0 @kubernetes
  20. kubelet.x86_64 1.13.4-0 @kubernetes
  21. kubernetes-cni.x86_64 0.6.0-0 @kubernetes

十二、k8s使用kube-router网络插件并监控流量状态
https://www.jianshu.com/p/1a3caecc3b6b

附:kubeadm-kuberouter-all-features.yaml

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: kube-router-cfg
  5. namespace: kube-system
  6. labels:
  7. tier: node
  8. k8s-app: kube-router
  9. data:
  10. cni-conf.json: |
  11. {
  12. "cniVersion":"0.3.0",
  13. "name":"mynet",
  14. "plugins":[
  15. {
  16. "name":"kubernetes",
  17. "type":"bridge",
  18. "bridge":"kube-bridge",
  19. "isDefaultGateway":true,
  20. "ipam":{
  21. "type":"host-local"
  22. }
  23. }
  24. ]
  25. }
  26. ---
  27. apiVersion: extensions/v1beta1
  28. kind: DaemonSet
  29. metadata:
  30. labels:
  31. k8s-app: kube-router
  32. tier: node
  33. name: kube-router
  34. namespace: kube-system
  35. spec:
  36. template:
  37. metadata:
  38. labels:
  39. k8s-app: kube-router
  40. tier: node
  41. annotations:
  42. scheduler.alpha.kubernetes.io/critical-pod: ''
  43. spec:
  44. serviceAccountName: kube-router
  45. serviceAccount: kube-router
  46. containers:
  47. - name: kube-router
  48. image: docker.io/cloudnativelabs/kube-router
  49. imagePullPolicy: IfNotPresent
  50. args:
  51. - --run-router=true
  52. - --run-firewall=true
  53. - --run-service-proxy=true
  54. - --kubeconfig=/var/lib/kube-router/kubeconfig
  55. env:
  56. - name: NODE_NAME
  57. valueFrom:
  58. fieldRef:
  59. fieldPath: spec.nodeName
  60. - name: KUBE_ROUTER_CNI_CONF_FILE
  61. value: /etc/cni/net.d/10-kuberouter.conflist
  62. livenessProbe:
  63. httpGet:
  64. path: /healthz
  65. port: 20244
  66. initialDelaySeconds: 10
  67. periodSeconds: 3
  68. resources:
  69. requests:
  70. cpu: 250m
  71. memory: 250Mi
  72. securityContext:
  73. privileged: true
  74. volumeMounts:
  75. - name: lib-modules
  76. mountPath: /lib/modules
  77. readOnly: true
  78. - name: cni-conf-dir
  79. mountPath: /etc/cni/net.d
  80. - name: kubeconfig
  81. mountPath: /var/lib/kube-router
  82. readOnly: true
  83. initContainers:
  84. - name: install-cni
  85. image: busybox
  86. imagePullPolicy: Always
  87. command:
  88. - /bin/sh
  89. - -c
  90. - set -e -x;
  91. if [ ! -f /etc/cni/net.d/10-kuberouter.conflist ]; then
  92. if [ -f /etc/cni/net.d/*.conf ]; then
  93. rm -f /etc/cni/net.d/*.conf;
  94. fi;
  95. TMP=/etc/cni/net.d/.tmp-kuberouter-cfg;
  96. cp /etc/kube-router/cni-conf.json ${TMP};
  97. mv ${TMP} /etc/cni/net.d/10-kuberouter.conflist;
  98. fi
  99. volumeMounts:
  100. - name: cni-conf-dir
  101. mountPath: /etc/cni/net.d
  102. - name: kube-router-cfg
  103. mountPath: /etc/kube-router
  104. hostNetwork: true
  105. tolerations:
  106. - key: CriticalAddonsOnly
  107. operator: Exists
  108. - effect: NoSchedule
  109. key: node-role.kubernetes.io/master
  110. operator: Exists
  111. - effect: NoSchedule
  112. key: node.kubernetes.io/not-ready
  113. operator: Exists
  114. volumes:
  115. - name: lib-modules
  116. hostPath:
  117. path: /lib/modules
  118. - name: cni-conf-dir
  119. hostPath:
  120. path: /etc/cni/net.d
  121. - name: kube-router-cfg
  122. configMap:
  123. name: kube-router-cfg
  124. - name: kubeconfig
  125. configMap:
  126. name: kube-proxy
  127. items:
  128. - key: kubeconfig.conf
  129. path: kubeconfig
  130. ---
  131. apiVersion: v1
  132. kind: ServiceAccount
  133. metadata:
  134. name: kube-router
  135. namespace: kube-system
  136. ---
  137. kind: ClusterRole
  138. apiVersion: rbac.authorization.k8s.io/v1beta1
  139. metadata:
  140. name: kube-router
  141. namespace: kube-system
  142. rules:
  143. - apiGroups:
  144. - ""
  145. resources:
  146. - namespaces
  147. - pods
  148. - services
  149. - nodes
  150. - endpoints
  151. verbs:
  152. - list
  153. - get
  154. - watch
  155. - apiGroups:
  156. - "networking.k8s.io"
  157. resources:
  158. - networkpolicies
  159. verbs:
  160. - list
  161. - get
  162. - watch
  163. - apiGroups:
  164. - extensions
  165. resources:
  166. - networkpolicies
  167. verbs:
  168. - get
  169. - list
  170. - watch
  171. ---
  172. kind: ClusterRoleBinding
  173. apiVersion: rbac.authorization.k8s.io/v1beta1
  174. metadata:
  175. name: kube-router
  176. roleRef:
  177. apiGroup: rbac.authorization.k8s.io
  178. kind: ClusterRole
  179. name: kube-router
  180. subjects:
  181. - kind: ServiceAccount
  182. name: kube-router
  183. namespace: kube-system

十三、k8s小知识点:如何安装指定版本的kubeadm
https://www.jianshu.com/p/4b22b5d2f69b

-------------------20200523 update-------------------

文献:

    1.kubernetes---CentOS7安装kubernetes1.11.2图文完整版

    2.安装k8s 1.9.0 实践:问题集锦

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/565711
推荐阅读
相关标签
  

闽ICP备14008679号