Kubernetes之CNI之Cilium的實踐
ubuntu20.04,單網卡,能訪問互聯網,
切換到阿里云的源,
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak,
sudo vim /etc/apt/sources.list,
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
sudo apt update,sudo apt dist-upgrade,
安裝docker,
sudo apt install docker.io,sudo systemctl enable docker,
sudo gpasswd -a master docker,newgrp docker,
安裝kubernetes,
sudo su root,
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -,
sudo vim /etc/apt/sources.list.d/kubernetes.list,
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main,
sudo apt update,
sudo apt install kubelet=1.19.16-00 kubeadm=1.19.16-00 kubectl=1.19.16-00,
sudo swapoff -a,
sudo kubeadm init --pod-network-cidr=10.0.0.0/8 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version=v1.19.16,
mkdir -p $HOME/.kube,
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config,
sudo chown $(id -u):$(id -g) $HOME/.kube/config,
kubectl taint nodes --all node-role.kubernetes.io/master-,
安裝cilium,
sudo mount bpffs /sys/fs/bpf -t bpf,
wget https://raw.githubusercontent.com/cilium/cilium/v1.9/install/kubernetes/quick-install.yaml,
kubectl create -f quick-install.yaml,
接下來要安裝cilium的流量可視化組件,
wget https://raw.githubusercontent.com/cilium/cilium/v1.9/install/kubernetes/quick-hubble-install.yaml,
kubectl apply -f quick-hubble-install.yaml,
當前hubble版本應該是有bug,無法正常完成,改成安裝低版本的,
下載安裝helm,
wget https://get.helm.sh/helm-v3.7.1-linux-amd64.tar.gz,
tar -zxvf helm-v3.7.1-linux-amd64.tar.gz,
sudo mv linux-amd64/helm /usr/local/bin/,
下載低版本hubble,
git clone https://github.com/cilium/hubble.git -b v0.5,
cd hubble/install/kubernetes,
helm template hubble --namespace kube-system --set metrics.enabled="{dns,drop,tcp,flow,port-distribution,icmp,http}" --set ui.enabled=true > /home/master/hubble.yaml,
kubectl apply -f hubble.yaml,
需要手動創建service,vim hubble-service.yaml,
apiVersion: v1
kind: Service
metadata:
name: hubble-ui-node
namespace: kube-system
spec:
ports:
- name: http
port: 12000
protocol: TCP
targetPort: 12000
nodePort: 32000
selector:
k8s-app: hubble-ui
sessionAffinity: None
type: NodePort
kubectl apply -f hubble-service.yaml,
創建兩個測試應用,訪問一下產生流量,hubble界面上能看到效果,
