kubekey icon indicating copy to clipboard operation
kubekey copied to clipboard

fix: support scaling up/down etcd

Open redscholar opened this issue 3 months ago • 3 comments

What type of PR is this?

/kind feature

What this PR does / why we need it:

Should support etcd scaling:

  • scaling up etcd:
  1. Define the etcd nodes in inventory.yaml.
apiVersion: kubekey.kubesphere.io/v1
kind: Inventory
metadata:
  name: default
spec:
  hosts: # your can set all nodes here. or set nodes on special groups.
    node1:
      connector:
        host: 172.16.66.7
      internal_ipv4: 172.16.66.7
    node2:
      connector:
        host: 172.16.66.3
      internal_ipv4: 172.16.66.3
    node3:
      connector:
        host: 172.16.66.4
      internal_ipv4: 172.16.66.4
  groups:
    # all kubernetes nodes.
    k8s_cluster:
      groups:
        - kube_control_plane
        - kube_worker
    # control_plane nodes
    kube_control_plane:
      hosts:
        - node1
    # worker nodes
    kube_worker:
      hosts:
        - node1
    # etcd nodes when etcd_deployment_type is external
    etcd:
      hosts:
        - node1
  1. Create cluster by this inventory.yaml kk create cluster -i inventory.yaml
  2. Add etcd node in inventory.yaml
apiVersion: kubekey.kubesphere.io/v1
kind: Inventory
metadata:
  name: default
spec:
  hosts: # your can set all nodes here. or set nodes on special groups.
    node1:
      connector:
        host: 172.16.66.7
      internal_ipv4: 172.16.66.7
    node2:
      connector:
        host: 172.16.66.3
      internal_ipv4: 172.16.66.3
    node3:
      connector:
        host: 172.16.66.4
      internal_ipv4: 172.16.66.4
  groups:
    # all kubernetes nodes.
    k8s_cluster:
      groups:
        - kube_control_plane
        - kube_worker
    # control_plane nodes
    kube_control_plane:
      hosts:
        - node1
        - node2
        - node3
    # worker nodes
    kube_worker:
      hosts:
        - node1
        - node2
        - node3
    # etcd nodes when etcd_deployment_type is external
    etcd:
      hosts:
        - node1
        - node2
        - node3
  1. Scaling up etcd. kk add nodes -i inventory.yaml
  • scaling down etcd:
  1. Define the etcd nodes in inventory.yaml.
apiVersion: kubekey.kubesphere.io/v1
kind: Inventory
metadata:
  name: default
spec:
  hosts: # your can set all nodes here. or set nodes on special groups.
    node1:
      connector:
        host: 172.16.66.7
      internal_ipv4: 172.16.66.7
    node2:
      connector:
        host: 172.16.66.3
      internal_ipv4: 172.16.66.3
    node3:
      connector:
        host: 172.16.66.4
      internal_ipv4: 172.16.66.4
  groups:
    # all kubernetes nodes.
    k8s_cluster:
      groups:
        - kube_control_plane
        - kube_worker
    # control_plane nodes
    kube_control_plane:
      hosts:
        - node1
        - node2
        - node3
    # worker nodes
    kube_worker:
      hosts:
        - node1
        - node2
        - node3
    # etcd nodes when etcd_deployment_type is external
    etcd:
      hosts:
        - node1
        - node2
        - node3
  1. Create cluster by this inventory.yaml kk create cluster -i inventory.yaml
  2. Scaling down etcd kk delete nodes -i inventory.yaml node2 node3

test results

Which issue(s) this PR fixes:

Fixes # https://github.com/kubesphere/kubekey/issues/2728 https://github.com/kubesphere/kubekey/issues/2742

Special notes for reviewers:

Does this PR introduced a user-facing change?

fix: support scaling down etcd

Additional documentation, usage docs, etc.:


redscholar avatar Sep 23 '25 10:09 redscholar

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

sonarqubecloud[bot] avatar Sep 29 '25 08:09 sonarqubecloud[bot]

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: redscholar

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

kubesphere-prow[bot] avatar Nov 07 '25 07:11 kubesphere-prow[bot]

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

sonarqubecloud[bot] avatar Dec 04 '25 02:12 sonarqubecloud[bot]