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。

相关推荐
余~1853816280024 分钟前
矩阵系统源码搭建,OEM贴牌技术
网络·人工智能·线性代数·算法·矩阵
小麦黑客笔记1 小时前
2024年最新自学手册 -网络安全(黑客技术)
开发语言·网络·安全·web安全·网络安全
沫夕残雪2 小时前
网络编程及回显服务器
网络·tcp/ip·java-ee·intellij-idea·信息与通信
CloudJourney2 小时前
初始Docker
运维·docker·容器
ZVAyIVqt0UFji2 小时前
云舟观测:基于eBPF监控主机的TCP网络连接
网络·网络协议·tcp/ip·web安全·php
AI原吾3 小时前
构建灵活、高效的HTTP/1.1应用:探索h11库
网络·python·网络协议·http·ai·h11
看山还是山,看水还是。3 小时前
Nginx 的 Http 模块介绍(中)
android·运维·网络·nginx·http
Tony聊跨境3 小时前
什么是 HTTP 代理?它如何工作?
网络·http·ip
licy__3 小时前
计算机网络期末考试试卷及答案
网络