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。

相关推荐
alden_ygq35 分钟前
Kubernetes容器运行时:Containerd vs Docker
docker·容器·kubernetes
努力搬砖 ing42 分钟前
Docker疑难杂症解决指南
docker·容器·eureka
Hello.Reader2 小时前
ngx_http_limit_conn_module精准连接控制
网络·网络协议·http
qq_386322693 小时前
华为网路设备学习-21 IGP路由专题-路由过滤(filter-policy)
前端·网络·学习
张青贤4 小时前
K8s中的containerPort与port、targetPort、nodePort的关系:
云原生·容器·kubernetes
云攀登者-望正茂6 小时前
AKS 支持 Kata Container容器沙盒 -预览阶段
容器·azure
撸码到无法自拔8 小时前
docker常见命令
java·spring cloud·docker·容器·eureka
firshman_start10 小时前
第十五章,SSL VPN
网络
Johnstons10 小时前
AnaTraf:深度解析网络性能分析(NPM)
前端·网络·安全·web安全·npm·网络流量监控·网络流量分析
落——枫10 小时前
路由交换实验
网络