部署cilium环境和hubble可视化UI界面
官网:https://docs.cilium.io/en/v1.10/
Cilium+hubble
Cilium 是一个基于 eBPF 和 XDP 的高性能容器网络方案的开源项目,目标是为微服务环境提供网络、负载均衡、安全功能,主要定位是容器平台。
部署Cilium
!!!!!!!!!!!版本要求!!!!!!!!!!!
Kubernetes >= 1.9Linux kernel >= 4.9ETCD >= 3.1.0kubernetes 环境中安装了 Helm 3Kubernetes in CNI mode在所有 worker node 上挂载 BPF 文件系统//推荐:在 kube-controller-manager 上使能 PodCIDR allocation (--allocate-node-cidrs)
安装 helm 3
wget https://get.helm.sh/helm-v3.1.2-linux-amd64.tar.gztar -zxvf helm-v3.1.2-linux-amd64.tar.gzmv linux-amd64/helm /usr/local/bin/helm version #查看版本
挂载 BPF 文件系统
mount bpffs /sys/fs/bpf -t bpfmount |grep bpfbpffs on /sys/fs/bpf type bpf (rw,relatime)echo "bpffs /sys/fs/bpf bpf defaults 0 0" >> /etc/fstab
kubernetes 配置
# 在所有的 kubernetes node 中的 kubelet 配置使用 CNI 模式, kubelet.config 中添加--network-plugin=cni# 在 kube-controller-manager 中使能 PodCIDR, kube-controller-manager.config 中添加--allocate-node-cidrs=tru
部署 Cilium
添加仓库并安装
helm repo add cilium https://helm.cilium.io/helm install cilium cilium/cilium --version 1.10.0 --namespace kube-system
验证安装
curl -L --remote-name-all https://github.com/cilium/cilium-cli/releases/latest/download/cilium-linux-amd64.tar.gz{,.sha256sum}sha256sum --check cilium-linux-amd64.tar.gz.sha256sumsudo tar xzvfC cilium-linux-amd64.tar.gz /usr/local/binrm cilium-linux-amd64.tar.gz{,.sha256sum}
cilium status --wait/¯¯\/¯¯\__/¯¯\ Cilium: OK\__/¯¯\__/ Operator: OK/¯¯\__/¯¯\ Hubble: disabled\__/¯¯\__/ ClusterMesh: disabled\__/DaemonSet cilium Desired: 2, Ready: 2/2, Available: 2/2Deployment cilium-operator Desired: 2, Ready: 2/2, Available: 2/2Containers: cilium-operator Running: 2cilium Running: 2Image versions cilium quay.io/cilium/cilium:v1.9.5: 2cilium-operator quay.io/cilium/operator-generic:v1.9.5: 2
运行以下命令以验证您的集群是否具有正确的网络连接:
cilium connectivity testℹ️ Monitor aggregation detected, will skip some flow validation steps✨ [k8s-cluster] Creating namespace for connectivity check...---------------------------------------------------------------------------------------------------------------------📋 Test Report---------------------------------------------------------------------------------------------------------------------✅ 69/69 tests successful (0 warnings)
部署Hubble
生产yaml
helm template cilium cilium/cilium --version 1.8.1 \--namespace kube-system \--set global.etcd.enabled=true \--set global.etcd.managed=true \--set global.hubble.enabled=true \--set global.hubble.listenAddress=":4244" \--set global.hubble.metrics.enabled="{dns,drop,tcp,flow,port-distribution,icmp,http}" \--set global.hubble.relay.enabled=true \--set global.hubble.ui.enabled=true > hubble.yamlkubectl apply -f hubble.yaml# 包含两个组件# - daemonset hubble# - deployment hubble UIkubectl get pod -n kube-system |grep hubblehubble-67ldp 1/1 Running 0 21hhubble-f287p 1/1 Running 0 21hhubble-fxzms 1/1 Running 0 21hhubble-tlq64 1/1 Running 1 21hhubble-ui-5f9fc85849-hkzkr 1/1 Running 0 15hhubble-vpxcb 1/1 Running 0 21h
kubectl apply -f hubble-ui-nodeport-svc.yaml
hubble-ui-nodeport-svc.yamlkind: ServiceapiVersion: v1metadata:namespace: kube-systemname: hubble-ui-npspec:selector:k8s-app: hubble-uiports:- name: httpport: 12000nodePort: 32321type: NodePort


