k8s错误解决汇总.md 1.6 KB

问题1.unknown container "/system.slice/docker.service"

Append "--runtime-cgroups=/systemd/system.slice --kubelet-cgroups=/systemd/system.slice" to "KUBELET_CGROUP_ARGS" in /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
# systemctl daemon-reload
# systemctl restart kubelet

问题2.pod has unbound immediate PersistentVolumeClaims

PVC和PV的绑定是通过StorageClassName进行的。然而如果定义PVC时没有指定StorageClassName呢?这取决与admission插件是否开启了DefaultStorageClass功能: 如果DefaultStorageClass功能开启,那么此PVC的StorageClassName就会被指定为DefaultStorageClass。 DefaultStorageClass从何处而来呢?原来在定义StorageClass时,可以在Annotation中添加一个键值对:storageclass.kubernetes.io/is-default-class: true,那么此StorageClass就变成默认的StorageClass了。 如果DefaultStorageClass功能没有开启,那么没有指定StorageClassName的PVC只能被绑定到同样没有指定StorageClassName的PV。

创建pv的声明yaml中去掉StorageClassName
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pytorch-pv-1
spec:
  capacity:
    storage: 20Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
#  storageClassName: local-storage
  local:
    path: /data/local/pytorch1
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - master1