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。

相关推荐
灼烧的疯狂14 分钟前
K8S + Jenkins 做CICD
容器·kubernetes·jenkins
wenyue11211 小时前
Revolutionize Your Kubernetes Experience with Easegress: Kubernetes Gateway API
容器·kubernetes·gateway
hakesashou1 小时前
Python中常用的函数介绍
java·网络·python
C++忠实粉丝2 小时前
计算机网络socket编程(4)_TCP socket API 详解
网络·数据结构·c++·网络协议·tcp/ip·计算机网络·算法
九州ip动态2 小时前
做网络推广及游戏注册为什么要换IP
网络·tcp/ip·游戏
Estar.Lee2 小时前
时间操作[取当前北京时间]免费API接口教程
android·网络·后端·网络协议·tcp/ip
蝶开三月2 小时前
php:使用socket函数创建WebSocket服务
网络·websocket·网络协议·php·socket
G丶AEOM2 小时前
SSL/TLS,SSL,TLS分别是什么
网络·网络协议·网络安全
儒道易行2 小时前
【DVWA】RCE远程命令执行实战
网络·安全·网络安全
Koi慢热3 小时前
路由基础(全)
linux·网络·网络协议·安全