网络相关
弹性网卡
如果集群网络模式是 Global Router,且启用了 VPC-CNI (两种模式混用),Pod 调度到普通节点默认使用 Global Router 模式,如需要 Pod 用 VPC-CNI (弹性网卡),需显式指定:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
annotations:
tke.cloud.tencent.com/networks: tke-route-eni
spec:
containers:
- name: nginx
image: nginx:latest
resources:
requests:
tke.cloud.tencent.com/eni-ip: "1"
limits:
tke.cloud.tencent.com/eni-ip: "1"
EIP
更详细的说明请参考 Pod 绑 EIP。
声明使用 EIP
- 标准集群写法
- Serverless 集群写法
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
annotations:
tke.cloud.tencent.com/networks: "tke-route-eni" # 如果集群网络是 GlobalRouter + VPC-CNI 混用,用此注解需要显式指定 Pod 使用 VPC-CNI
# 指定 EIP 属性,具体字段参考 CLB 的 AllocateAddresses 接口文档:https://cloud.tencent.com/document/api/215/16699#2.-.E8.BE.93.E5.85.A5.E5.8F.82.E6.95.B0
tke.cloud.tencent.com/eip-attributes: '{"Bandwidth":"100", "ISP":"BGP", "InternetMaxBandwidthOut":50, "InternetChargeType":"TRAFFIC_POSTPAID_BY_HOUR"}'
spec:
containers:
- name: nginx
image: nginx:latest
resources: # 声明 EIP 资源,用于调度 (节点能绑定的 EIP 数量有限)
limits:
tke.cloud.tencent.com/eni-ip: "1"
tke.cloud.tencent.com/eip: "1"
requests:
tke.cloud.tencent.com/eni-ip: "1"
tke.cloud.tencent.com/eip: "1"
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
annotations:
# 指定 EIP 属性,具体字段参考 CLB 的 AllocateAddresses 接口文档:https://cloud.tencent.com/document/api/215/16699#2.-.E8.BE.93.E5.85.A5.E5.8F.82.E6.95.B0
eks.tke.cloud.tencent.com/eip-attributes: '{"Bandwidth":"100", "ISP":"BGP", "InternetMaxBandwidthOut":50, "InternetChargeType":"TRAFFIC_POSTPAID_BY_HOUR"}'
spec:
containers:
- name: nginx
image: nginx:latest
保留 EIP
- 标准集群写法
- Serverless 集群写法
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app: nginx
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
serviceName: ""
template:
metadata:
annotations:
tke.cloud.tencent.com/networks: "tke-route-eni" # 如果集群网络是 GlobalRouter + VPC-CNI 混用,用此注解需要显式指定 Pod 使用 VPC-CNI
# 指定 EIP 属性,具体字段参考 CLB 的 AllocateAddresses 接口文档:https://cloud.tencent.com/document/api/215/16699#2.-.E8.BE.93.E5.85.A5.E5.8F.82.E6.95.B0
tke.cloud.tencent.com/eip-attributes: '{"Bandwidth":"100", "ISP":"BGP", "InternetMaxBandwidthOut":50, "InternetChargeType":"TRAFFIC_POSTPAID_BY_HOUR"}'
tke.cloud.tencent.com/eip-claim-delete-policy: "Never"
labels:
app: nginx
spec:
containers:
- image: nginx
name: nginx
resources:
limits:
tke.cloud.tencent.com/eni-ip: "1"
tke.cloud.tencent.com/eip: "1"
requests:
tke.cloud.tencent.com/eni-ip: "1"
tke.cloud.tencent.com/eip: "1"
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app: nginx
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
serviceName: ""
template:
metadata:
annotations:
tke.cloud.tencent.com/networks: "tke-route-eni" # 如果集群网络是 GlobalRouter + VPC-CNI 混用,用此注解需要显式指定 Pod 使用 VPC-CNI
# 指定 EIP 属性,具体字段参考 CLB 的 AllocateAddresses 接口文档:https://cloud.tencent.com/document/api/215/16699#2.-.E8.BE.93.E5.85.A5.E5.8F.82.E6.95.B0
tke.cloud.tencent.com/eip-attributes: '{"Bandwidth":"100", "ISP":"BGP", "InternetMaxBandwidthOut":50, "InternetChargeType":"TRAFFIC_POSTPAID_BY_HOUR"}'
eks.tke.cloud.tencent.com/eip-claim-delete-policy: "Never" # 声明要保留 EIP(Pod 重建后保持 EIP 不变),仅支持有状态工作负载,如 StatefulSet
labels:
app: nginx
spec:
containers:
- image: nginx
name: nginx
resources:
limits:
tke.cloud.tencent.com/eni-ip: "1"
tke.cloud.tencent.com/eip: "1"
requests:
tke.cloud.tencent.com/eni-ip: "1"
tke.cloud.tencent.com/eip: "1"