kubesphere / kubekey

Install Kubernetes/K3s only, both Kubernetes/K3s and KubeSphere, and related cloud-native add-ons, it supports all-in-one, multi-node, and HA 🔥 ⎈ 🐳
https://kubesphere.io
Apache License 2.0
2.18k stars 518 forks source link

feat: add CustomScripts.Role property #2220

Closed will4j closed 1 month ago

will4j commented 2 months ago

What type of PR is this?

/kind feature

What this PR does / why we need it:

Support custom scripts executing on some specfic nodes when creating a cluster, make kubekey more flexible for different scenes.

Take examples below:

apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
  name: dubhe-open-cluster
spec:
  hosts:
    - { name: master, address: 192.168.10.1, internalAddress: 192.168.10.1, user: ubuntu, password: "ubuntu" }
    - { name: storage, address: 192.168.10.2, internalAddress: 192.168.10.2, user: ubuntu, password: "ubuntu" }
  roleGroups:
    control-plane:
      -  master
    nfs-server:
      - storage
  system:
    preInstall:
      - name: install nfs server
        # new added `role` property
        role: nfs-server
        bash: /bin/bash -x install_nfs_server.sh
        materials:
          - ./scripts/install_nfs_server.sh

preInstall script 'install nfs server' will only executed at storage node.

Which issue(s) this PR fixes:

Fixes #

Special notes for reviewers:

Does this PR introduced a user-facing change?

Add new optional property `role` for CustomScripts to let custom scripts like `PreInstall` only executed at specific nodes.

Additional documentation, usage docs, etc.:

will4j commented 2 months ago

/assign @pixiake

pixiake commented 1 month ago

@will4j Thanks for this contributions ! /lgtm /approve

ks-ci-bot commented 1 month ago

LGTM label has been added.

Git tree hash: e12a56a74e979d48aa686bd1426d5792ca5fe9df

ks-ci-bot commented 1 month ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pixiake, will4j

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: - ~~[OWNERS](https://github.com/kubesphere/kubekey/blob/master/OWNERS)~~ [pixiake] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment