
Multus-CNI
Multus-CNI 简介
简单来讲,这玩意可以对一个pod插入多张网卡进行通信。同时也支持多种cni的插件,什么Flannle、calico、macvlan都是可以的。
它的工作流程如下图所示:
这样看不清晰流程可以看创建的pod信息。
执行如下命令进行安装。
git clone https://github.com/k8snetworkplumbingwg/multus-cni.git
cd multus-cni
cat ./deployments/multus-daemonset.yml | kubectl apply -f -
安装完成后,会多一个名为NetworkAttachmentDefinition
资源来定义cni的配置。
whereabouts 简介
在以前的博客中,使用local-host
需要为每台主机分配不同的ip地址范围才能实现,而whereabouts会自动进行分配ip地址且不会发生两台主机同一个ip的情况。
可通过如下命令进行安装:
git clone https://github.com/k8snetworkplumbingwg/whereabouts && cd whereabouts
kubectl apply \
-f doc/crds/daemonset-install.yaml \
-f doc/crds/whereabouts.cni.cncf.io_ippools.yaml \
-f doc/crds/whereabouts.cni.cncf.io_overlappingrangeipreservations.yaml
ipvlan 实践
首先我们定义ipvlan的配置文件。
vim networkad.yaml
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
name: whereabouts-ipvlan-conf-1
spec:
config: '{
"cniVersion": "0.3.0",
"name": "ipvlan-conf-1",
"type": "ipvlan",
"master": "eth0",
"mode": "l2",
"ipam": {
"type": "whereabouts",
"range": "10.211.55.0/24",
"range_start": "10.211.55.129",
"range_end": "10.211.55.159",
"gateway": "10.211.55.1"
}
}'
然后apply一下。
kubectl apply -f networkad.yaml
创建一个指定使用whereabouts-ipvlan-conf-1
配置的pod,并将该网卡设置为eth1
。
vim ipvlan.yaml
apiVersion: v1
kind: Pod
metadata:
name: pod0-case-02
annotations:
k8s.v1.cni.cncf.io/networks: whereabouts-ipvlan-conf-1@eth1
spec:
containers:
- name: pod0-case-02
image: burlyluo/nettoolbox
command:
- /sbin/init
kubectl apply -f ipvlan.yaml
kubectl get pod
kubectl exec pod/pod0-case-02 -- ifconfig
外网仍然可以访问。
macvlan 实践
首先定义macvlan配置文件。
vim networkwhereabouts.yaml
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
name: whereabouts-conf
spec:
config: '{
"cniVersion": "0.3.0",
"name": "whereaboutsexample",
"type": "macvlan",
"master": "eth0",
"mode": "bridge",
"ipam": {
"type": "whereabouts",
"range": "192.168.2.225/28"
}
}'
kubectl apply -f networkwhereabouts.yaml
kubectl get net-attach-def
kubectl get net-attach-def whereabouts-conf
创建一个指定使用whereabouts-conf
配置的pod,并将该网卡设置为eth3
。
cat <<EOF | kubectl create -f -
apiVersion: v1
kind: Pod
metadata:
name: pod-macvlan
annotations:
k8s.v1.cni.cncf.io/networks: whereabouts-conf@eth3
spec:
containers:
- name: pod
image: burlyluo/nettoolbox
EOF
kubectl get pods -o wide
kubectl exec pod/pod-macvlan -- ifconfig
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739
评价
排名
2
文章
634
粉丝
44
评论
93
docker中Sware集群与service
尘叶心繁 : 想学呀!我教你呀
一个bug让程序员走上法庭 索赔金额达400亿日元
叼着奶瓶逛酒吧 : 所以说做程序员也要懂点法律知识
.net core 塑形资源
剑轩 : 收藏收藏
映射AutoMapper
剑轩 :
好是好,这个对效率影响大不大哇,效率高不高
一个bug让程序员走上法庭 索赔金额达400亿日元
剑轩 : 有点可怕
ASP.NET Core 服务注册生命周期
剑轩 :
http://www.tnblog.net/aojiancc2/article/details/167
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256


欢迎加群交流技术