目标
对宿主节点划分子网,同时实现对不同应用划分子网。
实现说明
部署k8s时,划分宿主节点ip,对每个节点配置不同net-conf.json, 这样pod调度到宿主节点时,根据net-conf.json内的network配置分配ip,实现pod级子网划分。
同时对每个宿主节点label不同分组,部署时根据节点亲和性调度pod。
部署过程
注意需要节点已经加入集群的话,需要重置并重新加入。
有三个节点集群
每个节点上配置cni配置文件
修改flannel部署文件,配置从configmap取改到从hostpath取
apiVersion: apps/v1
kind: DaemonSet
metadata:
annotations:
deprecated.daemonset.template.generation: "2"
creationTimestamp: "2021-05-27T06:00:27Z"
generation: 2
labels:
app: flannel
tier: node
name: kube-flannel-ds
namespace: kube-system
resourceVersion: "10808741"
selfLink: /apis/apps/v1/namespaces/kube-system/daemonsets/kube-flannel-ds
uid: fff853a1-a4e2-48f8-bee4-a3ba43522ac6
spec:
revisionHistoryLimit: 10
selector:
matchLabels:
app: flannel
template:
metadata:
creationTimestamp: null
labels:
app: flannel
tier: node
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution: