更新时间:2025-10-31 GMT+08:00
Pod指定子网配置
操作场景
如果Pod的网络配置包含多个子网时,支持通过Annotation(yangtse.io/subnets)配置Pod创建后使用的子网。
约束与限制
- Pod指定的子网最多不能超过20个。
- Pod指定的子网必须包含在 Pod网络配置(network)资源内,不能随意指定。
- 可以支持为Pod配置单个或者多个子网,多个子网使用逗号 (,) 分隔。
- 必须保证指定的子网下存在空闲的IP地址,否则会因为IP不足导致Pod创建失败。
通过ccictl命令行设置
您可以通过对工作负载添加annotations控制Pod使用的子网,如下所示。
apiVersion: cci/v2
kind: Deployment
metadata:
annotations:
description: ''
labels: {}
name: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
annotations:
vm.cci.io/pod-size-specs: 2.00_4.0
resource.cci.io/pod-size-specs: 2.00_4.0
metrics.alpha.kubernetes.io/custom-endpoints: '[{api:'''',path:'''',port:'''',names:''''}]'
yangtse.io/subnets: ${subnetID1},${subnetID2} # Pod指定子网
log.stdoutcollection.kubernetes.io: '{"collectionContainers": ["container-0"]}'
labels:
app: nginx
spec:
containers:
- image: library/nginx:stable-alpine-perl
name: container-0
resources:
limits:
cpu: 2000m
memory: 4096Mi
requests:
cpu: 2000m
memory: 4096Mi
command: []
lifecycle: {}
dnsPolicy: ''
imagePullSecrets:
- name: imagepull-secret
dnsConfig: {}
minReadySeconds: 0
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
yangtse.io/subnets:Pod需要配置的子网ID。