FailedScheduling节点与在AWS上设置的kubernetes中的节点选择器不匹配

时间:2020-10-04 12:30:01

标签: amazon-web-services kubernetes yaml

我在AWS中设置了一个具有多个节点的kubernetes。

尝试创建其中一个Pod时,出现以下错误


Warning  FailedScheduling  4m7s (x2 over 4m7s)  default-scheduler  0/15 nodes are available: 11 
Insufficient cpu, 12 Insufficient memory, 15 node(s) didn't match node selector.
Warning  FailedScheduling  50s (x6 over 4m11s)  default-scheduler  0/15 nodes are available: 11 
Insufficient cpu, 11 Insufficient memory, 15 node(s) didn't match node selector.

我的豆荚Yaml如下所示,


apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: test-instapi
    suite: test
    log-topic: logs.app.test.instapi
  name: test-instapi
  namespace: test-dev
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test-instapi
      cache-service: hazelcast-instapi
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      annotations:
        prometheus.io/scrape_port: "9999"
        prometheus.io/should_be_scraped: "true"
      labels:
        app: test-instapi
        cache-service: hazelcast-instapi
        log-topic: logs.app.test.instapi
        version: latest
    spec:
      nodeSelector:
        beta.kubernetes.io/instance-type: m5.8xlarge
      containers:
      - image: artifactory.global.standardchartered.com/test/test-fast-api:latest
        imagePullPolicy: Always
        name: test-instapi
        ports:
        - containerPort: 8080
          name: hazel-mancenter
          protocol: TCP
        - containerPort: 9999
          name: jmxexporter
          protocol: TCP
        - containerPort: 9000
          name: rest
          protocol: TCP
        resources:
          limits:
            cpu: "16"
            memory: 96Gi
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /opt/docker/conf/application.conf
          name: config
          subPath: application.conf
        - mountPath: /opt/docker/conf/application.ini
          name: config
          subPath: application.ini
        - mountPath: /opt/docker/conf/cassandra.conf
          name: config
          subPath: cassandra.conf
        - mountPath: /opt/docker/conf/hazelcast.yaml
          name: config
          subPath: hazelcast.yaml
        - mountPath: /opt/docker/conf/logback.xml
          name: config
          subPath: logback.xml
        - mountPath: /opt/docker/conf/streaming.conf
          name: config
          subPath: streaming.conf
        - mountPath: /opt/docker/conf/routes
          name: config
          subPath: routes
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - configMap:
          defaultMode: 420
          name: test-instapi
        name: config
***

我设置的kubernetes版本如下


    Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.3",                 
    GitCommit:"2d3c76f9091b6bec110a5e63777c332469e0cba2", GitTreeState:"clean", BuildDate:"2019-08- 
    19T11:13:54Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
    Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.11", 
    GitCommit:"d94a81c724ea8e1ccc9002d89b7fe81d58f89ede", GitTreeState:"clean", BuildDate:"2020-03- 
    12T21:00:06Z", GoVersion:"go1.12.17", Compiler:"gc", Platform:"linux/amd64"}

我在这里想念什么?我如何确定吊舱已插入8xlarge机器之一? 节点选择器是否可以解决此问题?

1 个答案:

答案 0 :(得分:1)

从kubernetes 1.17版开始,不推荐使用beta.kubernetes.io/instance-type,而推荐使用node.kubernetes.io/instance-type。因此,广告连播需要将其用作nodeSelector

...
spec:
  nodeSelector:
    node.kubernetes.io/instance-type: m5.8xlarge
...

Kubelet使用cloudprovider定义的实例类型填充该实例。仅当您使用cloudprovider 时才设置。

您似乎没有使用cloudprovider即EKS。因此,您需要自行将标签添加到节点。

您可以使用以下方法检查节点上的标签

kubectl get nodes --show-labels

您可以使用以下方法在节点上添加标签

kubectl label nodes <your-node-name> node.kubernetes.io/instance-type=m5.8xlarge