Managing StatefulSets with Static Pod IP Addresses

Last updated: 2020-04-01 17:41:33

    Operation Scenario

    To deploy applications in TKE and use static pod IP addresses, you can use StatefulSets with static IP addresses. Tencent Cloud TKE supports this type of StatefulSets that create pods with IP addresses in an actual VPC instance assigned through ENIs. TKE’s VPC-CNI plugin assigns IP addresses that do not change after pods are restarted or migrated.
    By using StatefulSets with static IP addresses, you can:

    • Authorize through source IP addresses.
    • Review processes based on IP addresses.
    • Query logs based on pod IP addresses.

    Note that when StatefulSets with static IP addresses are used, static IPs survive only within the lifecycle of their StatefulSets.


    You have enabled the VPC-CNI mode for the cluster. For more information, see Enabling the VPC-CNI Mode for a Cluster.


    Using the console

    1. Log in to the TKE console and go to the management page of the cluster.
    2. Select the ID or name of the cluster that you want to view to go to the cluster management page.
    3. Choose Workload > StatefulSet to go to the cluster management page of StatefulSet.
    4. Click Create to view Number of Pods, as shown below:
    5. Click Advanced Settings and set the StatefulSet parameters as needed. The key parameters are as follows:
      Create a StatefulSet
      • Network mode: select Use VPC-CNI mode.
      • IP address range: currently, only the Random value is supported.
      • Static pod IP: select Enable.

    YAML sample

    apiVersion: apps/v1beta1
    kind: StatefulSet
    annotations: "true"
    name: busybox
    serviceName: "busybox"
    replicas: 3
    annotations: "tke-route-eni"
    app: busybox
    terminationGracePeriodSeconds: 0
    - name: busybox
    image: busybox
    command: ["sleep", "10000000000"]
    requests: "1"
    limits: "1"
    • metadata.annotations: to create StatefulSets with static IP addresses, you need to set annotations, that is,
    • spec.template.annotations: to create pods in VPC-CNI mode, you need to set annotations, that is,
    • spec.template.spec.containers.0.resources: to create pods in VPC-CNI mode, you need to add limits on "requests" and "limits", that is,

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback