题目

Task

Schedule  a pod as follows:

  • Name:nginx-kusc00401
  • Image:nginx
  • Node selector:disk=spinning

答案

官网:Kubernetes 文档/概念/工作负载/Pods,Kubernetes 文档/概念/调度,抢占和驱逐/将 Pod 分配给节点

https://kubernetes.io/zh/docs/concepts/workloads/pods/pod-topology-spread-constraints/

[root@test CKA]# cat nginx.yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx-kusc00401
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:
    disk: spinning

启动

kubectl apply -f nginx.yaml

或者使用 kubectl run

 kubectl run nginx-kusc00401 --image=nginx  --dry-run='client' -o yaml > test-nginx.yaml

在生成的yaml这添加   nodeSelector

Logo

开源、云原生的融合云平台

更多推荐