Kubernetes pod 卡在待处理状态并且没有事件

Joh*_*ohn 5 amazon-web-services kubernetes amazon-eks

没有部署任何其他 pod。我有 2 个节点,但 Pod 为零。它是一个t3.small实例类型。

是否还有其他命令可以调试并查看为什么它仍然停留在挂起状态?

kubectl get pods
NAME                     READY   STATUS    RESTARTS   AGE
mysql-6cc489dcd5-5jc8t   0/1     Pending   0          91s


kubectl describe pod mysql-6cc489dcd5-5jc8t
Name:           mysql-6cc489dcd5-5jc8t
Namespace:      default
Priority:       0
Node:           <none>
Labels:         app=mysql
                pod-template-hash=6cc489dcd5
Annotations:    kubernetes.io/psp: eks.privileged
Status:         Pending
IP:
IPs:            <none>
Controlled By:  ReplicaSet/mysql-6cc489dcd5
Containers:
  mysql:
    Image:      mysql:5.6
    Port:       3306/TCP
    Host Port:  0/TCP
    Environment:
      MYSQL_ROOT_PASSWORD:  dbpassword11
    Mounts:
      /docker-entrypoint-initdb.d from usermanagement-dbcreation-script (rw)
      /var/lib/mysql from mysql-persistent-storage (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-nlx4p (ro)
Volumes:
  mysql-persistent-storage:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  ebs-mysql-pv-claim
    ReadOnly:   false
  usermanagement-dbcreation-script:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      usermanagement-dbcreation-script
    Optional:  false
  default-token-nlx4p:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-nlx4p
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>
Run Code Online (Sandbox Code Playgroud)

部署表明它已经扩展并且没有任何问题。

Events:
  Type    Reason             Age    From                   Message
  ----    ------             ----   ----                   -------
  Normal  ScalingReplicaSet  5m34s  deployment-controller  Scaled up replica set mysql-6cc489dcd5 to 1
Run Code Online (Sandbox Code Playgroud)

cat 01-storage-class.yml

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: ebs-sc

provisioner: ebs.csi.aws.com
volumeBindingMode: WaitForFirstConsumer
Run Code Online (Sandbox Code Playgroud)

cat 02-persistent-volume-claim.yml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: ebs-mysql-pv-claim

spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ebs-sc # Metadata name of the storage class
  resources:
    requests:
      storage: 4Gi
Run Code Online (Sandbox Code Playgroud)

cat 03-UserManagement-ConfigMap.yml

apiVersion: v1
kind: ConfigMap
metadata:
  name: usermanagement-dbcreation-script

data:
  mysql_usermgt.sql: |-
    DROP DATABASE IF EXISTS usermgmt;
    CREATE DATABASE usermgt;
Run Code Online (Sandbox Code Playgroud)

cat 04-mysql-deployment.yml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql

spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql
  strategy:
   type: Recreate
  template:
    metadata:
      name: mysql-deployment
      labels:
        app: mysql
    spec:
      containers:
        - name: mysql
          image: mysql:5.6
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: dbpassword11
          ports:
            - containerPort: 3306
              name: mysql
          volumeMounts:
            - name: mysql-persistent-storage            # name from the volumes listed below
              mountPath: /var/lib/mysql
            - name: usermanagement-dbcreation-script    # name from the volumes listed below
              mountPath:  /docker-entrypoint-initdb.d

      volumes:
        - name: mysql-persistent-storage
          persistentVolumeClaim:
            claimName: ebs-mysql-pv-claim
        - name: usermanagement-dbcreation-script
          configMap:
            name: usermanagement-dbcreation-script
Run Code Online (Sandbox Code Playgroud)

cat 05-mysql-clusterip-service.yml

apiVersion: v1
kind: Service
metadata:
  name: mysql

spec:
  #type: # Defaults to cluster IP service
  selector:
    app: mysql
  ports:
    - name: mysql
      port: 3306  # If name isn't provided, port can start as a list `- port: 3306`
      #targetPort # Defaults to containerPort
  clusterIP: None # Use POD IP directly
Run Code Online (Sandbox Code Playgroud)

kubectl 描述节点

Name:               ip-192-168-14-238.ap-south-1.compute.internal
Roles:              <none>
Labels:             alpha.eksctl.io/cluster-name=eksdemo1
                    alpha.eksctl.io/nodegroup-name=eksdemo1-ng-public1
                    beta.kubernetes.io/arch=amd64
                    beta.kubernetes.io/instance-type=t2.small
                    beta.kubernetes.io/os=linux
                    eks.amazonaws.com/capacityType=ON_DEMAND
                    eks.amazonaws.com/nodegroup=eksdemo1-ng-public1
                    eks.amazonaws.com/nodegroup-image=ami-01cfab2ec59e55c25
                    eks.amazonaws.com/sourceLaunchTemplateId=lt-02527e7be817e66a5
                    eks.amazonaws.com/sourceLaunchTemplateVersion=1
                    failure-domain.beta.kubernetes.io/region=ap-south-1
                    failure-domain.beta.kubernetes.io/zone=ap-south-1a
                    kubernetes.io/arch=amd64
                    kubernetes.io/hostname=ip-192-168-14-238.ap-south-1.compute.internal
                    kubernetes.io/os=linux
                    node.kubernetes.io/instance-type=t2.small
                    topology.ebs.csi.aws.com/zone=ap-south-1a
                    topology.kubernetes.io/region=ap-south-1
                    topology.kubernetes.io/zone=ap-south-1a
Annotations:        csi.volume.kubernetes.io/nodeid: {"ebs.csi.aws.com":"i-0b3699bcac4e70d31"}
                    node.alpha.kubernetes.io/ttl: 0
                    volumes.kubernetes.io/controller-managed-attach-detach: true
CreationTimestamp:  Wed, 25 Nov 2020 05:05:47 -0500
Taints:             <none>
Unschedulable:      false
Lease:
  HolderIdentity:  ip-192-168-14-238.ap-south-1.compute.internal
  AcquireTime:     <unset>
  RenewTime:       Thu, 26 Nov 2020 01:41:17 -0500
Conditions:
  Type             Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message
  ----             ------  -----------------                 ------------------                ------                       -------
  MemoryPressure   False   Thu, 26 Nov 2020 01:40:40 -0500   Wed, 25 Nov 2020 05:05:47 -0500   KubeletHasSufficientMemory   kubelet has sufficient memory available
  DiskPressure     False   Thu, 26 Nov 2020 01:40:40 -0500   Wed, 25 Nov 2020 05:05:47 -0500   KubeletHasNoDiskPressure     kubelet has no disk pressure
  PIDPressure      False   Thu, 26 Nov 2020 01:40:40 -0500   Wed, 25 Nov 2020 05:05:47 -0500   KubeletHasSufficientPID      kubelet has sufficient PID available
  Ready            True    Thu, 26 Nov 2020 01:40:40 -0500   Wed, 25 Nov 2020 05:06:17 -0500   KubeletReady                 kubelet is posting ready status
Addresses:
  InternalIP:   192.168.14.238
  ExternalIP:   15.206.94.127
  Hostname:     ip-192-168-14-238.ap-south-1.compute.internal
  InternalDNS:  ip-192-168-14-238.ap-south-1.compute.internal
  ExternalDNS:  ec2-15-206-94-127.ap-south-1.compute.amazonaws.com
Capacity:
  attachable-volumes-aws-ebs:  39
  cpu:                         1
  ephemeral-storage:           20959212Ki
  hugepages-2Mi:               0
  memory:                      2039136Ki
  pods:                        11
Allocatable:
  attachable-volumes-aws-ebs:  39
  cpu:                         940m
  ephemeral-storage:           18242267924
  hugepages-2Mi:               0
  memory:                      1551712Ki
  pods:                        11
System Info:
  Machine ID:                 10f1040dde9f47289c7e10ea3fb9f040
  System UUID:                EC2C067A-2E0E-8A49-76C1-7F5FFA16E7ED
  Boot ID:                    d2638886-d5b3-4fa6-a15b-e95e046397f5
  Kernel Version:             4.14.203-156.332.amzn2.x86_64
  OS Image:                   Amazon Linux 2
  Operating System:           linux
  Architecture:               amd64
  Container Runtime Version:  docker://19.3.6
  Kubelet Version:            v1.18.9-eks-d1db3c
  Kube-Proxy Version:         v1.18.9-eks-d1db3c
ProviderID:                   aws:///ap-south-1a/i-0b3699bcac4e70d31
Non-terminated Pods:          (5 in total)
  Namespace                   Name                                   CPU Requests  CPU Limits  Memory Requests  Memory Limits  AGE
  ---------                   ----                                   ------------  ----------  ---------------  -------------  ---
  kube-system                 aws-node-zn9v5                         10m (1%)      0 (0%)      0 (0%)           0 (0%)         20h
  kube-system                 coredns-6b4cdc67b4-pzrl7               100m (10%)    0 (0%)      70Mi (4%)        170Mi (11%)    20h
  kube-system                 ebs-csi-controller-7bf8974dc8-cth9n    0 (0%)        0 (0%)      0 (0%)           0 (0%)         20h
  kube-system                 ebs-csi-node-2vr6j                     0 (0%)        0 (0%)      0 (0%)           0 (0%)         20h
  kube-system                 kube-proxy-dd4wd                       100m (10%)    0 (0%)      0 (0%)           0 (0%)         20h
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource                    Requests    Limits
  --------                    --------    ------
  cpu                         210m (22%)  0 (0%)
  memory                      70Mi (4%)   170Mi (11%)
  ephemeral-storage           0 (0%)      0 (0%)
  hugepages-2Mi               0 (0%)      0 (0%)
  attachable-volumes-aws-ebs  0           0
Events:                       <none>


Name:               ip-192-168-57-231.ap-south-1.compute.internal
Roles:              <none>
Labels:             alpha.eksctl.io/cluster-name=eksdemo1
                    alpha.eksctl.io/nodegroup-name=eksdemo1-ng-public1
                    beta.kubernetes.io/arch=amd64
                    beta.kubernetes.io/instance-type=t2.small
                    beta.kubernetes.io/os=linux
                    eks.amazonaws.com/capacityType=ON_DEMAND
                    eks.amazonaws.com/nodegroup=eksdemo1-ng-public1
                    eks.amazonaws.com/nodegroup-image=ami-01cfab2ec59e55c25
                    eks.amazonaws.com/sourceLaunchTemplateId=lt-02527e7be817e66a5
                    eks.amazonaws.com/sourceLaunchTemplateVersion=1
                    failure-domain.beta.kubernetes.io/region=ap-south-1
                    failure-domain.beta.kubernetes.io/zone=ap-south-1b
                    kubernetes.io/arch=amd64
                    kubernetes.io/hostname=ip-192-168-57-231.ap-south-1.compute.internal
                    kubernetes.io/os=linux
                    node.kubernetes.io/instance-type=t2.small
                    topology.ebs.csi.aws.com/zone=ap-south-1b
                    topology.kubernetes.io/region=ap-south-1
                    topology.kubernetes.io/zone=ap-south-1b
Annotations:        csi.volume.kubernetes.io/nodeid: {"ebs.csi.aws.com":"i-0317d2c406ad6034d"}
                    node.alpha.kubernetes.io/ttl: 0
                    volumes.kubernetes.io/controller-managed-attach-detach: true
CreationTimestamp:  Wed, 25 Nov 2020 05:05:49 -0500
Taints:             <none>
Unschedulable:      false
Lease:
  HolderIdentity:  ip-192-168-57-231.ap-south-1.compute.internal
  AcquireTime:     <unset>
  RenewTime:       Thu, 26 Nov 2020 01:41:17 -0500
Conditions:
  Type             Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message
  ----             ------  -----------------                 ------------------                ------                       -------
  MemoryPressure   False   Thu, 26 Nov 2020 01:40:39 -0500   Wed, 25 Nov 2020 05:05:49 -0500   KubeletHasSufficientMemory   kubelet has sufficient memory available
  DiskPressure     False   Thu, 26 Nov 2020 01:40:39 -0500   Wed, 25 Nov 2020 05:05:49 -0500   KubeletHasNoDiskPressure     kubelet has no disk pressure
  PIDPressure      False   Thu, 26 Nov 2020 01:40:39 -0500   Wed, 25 Nov 2020 05:05:49 -0500   KubeletHasSufficientPID      kubelet has sufficient PID available
  Ready            True    Thu, 26 Nov 2020 01:40:39 -0500   Wed, 25 Nov 2020 05:06:20 -0500   KubeletReady                 kubelet is posting ready status
Addresses:
  InternalIP:   192.168.57.231
  ExternalIP:   52.66.246.122
  Hostname:     ip-192-168-57-231.ap-south-1.compute.internal
  InternalDNS:  ip-192-168-57-231.ap-south-1.compute.internal
  ExternalDNS:  ec2-52-66-246-122.ap-south-1.compute.amazonaws.com
Capacity:
  attachable-volumes-aws-ebs:  39
  cpu:                         1
  ephemeral-storage:           20959212Ki
  hugepages-2Mi:               0
  memory:                      2039136Ki
  pods:                        11
Allocatable:
  attachable-volumes-aws-ebs:  39
  cpu:                         940m
  ephemeral-storage:           18242267924
  hugepages-2Mi:               0
  memory:                      1551712Ki
  pods:                        11
System Info:
  Machine ID:                 a14b97ab355f485294e0e6bd736775af
  System UUID:                EC2D6C5A-497D-E6A4-F235-CF3055FCB546
  Boot ID:                    c37c79e9-4bb1-4ffb-810f-80a4405cb403
  Kernel Version:             4.14.203-156.332.amzn2.x86_64
  OS Image:                   Amazon Linux 2
  Operating System:           linux
  Architecture:               amd64
  Container Runtime Version:  docker://19.3.6
  Kubelet Version:            v1.18.9-eks-d1db3c
  Kube-Proxy Version:         v1.18.9-eks-d1db3c
ProviderID:                   aws:///ap-south-1b/i-0317d2c406ad6034d
Non-terminated Pods:          (5 in total)
  Namespace                   Name                                   CPU Requests  CPU Limits  Memory Requests  Memory Limits  AGE
  ---------                   ----                                   ------------  ----------  ---------------  -------------  ---
  kube-system                 aws-node-qnjzl                         10m (1%)      0 (0%)      0 (0%)           0 (0%)         20h
  kube-system                 coredns-6b4cdc67b4-whszf               100m (10%)    0 (0%)      70Mi (4%)        170Mi (11%)    20h
  kube-system                 ebs-csi-controller-7bf8974dc8-cs6p8    0 (0%)        0 (0%)      0 (0%)           0 (0%)         20h
  kube-system                 ebs-csi-node-2qwjq                     0 (0%)        0 (0%)      0 (0%)           0 (0%)         20h
  kube-system                 kube-proxy-pkxc9                       100m (10%)    0 (0%)      0 (0%)           0 (0%)         20h
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource                    Requests    Limits
  --------                    --------    ------
  cpu                         210m (22%)  0 (0%)
  memory                      70Mi (4%)   170Mi (11%)
  ephemeral-storage           0 (0%)      0 (0%)
  hugepages-2Mi               0 (0%)      0 (0%)
  attachable-volumes-aws-ebs  0           0
Events:                       <none>
Run Code Online (Sandbox Code Playgroud)

Jef*_*ard 1

kubectl get nodes -o wide
Run Code Online (Sandbox Code Playgroud)

或者

kubectl describe nodes
Run Code Online (Sandbox Code Playgroud)

应该为您提供有关集群中节点的一些信息。这可能是资源问题。我在您的 podspec 中没有看到有关 CPU/内存的任何限制或请求。我会尝试添加一些并确保最小推荐值与节点上可用的值一致。