先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新大数据全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以添加V获取:vip204888 (备注大数据)
img

正文

污点容忍

污点容忍就是某个节点可能被调度,也可能不被调度

node 节点亲和性

node 节点亲和性调度:nodeAffinity 用帮助文档查看亲和性字段下面的东西

[root@k8smaster node]# kubectl explain pods.spec.affinity 
KIND:     Pod
VERSION:  v1

RESOURCE: affinity <Object>

DESCRIPTION:
     If specified, the pod's scheduling constraints

 Affinity is a group of affinity scheduling rules.

FIELDS:
 nodeAffinity <Object>
 Describes node affinity scheduling rules for the pod.

 podAffinity <Object>
 
 podAntiAffinity <Object>
#有node节点亲和性 pode节点亲和性等,然后我们再详细的看看nodeAffinity 。
 
[root@k8smaster node]# kubectl explain pods.spec.affinity.nodeAffinity 
KIND: Pod
VERSION: v1

RESOURCE: nodeAffinity <Object>

DESCRIPTION:
 Describes node affinity scheduling rules for the pod.

 Node affinity is a group of node affinity scheduling rules.

FIELDS:
 preferredDuringSchedulingIgnoredDuringExecution <[]Object>

 requiredDuringSchedulingIgnoredDuringExecution <Object>
 
#prefered 表示有节点尽量满足这个位置定义的亲和性,这不是一个必须的条件,软亲和性,没满足也可能调度。
#require 表示必须有节点满足这个位置定义的亲和性,这是个硬性条件,硬亲和性,没满足不可能调度。

[root@k8smaster node]# kubectl explain pods.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution
KIND: Pod
VERSION: v1

RESOURCE: requiredDuringSchedulingIgnoredDuringExecution <Object>

DESCRIPTION:
 If the affinity requirements specified by this field are not met at
 scheduling time, the pod will not be scheduled onto the node. If the
 affinity requirements specified by this field cease to be met at some point
 during pod execution (e.g. due to an update), the system may or may not try
 to eventually evict the pod from its node.

 A node selector represents the union of the results of one or more label
 queries over a set of nodes; that is, it represents the OR of the selectors
 represented by the node selector terms.

FIELDS:
 nodeSelectorTerms <[]Object> -required- #必写字段,对象列表
 
[root@k8smaster node]# kubectl explain pods.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTermsKIND: Pod
VERSION: v1

RESOURCE: nodeSelectorTerms <[]Object>

DESCRIPTION:
 Required. A list of node selector terms. The terms are ORed.

 A null or empty node selector term matches no objects. The requirements of
 them are ANDed. The TopologySelectorTerm type implements a subset of the
 NodeSelectorTerm.

FIELDS:
 matchExpressions <[]Object> #匹配表达式的
 A list of node selector requirements by node's labels.

   matchFields	<[]Object>	#匹配字段的 
     A list of node selector requirements by node's fields.
 
[root@k8smaster node]# kubectl explain pods.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms.matchExpressions
KIND: Pod
VERSION: v1

RESOURCE: matchExpressions <[]Object>

DESCRIPTION:
 A list of node selector requirements by node's labels.

     A node selector requirement is a selector that contains values, a key, and
     an operator that relates the key and values.

FIELDS:
   key	<string> -required-		#检查 label
   
   operator	<string> -required-	#做等值选则还是不等值选则 

   values	<[]string>			#给定的值 
#在做node节点亲和性的时候,values是标签的值,他会通过op匹配相等的key或者不等的key。
 
 
例 1:使用 requiredDuringSchedulingIgnoredDuringExecution 硬亲和性 
#node1 node2都拉nginx
 
[root@k8smaster node]# vim pod-nodeaffinity-demo.yaml
apiVersion: v1
kind: Pod
metadata:
        name: pod-node-affinity-demo
        namespace: default
        labels:
            app: myapp
            tier: frontend
spec:
    containers:
    - name: myapp
      image: nginx
    affinity:
         nodeAffinity:
            requiredDuringSchedulingIgnoredDuringExecution:
                   nodeSelectorTerms:
                   - matchExpressions:
                     - key: zone
                       operator: In
                       values:
                       - foo
                       - bar


affinity:亲和性,下面的node是node亲和性,然后requ硬亲和性,nodeselect是对象列表,我们用-链接,然后match也是对象列表,同上,key是zone,然后等值关系,值是foo和bar。
这个yaml意思是:我们检查当前节点中有任意一个节点拥有 zone 标签的值是 foo 或者 bar,就可以把 pod 调度到这个 node 节点的 foo 或者 bar 标签上的节点上,现在找不到,因为没打标签!

[root@k8smaster node]# kubectl apply -f pod-nodeaffinity-demo.yaml 
pod/pod-node-affinity-demo created
[root@k8smaster node]# kubectl get pods -o wide | grep pod-node 
pod-node-affinity-demo        0/1     Pending   0          11s    <none>        <none>     <none>          

# status 的状态是 pending,上面说明没有完成调度,因为没有一个拥有 zone 的标签的值是 foo 或者 bar,而且使用的是硬亲和性,必须满足条件才能完成调度。
[root@k8smaster node]# kubectl label nodes k8snode zone=foo
node/k8snode labeled
#给这个节点打上标签 zone=foo,在查看 
[root@k8smaster node]# kubectl get pods -o wide 显示running了
pod-node-affinity-demo        1/1     Running   0          4m4s   10.244.2.19   k8snode    <none>           
 
例 2:使用 preferredDuringSchedulingIgnoredDuringExecution 软亲和性 
[root@k8smaster node]# vim pod-nodeaffinity-demo-2.yaml 
apiVersion: v1
kind: Pod
metadata:
        name: pod-node-affinity-demo-2
        namespace: default
        labels:
            app: myapp
            tier: frontend
spec:
    containers:
    - name: myapp
      image: nginx
    affinity:
        nodeAffinity:
            preferredDuringSchedulingIgnoredDuringExecution:
            - preference:
               matchExpressions:
               - key: zone1
                 operator: In
                 values:
                 - foo1
                 - bar1
              weight: 60
          
#用的还是node亲和性,然后是软亲和性,如果所有的工作节点都没有这个标签,pod还是会调度
[root@k8smaster node]# kubectl apply -f pod-nodeaffinity-demo-2.yaml 
pod/pod-node-affinity-demo-2 created

[root@k8smaster node]# kubectl get pods -o wide |grep demo-2
pod-node-affinity-demo-2      1/1     Running   0          29s     10.244.1.20   k8snode2   <none>          


#上面说明软亲和性是可以运行这个 pod 的,尽管没有运行这个 pod 的节点定义的 zone1 标签 
 
Node 节点亲和性针对的是 pod 和 node 的关系,Pod 调度到 node 节点的时候匹配的条件

写在最后

创作不易,如果觉得内容对你有帮助,麻烦给个三连关注支持一下我!如果有错误,请在评论区指出,我会及时更改!
目前正在更新的系列:从零开始学k8s
感谢各位的观看,文章掺杂个人理解,如有错误请联系我指出~

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip204888 (备注大数据)
img

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

需要这份系统化的资料的朋友,可以添加V获取:vip204888 (备注大数据)
[外链图片转存中…(img-6gGT61XI-1713354252507)]

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐