This mode is suitable for scenarios that rely on static container IP addresses. For example, migration from a traditional architecture to a container platform and security policy restrictions on IP addresses. It is not recommended to use the static IP address mode for services without IP limits.
You can enable the static IP address using either of the following methods:
If you use this method to enable VPC-CNI and create a workload on the console or using YAML, the pods all use ENIs by default.
- GlobalRouter VPC-CNI Mode with static IP address, that is, when creating a cluster, select the Global Router network plug-in. On the basic information page of the cluster, enable the VPC-CNI mode (by default, both modes are enabled).
- If you use this method to enable VPC-CNI, the pods do not use ENIs by default.
- In static-IP scenarios, after enabling VPC-CNI, you need to set the IP reclaiming policy, which specifies how long after pods are terminated their IP addresses are returned.
- Pods with non-static IP addresses are not affected by these settings because their IP addresses are immediately released upon pod termination.
- Click Submit.
In GlobalRouter VPC-CNI Mode, to deploy applications in 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:
When StatefulSets with static IP addresses are used, the static IP addresses survive only within the lifecycle of their StatefulSets.
You can create the static IP address using either of the following methods:
Creating StatefulSets with Static IP Addresses on TKE console
Creating using YAML
apiVersion: apps/v1 kind: StatefulSet metadata: 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/networks: "tke-route-eni" 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/networks: "tke-route-eni"indicates that the Pod uses the VPC-CNI mode with shared ENI. If you are using the VPC-CNI mode with independent ENI, please modify the value to
tke.cloud.tencent.com/vpc-ip-claim-delete-policy. The default value is “Immediate”. After a pod is terminated, the associated IP address is also terminated. To use a static IP address, set it to “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. If you are using the VPC-CNI mode with independent ENI, add