K8S之调度约束+故障排查

目录

一、调度约束的各个组件流程图

二、基本调度方式 

三、操作实例

3.1 nodeName

3.2 nodeSelector 

四、故障排查 

一、调度约束的各个组件流程图

Kubernetes通过watch的机制进行每个组件的协作,每个组件之间的设计实现了解耦。

二、基本调度方式 

  • nodeName用于将Pod调度到指定的Node名称上(跳过调度器直接分配)
  • nodeSelector用于将Pod调度到匹配Label的Node上

三、操作实例

3.1 nodeName

vim pod5.yaml
kubectl create -f pod5.yaml 
apiVersion: v1  
kind: Pod  
metadata:
  name: pod-example  
  labels:
    app: nginx  
spec:
  nodeName: node1
  containers:
  - name: nginx  
    image: nginx:1.14
kubectl get pods -o wide
#查看详细事件(发现未经过调度器)
kubectl describe pod pod-example

#清空pod
kubectl delete -f .

3.2 nodeSelector 

#查看标签用法
kubectl label --help
Usage:
  kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N
[--resource-version=version] [options]
#需要获取node上的NAME名称
kubectl get node
#给对应的node设置标签分别为cz=alice和cz=bob
kubectl label nodes node1(节点名字为none的用IP) cz=alice
kubectl label nodes node2 cz=bob
#查看标签
kubectl get nodes --show-labels

apiVersion: v1
kind: Pod
metadata:
  name: pod-example
  labels:
    app: nginx
spec:
  nodeSelector:
    cz: bob
  containers:
  - name: nginx
    image: nginx:1.14

vim pod5.yaml 
kubectl create -f pod5.yaml
kubectl get pods -o wide
#查看详细事件(通过事件可以观察经过调度器分配)
kubectl describe pod pod-example

四、故障排查 

状态表

#查看pod事件
kubectl describe TYPE NAME_PREFIX  
#查看pod日志(Failed状态下)
kubectl logs POD_NAME
#进入pod(状态为running,但是服务没有提供)
kubectl exec –it POD_NAME bash
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值