Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add worker node to the cluster #93

Merged
merged 1 commit into from
Jan 14, 2025
Merged

feat: add worker node to the cluster #93

merged 1 commit into from
Jan 14, 2025

Conversation

dkeven
Copy link
Collaborator

@dkeven dkeven commented Jan 6, 2025

two node-related commands are added:

  • olares-cli node masterinfo for getting information about a target master node, and checks whether current node can be added to the cluster.
  • olares-cli node add for adding current node to the Kubernetes cluster as a worker node.

both commands share a same set of options that specify how to access the master node by SSH:

option explain required default
master-host the IP address of the master node true
master-node-name the Kubernetes node name of the master node false false
master-ssh-user the Linux user name to login to the master node by SSH false root
master-ssh-password the password of the Linux user true for non-root master-ssh-user
master-ssh-private-key-path the private SSH key to authenticate as the Linux user false $HOME/.ssh/id_rsa
master-ssh-port the listening port of the SSH service on the master node false 22

some changes at the framework level is made, to make it possible to operate on two nodes simultaneously, in order to add worker node:

previously, in 7725447 and a550861:

a RemoteTask is made effectively the same as a LocalTask in that it does not use a SSH connection:

func (t *RemoteTask) ConfigureSelfRuntime(runtime connector.Runtime, host connector.Host, index int) error {
// var conn connector.Connection
// var err error
// if !host.GetMinikube() {
// conn, err = runtime.GetConnector().Connect(host)
// if err != nil {
// return errors.Wrapf(err, "failed to connect to %s", host.GetAddress())
// }
// }
r := &connector.Runner{
Conn: nil,
//Debug: runtime.Arg.Debug,
Host: host,
Index: index,
}
runtime.SetRunner(r)
return nil
}

and all remote commands (via SSH connection by runtime.GetRunner().Cmd()) are changed to run locally (by runtime.GetRunner().Host.Cmd())

these changes are partially reverted and partially merged into the original code, specifically, RemoteTask and LocalTask are made more interchangeable by:

  • when initiating a RemoteTask, if the target host is not the local machine, a SSH connection is established, otherwise a nil connection is passed to the Runner, indicating it's running on a local machine
  • when initiating a LocalTask, a real host is fetched from the runtime's host map first, instead of the current dummy localhost, to retain the host's roles
  • when calling methods like runtime.GetRunner().Cmd(), the Runner's connection field is checked, if one exists, the SSH connection is used to execute the command, otherwise, the command is passed to Runner's host to execute locally.
  • all runtime.GetRunner().Host.Cmd() is changed back to runtime.GetRunner().Cmd()
  • when calling methods like runtime.GetRunner().SudoCmd(), the host's user is checked, a sudo prefix is added to the command only if the user is not root

some other module level changes are made to adjust the new cases for a worker node, when it needs to install JuiceFS based on a remote Redis server, and when the storage and K8s services need reconfiguration when its IP changes.

a new option --new-master-host is added to the change-ip command, to handle the case where a master node's IP address has changed, but the worker node has no way to automatically know it.

@dkeven dkeven requested review from aby913 and eball January 6, 2025 06:30
@dkeven dkeven enabled auto-merge (squash) January 6, 2025 06:30
@github-actions github-actions bot added the feat label Jan 6, 2025
@dkeven dkeven force-pushed the feat/add_node branch 7 times, most recently from ba6f877 to db51532 Compare January 10, 2025 13:48
@dkeven dkeven force-pushed the feat/add_node branch 3 times, most recently from a33c70e to 2393b33 Compare January 14, 2025 11:21
@dkeven dkeven disabled auto-merge January 14, 2025 12:36
@dkeven dkeven merged commit 6ef874c into main Jan 14, 2025
1 check passed
@dkeven dkeven deleted the feat/add_node branch January 14, 2025 12:36
dkeven added a commit that referenced this pull request Jan 15, 2025
dkeven added a commit that referenced this pull request Jan 16, 2025
dkeven added a commit that referenced this pull request Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants