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 發布!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/285808.html
標籤:其他
