Skip to content

Commit

Permalink
Library based ssh (#1209)
Browse files Browse the repository at this point in the history
* chore: Vendoring commit

Signed-off-by: aerosouund <[email protected]>

* feat: Introduce SSH package

The package provides simple interface for SSH to specific node and implementation of this interface.
The implementation is based on std ssh package and we use the SSH port exposed on master node.
Jump is used to SSH to other nodes.

Signed-off-by: aerosouund <[email protected]>

* feat: Create DockerAdapter type

The DockerAdapter type changes the previously used docker.Exec ssh.sh method and conforms it into the SSHClient interface. By taking the command and modifying it to be runnable with ssh.sh based on whether its a script, script with params or direct binary command.
The node container field indicates the name of the container that ran the qemu command that corresponds to the target ssh node

Signed-off-by: aerosouund <[email protected]>

* refactor: Use DockerAdapter in place of docker.Exec

Keep ssh in a single place by leveraging the adapter and passing it as a param for functions that did docker exec themselves; prepareDeviceForAssignment and prepareEtcdDataMount.
Replace the logic for checking if there's a special provision script for a node to running the script for node01 at index 1

Signed-off-by: aerosouund <[email protected]>

* feat: Create the config package

The config package introduces holder structs that contain the params for a node and the k8s optional deployments on a kubevirt provider. To pass this config directly to other methods without having to pass every parameter to the functions that run the node or k8s options

Signed-off-by: aerosouund <[email protected]>

* refactor: Introduce provisionNode and provisionK8sOptions

Package the logic of node launching and configuring its linux system into provisionNode and running the optional k8s deployments into provisionK8sOptions.
Both functions take as a parameter an ssh client and a struct that represents a holder to their config from the config package

Signed-off-by: aerosouund <[email protected]>

* test: Testing logic for ssh

Introduce a testing package based on mock that tests the provisionNode and provisionK8sOptions methods and include the logic to run this package in the main test suite of the cmd package

Signed-off-by: aerosouund <[email protected]>

* refactor: Leverage the ssh client in favor of Docker adapter

Use an implementation based on ssh'ing directly to nodes rather than through their node container.
Move the scripts directory on the node during provisioning and remove it after finishing

Signed-off-by: aerosouund <[email protected]>

---------

Signed-off-by: aerosouund <[email protected]>
  • Loading branch information
aerosouund authored Jul 16, 2024
1 parent c43f010 commit aa7d876
Show file tree
Hide file tree
Showing 52 changed files with 14,730 additions and 189 deletions.
2 changes: 1 addition & 1 deletion cluster-provision/gocli/cmd/cmd_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd_test
package cmd

import (
"testing"
Expand Down
54 changes: 54 additions & 0 deletions cluster-provision/gocli/cmd/nodesconfig/nodeconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package nodesconfig

// NodeLinuxConfig type holds the config params that a node can have for its linux system
type NodeLinuxConfig struct {
NodeIdx int
K8sVersion string
FipsEnabled bool
DockerProxy string
EtcdInMemory bool
EtcdSize string
SingleStack bool
EnableAudit bool
GpuAddress string
Realtime bool
PSA bool
}

// NodeK8sConfig type holds the config k8s options for kubevirt cluster
type NodeK8sConfig struct {
Ceph bool
Prometheus bool
Alertmanager bool
Grafana bool
Istio bool
NfsCsi bool
}

func NewNodeK8sConfig(ceph, prometheus, alertmanager, grafana, istio, nfsCsi bool) *NodeK8sConfig {
return &NodeK8sConfig{
Ceph: ceph,
Prometheus: prometheus,
Alertmanager: alertmanager,
Grafana: grafana,
Istio: istio,
NfsCsi: nfsCsi,
}
}

func NewNodeLinuxConfig(nodeIdx int, k8sVersion, dockerProxy, etcdSize, gpuAddress string,
fipsEnabled, etcdInMemory, singleStack, enableAudit, realtime, psa bool) *NodeLinuxConfig {
return &NodeLinuxConfig{
NodeIdx: nodeIdx,
K8sVersion: k8sVersion,
FipsEnabled: fipsEnabled,
DockerProxy: dockerProxy,
EtcdInMemory: etcdInMemory,
EtcdSize: etcdSize,
SingleStack: singleStack,
EnableAudit: enableAudit,
GpuAddress: gpuAddress,
Realtime: realtime,
PSA: psa,
}
}
Loading

0 comments on commit aa7d876

Please sign in to comment.