tencent cloud

Feedback

Declarative Operation Practice

Last updated: 2023-02-03 10:54:17

    Operations Supported by Kubectl

    CRD Type Operation
    MachineSet Creating a native node pool
    `kubectl create -f machineset-demo.yaml`
    Viewing the list of nodes in the native node pool
    `kubectl get machineset`
    Viewing YAML details of a native node pool
    `kubectl describe ms machineset-name`
    Deleting a native node pool
    `kubectl delete ms machineset-name`
    Scaling out a native node pool
    `kubectl scale --replicas=3 machineset/machineset-name`
    Machine Viewing native nodes
    `kubectl get machine`
    Viewing the YAML details of a native node
    `kubectl describe ma machine-name`
    Deleting a native node
    `kubectl delete ma machine-name`
    HealthCheckPolicy Creating a fault self-healing rule
    `kubectl create -f demo-HealthCheckPolicy.yaml`
    Viewing the fault self-healing rule list
    `kubectl kubectl get HealthCheckPolicy`
    Viewing the YAML details of a fault self-healing rule
    `kubectl describe HealthCheckPolicy HealthCheckPolicy-name`
    Deleting a fault self-healing rule
    `kubectl delete HealthCheckPolicy HealthCheckPolicy-name`

    Using CRD via YAML

    MachineSet

    apiVersion: node.tke.cloud.tencent.com/v1beta1
    kind: MachineSet
    spec:
     type: Native
     displayName: mstest
     replicas: 2
     autoRepair: true
     deletePolicy: Random
     healthCheckPolicyName: test-all
     instanceTypes:
     - C3.LARGE8
     subnetIDs:
     - subnet-xxxxxxxx
     - subnet-yyyyyyyy
     scaling:
       createPolicy: ZonePriority
       maxReplicas: 100
     template:
       spec:
         displayName: mtest
         runtimeRootDir: /var/lib/containerd
         unschedulable: false
         metadata:
           labels:
             key1: "val1"
             key2: "val2"
         providerSpec:
           type: Native
           value:
             instanceChargeType: PostpaidByHour
             lifecycle:
               preInit: "echo hello"
               postInit: "echo world"
             management:
               hosts:
               - Hostnames:
                 - lkongtest
                 IP: 22.22.22.22
               nameservers:
               - 183.60.83.19
               - 183.60.82.98
               - 8.8.8.8
             metadata:
               creationTimestamp: null
             securityGroupIDs:
             - sg-xxxxxxxx
             systemDisk:
               diskSize: 50
               diskType: CloudPremium
    

    Kubectl Operation Demo

    MachineSet

    1. Run the kubectl create -f machineset-demo.yaml command to create a MachineSet based on the preceding YAML file:

    2. Run the kubectl get machineset command to view the status of the MachineSet np-pjrlok3w. At this time, the corresponding node pool already exists in the console, and its node is being created:

    1. Run the kubectl describe machineset np-pjrlok3w command to view the description of the MachineSet np-pjrlok3w:

    2. Run the kubectl scale --replicas=2 machineset/np-pjrlok3w command to scale in the node pool:

    3. Run the kubectl delete ms np-pjrlok3w command to delete the node pool.

    Machine

    1. Run the kubectl get machine command to view the machine list. At this time, the corresponding nodes already exist in the console:

    2. Run the kubectl describe ma np-14024r66-nv8bk command to check the description of the machine np-14024r66-nv8bk:

    3. Run the kubectl delete ma np-14024r66-nv8bk command to delete the node.

    Note:

    • If you delete the node directly without adjusting the expected number of nodes in the node pool, the node pool will create a new node to join the node pool when detecting that the actual number of nodes does not meet the declarative number of nodes. The recommended way to delete a node is as follows:
      1. Run the kubectl scale --replicas=1 machineset/np-xxxxx command to adjust the expected number of nodes.
      2. Run the kubectl delete machine np-xxxxxx-dtjhd command to delete the corresponding node.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support