kubernetes 无法调度问题

0/1 nodes are available: 1 node(s) didn't match Pod's node affinity/selector. preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling.

kubernetes 如何出现上面报错,说明没有可调度的机器,是因为在yaml文件里写了 nodeSelector, 解决其实特别简单。比如:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: chartmuseum
  name: chartmuseum
  namespace: helm
spec:
  replicas: 1
  selector:
    matchLabels:
      app: chartmuseum
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: chartmuseum
    spec:
      containers:
      - image: chartmuseum/chartmuseum:latest
        name: chartmuseum
        ports:
        - containerPort: 8080
          protocol: TCP
        env:
        - name: DEBUG
          value: "1"
        - name: STORAGE
          value: local
        - name: STORAGE_LOCAL_ROOTDIR
          value: /charts
        resources:
          limits:
            cpu: 500m
            memory: 256Mi
          requests:
            cpu: 100m
            memory: 64Mi
        volumeMounts:
        - mountPath: /charts
          name: charts-volume
      nodeSelector:
        node-role.kubernetes.io/edge=master
      volumes:
      - name: charts-volume
        hostPath:
          path: /data/charts
          type: DirectoryOrCreate
      restartPolicy: Always

上面yaml中 设置了nodeSelector ,就只要在master上找个node打个标签(label):

# kubectl label nodes node node-role.kubernetes.io/edge=master
node/node labeled

这样就会成功调度。

发表回复 0

Your email address will not be published. Required fields are marked *