K8S将pod调度到指定nodes上运行
两种方式
方式1:强制固定
编写yaml,添加参数(node节点名)
vim text.yaml nodeName: worker01 #添加节点名参数
具体yaml
apiVersion: v1 kind: Pod metadata: name: text namespace: text spec: nodeName: worker01 #添加节点名参数 containers:- name: hello image: centos:7 imagePullPolicy: IfNotPresent command:["bash","-c","--"] args:["while true; do sleep 3;done;"]
创建该pod
kubectl create-f text.yaml
查看pod,运行成功
查看是否在worker01上运行
kubectl describe pod text-n text
方式2:使用标签选择器(label-selector)
给节点添加标签
kubectl label nodes worker03 type=node_type
查看标签是否添加成功
kubectl get node--show-labels #获取所有节点的标签,得到worker03设置的标签
编写yaml创建pod,添加标签选择器参数
vim text1.yaml
内容如下
apiVersion: v1 kind: Pod metadata: name: text1 namespace: text spec: nodeSelector: #标签选择器参数 type: node_type #刚刚添加的类型 containers:- name: hello1 image: centos:7 imagePullPolicy: IfNotPresent command:["bash","-c","--"] args:["while true; do sleep 3;done;"]
查看是否运行
kubectl get pod-n text
查看是否成功在worker03上运行
kubectl describe pod text1-n text
原文链接:http://www.hainiubl.com/topics/75623
热门文章
- rancher k8s修改ingress默认80端口
- 嵌入式Linux开发-根文件系统NFS网络挂载
- @PathVariable接收两个参数
- 「2月13日」2025年最新高速Clash/Shadowrocket/SSR/V2ray免费节点订阅链接地址分享
- 「2月18日」2025年最新高速SSR/V2ray/Clash/Shadowrocket免费节点订阅链接地址分享
- 「1月11日」2025年最新高速Clash/SSR/Shadowrocket/V2ray免费节点订阅链接地址分享
- 「1月31日」2025年最新高速Shadowrocket/Clash/SSR/V2ray免费节点订阅链接地址分享
- springboot的依赖管理和自动配置
- 「3月2日」2025年最新高速Clash/Shadowrocket/SSR/V2ray免费节点订阅链接地址分享
- 「2月11日」2025年最新高速SSR/Shadowrocket/Clash/V2ray免费节点订阅链接地址分享