11

使用 Cilium 作为网络插件部署 K8s + KubeSphere

 3 years ago
source link: https://segmentfault.com/a/1190000040123050
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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 为例

nameiprolenode110.160.6.136etcd, 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 发布!


Recommend

  • 47

    Cilium 1.0:将BPF革新引入k8s网络和安全系统

  • 27
    • dockone.io 4 years ago
    • Cache

    Cilium网络概述

    Cilium 是一种开源网络实现方案,与其他网络方案不同的是,Cilium着重强调了其在网络安全上的优势,可以透明的对Kubernetes等容器管理平台上的应用程序服务之间的网络连接进行安全防护。 Cil...

  • 23
    • zhuanlan.zhihu.com 4 years ago
    • Cache

    携程 Cilium+BGP 云原生网络实践

    Cilium 是近两年最火的云原生网络方案之一。Cilium 的核心基于 eBPF,有两大亮点:基于 eBPF 的灵活、高性能网络,以及基于 eBPF 的 L3-L7 安全策略实现。 携程 2019 年开始在生产环境使用 Cilium,本文将介绍 Cilium...

  • 9
    • www.bladewan.com 4 years ago
    • Cache

    k3s集群部署和使用cilium网络插件

    cilium都近期比较火的一个网络插件,它通过将ebpf技术引入网络插件中用于满足容器工作负载的新可伸缩性,安全性和可见性要求。 ebpf依赖内核技术,所以需要保证以下内核版本1 、kernel版本 >= 4.9.17 软件 版本 k3s v1.18.6+k3s1 cilium 1....

  • 38

    K8S 生态周报| Google 选择 Cilium 作为 GKE 下一代数据面网易有道 资深运维开发“ 「K8S 生态周报」内容主要包含我所接触到的 K8S 生态相关的每周值得推荐的一些信息...

  • 16
    • www.chenshake.com 3 years ago
    • Cache

    CentOS8 KubeSphere Cilium and Hubble

    陈沙克日志   这篇文章是参考青云的文章,我在CentOS 上重新测试一遍。 我目前测试基本都是在阿里云香港上启动spot 虚拟机,这样的成本很低,也可以满足...

  • 8
    • segmentfault.com 3 years ago
    • Cache

    KubeSphere 升级 && 安装后启用插件

    KubeSphere 升级 && 安装后启用插件发布于 4 分钟前KubeSphere 升级root@master1:~# export KKZONE=cn root@master1:~# kk upgr...

  • 3
    • blog.51cto.com 2 years ago
    • Cache

    Cilium v1.10.6 安装部署

    Cilium v1.10.6 安装部署 推荐 原创 1.系统要求​

  • 2

    2023-04-19 17:30阅读: 58评论: 0推荐: 3 Kubuesphere部署Ruoyi(二):部署kubesphere

  • 7

    总算能让devops运行以后,流水线却卡在了deploy这一步。碰到了两个比较大的问题,一个是无法使用k8sp自带的kubeconfig认证去部署;一个是部署好了以后但是没有办法解析镜像名。 k8s:v1.21.5 k8sp:v3.3.0 流水线概览

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK