首页
视频
资源
登录
原
Multus-CNI与whereabouts的简单运用
3182
人阅读
2022/12/22 16:00
总访问:
2611903
评论:
0
收藏:
0
手机
分类:
容器编排
![](https://img.tnblog.net/arcimg/hb/3b16052dd86e489eadd9e573b94a4472.png) ># Multus-CNI [TOC] ## Multus-CNI 简介 tn2>简单来讲,这玩意可以对一个pod插入多张网卡进行通信。同时也支持多种cni的插件,什么Flannle、calico、macvlan都是可以的。 ![](https://img.tnblog.net/arcimg/hb/7086b69de9c4415c813812b7188b4d6a.png) tn2>它的工作流程如下图所示: ![](https://img.tnblog.net/arcimg/hb/f21a01d1b3a54d73892df7d67ed939d8.png) tn2>这样看不清晰流程可以看创建的pod信息。 ![](https://img.tnblog.net/arcimg/hb/e603c10177e9483c83dff7b08de9a134.png) tn2>执行如下命令进行安装。 ```bash git clone https://github.com/k8snetworkplumbingwg/multus-cni.git cd multus-cni cat ./deployments/multus-daemonset.yml | kubectl apply -f - ``` tn2>安装完成后,会多一个名为`NetworkAttachmentDefinition`资源来定义cni的配置。 ## whereabouts 简介 ![](https://img.tnblog.net/arcimg/hb/7e34d79fc7574a8dbd9badf88c746adb.png) tn2>在以前的博客中,使用`local-host`需要为每台主机分配不同的ip地址范围才能实现,而whereabouts会自动进行分配ip地址且不会发生两台主机同一个ip的情况。 可通过如下命令进行安装: ```bash 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 实践 tn2>首先我们定义ipvlan的配置文件。 ```bash vim networkad.yaml ``` ```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" } }' ``` tn2>然后apply一下。 ```bash kubectl apply -f networkad.yaml ``` tn2>创建一个指定使用`whereabouts-ipvlan-conf-1`配置的pod,并将该网卡设置为`eth1`。 ```bash vim ipvlan.yaml ``` ```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 ``` ```bash kubectl apply -f ipvlan.yaml kubectl get pod kubectl exec pod/pod0-case-02 -- ifconfig ``` ![](https://img.tnblog.net/arcimg/hb/7d6bad8d8c61432c8d6795f3d12bd004.png) tn2>外网仍然可以访问。 ![](https://img.tnblog.net/arcimg/hb/8f5981e354044533bb6594f76d0064a6.png) ## macvlan 实践 tn2>首先定义macvlan配置文件。 ```bash vim networkwhereabouts.yaml ``` ```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" } }' ``` ```bash kubectl apply -f networkwhereabouts.yaml kubectl get net-attach-def kubectl get net-attach-def whereabouts-conf ``` tn2>创建一个指定使用`whereabouts-conf`配置的pod,并将该网卡设置为`eth3`。 ```yaml 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 ``` ```bash kubectl get pods -o wide kubectl exec pod/pod-macvlan -- ifconfig ``` ![](https://img.tnblog.net/arcimg/hb/85eb2847e61248129823ce30b4f90d0d.png)
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739
👈{{preArticle.title}}
👉{{nextArticle.title}}
评价
{{titleitem}}
{{titleitem}}
{{item.content}}
{{titleitem}}
{{titleitem}}
{{item.content}}
尘叶心繁
这一世以无限游戏为使命!
博主信息
排名
6
文章
6
粉丝
16
评论
8
文章类别
.net后台框架
168篇
linux
17篇
linux中cve
1篇
windows中cve
0篇
资源分享
10篇
Win32
3篇
前端
28篇
传说中的c
4篇
Xamarin
9篇
docker
15篇
容器编排
101篇
grpc
4篇
Go
15篇
yaml模板
1篇
理论
2篇
更多
Sqlserver
4篇
云产品
39篇
git
3篇
Unity
1篇
考证
2篇
RabbitMq
23篇
Harbor
1篇
Ansible
8篇
Jenkins
17篇
Vue
1篇
Ids4
18篇
istio
1篇
架构
2篇
网络
7篇
windbg
4篇
AI
18篇
threejs
2篇
人物
1篇
嵌入式
2篇
python
13篇
HuggingFace
8篇
pytorch
9篇
opencv
6篇
Halcon
1篇
最新文章
最新评价
{{item.articleTitle}}
{{item.blogName}}
:
{{item.content}}
关于我们
ICP备案 :
渝ICP备18016597号-1
网站信息:
2018-2024
TNBLOG.NET
技术交流:
群号656732739
联系我们:
contact@tnblog.net
欢迎加群
欢迎加群交流技术