共计 3004 个字符,预计需要花费 8 分钟才能阅读完成。
Cilium 简介
Cilium 是一个用于容器网络畛域的开源我的项目,次要是面向容器而应用,用于提供并通明地爱护应用程序工作负载(如应用程序容器或过程)之间的网络连接和负载平衡。
Cilium 在第 3/4 层运行,以提供传统的网络和平安服务,还在第 7 层运行,以爱护古代利用协定(如 HTTP, gRPC 和 Kafka)的应用。Cilium 被集成到常见的容器编排框架中,如 Kubernetes 和 Mesos。
Cilium 的底层根底是 BPF,Cilium 的工作模式是生成内核级别的 BPF 程序与容器间接交互。区别于为容器创立 overlay 网络,Cilium 容许每个容器调配一个 IPv6 地址(或者 IPv4 地址),应用容器标签而不是网络路由规定去实现容器间的网络隔离。它还蕴含创立并施行 Cilium 规定的编排零碎的整合。
以上简介来源于 oschina
对 Cilium 的性能比拟感兴趣的读者能够参考这篇文章:最强 CNI 基准测试:Cilium 网络性能剖析
零碎要求
Linux Kernel >= 4.9.17
更多信息请查看 Cilium 零碎要求
环境
以一台 Ubuntu Server 20.04.1 LTS 64bit 为例
name | ip | role |
---|---|---|
node1 | 10.160.6.136 | etcd, master, worker |
下载安装包
sudo wget https://github.com/kubesphere/kubekey/releases/download/v1.1.0/kubekey-v1.1.0-linux-64bit.deb
应用 cilium 作为网络插件部署 KubeSphere
1. 装置 KubeKey
sudo dpkg -i kubekey-v1.1.0-linux-64bit.deb
2. 生成配置文件
sudo kk create config --with-kubernetes v1.19.8
3. 批改配置文件,将网络插件批改为 cilium
留神将 spec.network.plugin 的值批改为 cilium
sudo vi config-sample.yaml
apiVersion: kubekey.kubesphere.io/v1alpha1 | |
kind: Cluster | |
metadata: | |
name: sample | |
spec: | |
hosts: | |
- {name: node1, address: 10.160.6.136, internalAddress: 10.160.6.136, user: ubuntu, password: ********} | |
roleGroups: | |
etcd: | |
- node1 | |
master: | |
- node1 | |
worker: | |
- node1 | |
controlPlaneEndpoint: | |
domain: lb.kubesphere.local | |
address: "" | |
port: 6443 | |
kubernetes: | |
version: v1.19.8 | |
imageRepo: kubesphere | |
clusterName: cluster.local | |
network: | |
plugin: cilium | |
kubePodsCIDR: 10.233.64.0/18 | |
kubeServiceCIDR: 10.233.0.0/18 | |
registry: | |
registryMirrors: [] | |
insecureRegistries: [] | |
addons: [] |
4. 部署依赖
sudo kk init os -f config-sample.yaml
5. 部署 KubeSphere
sudo kk create cluster -f config-sample.yaml --with-kubesphere v3.1.0
看到如下提醒阐明装置实现
##################################################### | |
### Welcome to KubeSphere! ### | |
##################################################### | |
Console: http://10.160.6.136:30880 | |
Account: admin | |
Password: P@88w0rd | |
NOTES:1. After you log into the console, please check the | |
monitoring status of service components in | |
"Cluster Management". If any service is not | |
ready, please wait patiently until all components | |
are up and running. | |
2. Please change the default password after login. | |
##################################################### | |
https://kubesphere.io 2021-05-18 17:15:03 | |
##################################################### | |
INFO[17:15:16 CST] Installation is complete. |
6. 登陆 KubeSphere console
7. 查看状态
装置 hubble UI
Hubble 是专门为网络可视化设计的,可能利用 Cilium 提供的 eBPF 数据门路,取得对 Kubernetes 利用和服务的网络流量的深度可见性。这些网络流量信息能够对接 Hubble CLI、UI 工具,能够通过交互式的形式疾速诊断如与 DNS 相干的问题。除了 Hubble 本身的监控工具,还能够对接支流的云原生监控体系——Prometheus 和 Grafana,实现可扩大的监控策略。
Hubble 的装置很简略,间接执行以下命令:
kubectl apply -f https://raw.githubusercontent.com/cilium/cilium/1.9.7/install/kubernetes/quick-hubble-install.yaml
查看状态
装置 demo 服务,并在 hubble UI 查看服务依赖关系
1. 装置 demo
kubectl create -f https://raw.githubusercontent.com/cilium/cilium/1.9.7/examples/minikube/http-sw-app.yaml
2. 将 hubble UI 服务类型批改为 NodePort
3. 拜访 demo
kubectl exec xwing -- curl -s -XPOST deathstar.default.svc.cluster.local/v1/request-landing | |
Ship landed | |
kubectl exec tiefighter -- curl -s -XPOST deathstar.default.svc.cluster.local/v1/request-landing | |
Ship landed |
4. 在 hubble 上 查看服务依赖关系
如果想开启网络 7 层的可视化察看,就须要对指标 Pod 进行 annotations,感兴趣能够看 Cilium 的官网文档。
总结
从应用体验来看,Cilium 曾经能够满足绝大多数的容器网络需要,特地是 Hubble 应用原生的形式实现了数据立体的可视化,比 Istio 高超多了。置信用不了多久,Cilium 便会成为 Kubernetes 社区应用最多的网络计划。
本文由博客一文多发平台 OpenWrite 公布!