To deploy applications in Tencent Kubernetes Engine (TKE) and use static pod IP addresses, you can use StatefulSets with static IP addresses. Pods created by this type of StatefulSet are assigned with an IP in an actual VPC through ENIs. TKE's VPC-CNI plugin assigns IP addresses. The IP addresses remain unchanged after pods are restarted or migrated.
By using StatefulSets with static IP addresses, you can:
Note:
When StatefulSets with static IP addresses are used, the static IP addresses survive only within the lifecycle of their StatefulSets.
You have enabled the VPC-CNI mode for your cluster. For more information, please see Enabling VPC-CNI for a Cluster.
apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations:
tke.cloud.tencent.com/enable-static-ip: "true"
labels:
k8s-app: busybox
name: busybox
namespace: default
spec:
replicas: 3
selector:
matchLabels:
k8s-app: busybox
qcloud-app: busybox
serviceName: ""
template:
metadata:
annotations:
tke.cloud.tencent.com/vpc-ip-claim-delete-policy: Never
creationTimestamp: null
labels:
k8s-app: busybox
qcloud-app: busybox
spec:
containers:
- args:
- "10000000000"
command:
- sleep
image: busybox
imagePullPolicy: Always
name: busybox
resources:
limits:
tke.cloud.tencent.com/eni-ip: "1"
requests:
tke.cloud.tencent.com/eni-ip: "1"
tke.cloud.tencent.com/enable-static-ip
.tke.cloud.tencent.com/networks
.Immediate
. After a pod is terminated, the associated IP address is also terminated.Never
. After a pod is terminated, the associated IP address will be retained. When a pod with the same name as the terminated pod is pulled the next time, the original IP address is used.tke.cloud.tencent.com/eni-ip
.
Was this page helpful?