Cilium + ebpf 系列文章- (七)Cilium-LoadBalancer类型的SVC的IPPool

一、配置全局LoadBalancer类型的SVC的IPPool

复制代码
apiVersion: "cilium.io/v2alpha1"
kind: CiliumLoadBalancerIPPool
metadata:
  name: "pool"
spec:
  blocks:
    - cidr: "20.0.10.0/24"

二、配置基于label的LoadBalancer类型的SVC的IPPool

复制代码
# Expression selector
apiVersion: "cilium.io/v2alpha1"
kind: CiliumLoadBalancerIPPool
metadata:
  name: "pool-primary"
spec:
  blocks:
    - cidr: "60.0.10.0/24"
  serviceSelector:
    matchExpressions:
      - {key: color, operator: In, values: [yellow, red, blue]}

# # Second pool, label selector
apiVersion: "cilium.io/v2alpha1"
kind: CiliumLoadBalancerIPPool
metadata:
  name: "pool-green"
spec:
  blocks:
    - cidr: "40.0.10.0/24"
  serviceSelector:
    matchLabels:
      color: green

三、 通过注释获取特定ip的方式(k8s 1.24弃用)并且同时存在CiliumLoadBalancerIPPool

复制代码
apiVersion: v1
kind: Service
metadata:
  name: service-yellow
  namespace: tenant-c
  labels:
    color: yellow
  annotations:
    "io.cilium/lb-ipam-ips": "30.0.10.100,40.0.10.100,50.0.10.100,60.0.10.100"
spec:
  type: LoadBalancer
  ports:
    - port: 1234

root@server:~# yq pool-yellow.yaml
# Namespace selector
apiVersion: "cilium.io/v2alpha1"
kind: CiliumLoadBalancerIPPool
metadata:
  name: "pool-yellow"
spec:
  blocks:
    - cidr: "50.0.10.0/24"
  serviceSelector:
    matchLabels:
      "io.kubernetes.service.namespace": "tenant-c"

root@server:~# kubectl get svc/service-yellow -n tenant-c
NAME             TYPE           CLUSTER-IP     EXTERNAL-IP               PORT(S)          AGE
service-yellow   LoadBalancer   10.96.76.161   50.0.10.100,60.0.10.100   1234:32555/TCP   11s

*会同时获取到两个地址

Note that the Service was allocated two of the requested IP addresses:

  • 50.0.10.100 because it matches the namespace (tenant-c).
  • 60.0.10.100 because it matches the primary colours labels.

第一个地址匹配SVC。

第二个地址匹配CiliumLoadBalancerIPPool。

相关推荐
bantinghy19 分钟前
Linux系统TCP/IP网络参数优化
linux·网络·tcp/ip
Delphi菜鸟1 小时前
docker 部署RustDesk服务
运维·docker·容器
Sweety丶╮7941 小时前
【Kubernetes】知识点总结5
云原生·容器·kubernetes
wanhengidc1 小时前
云手机可以息屏挂手游吗?
运维·网络·安全·游戏·智能手机
一只小白菜~2 小时前
实战记录:H3C路由器IS-IS Level-1邻居建立与路由发布
运维·网络·计算机网络·智能路由器
kenwm2 小时前
家庭网络异常降速问题排查处理方案
网络·智能路由器
今晚务必早点睡2 小时前
从零到上线:Docker、Docker Compose 与 Runtime 安装部署全指南(含实战示例与应用场景)
运维·docker·容器
搬码临时工2 小时前
使用自定义固定公网URL地址远程访问公司内网OA办公系统,本地无需公网IP和专线让外网访问
网络·网络协议·tcp/ip
zyplanke4 小时前
Kubernetes(四):Service
云原生·容器·kubernetes·k8s
星马梦缘4 小时前
计算机网络6 第六章 应用层——解决“怎么发请求、怎么回响应”的问题(邮件整体传输流程)
网络·计算机网络·域名·ftp·dns·dhcp