From 19f402764b29ff3f0a8dbe02cce9acb8be0007c3 Mon Sep 17 00:00:00 2001 From: Andrew Lavery Date: Thu, 26 Oct 2023 07:47:35 -0600 Subject: [PATCH] do the remaining helmvm -> embedded-cluster renamings (#153) --- README.md | 27 +++--- cmd/embedded-cluster/install.go | 4 +- cmd/embedded-cluster/node.go | 6 +- cmd/embedded-cluster/shell.go | 2 +- cmd/embedded-cluster/upgrade.go | 4 +- e2e/cluster/cluster.go | 20 ++--- e2e/embed_test.go | 12 +-- e2e/install_test.go | 84 +++++++++---------- e2e/scripts/addons-only.sh | 2 +- e2e/scripts/embed-and-install.sh | 2 +- e2e/scripts/embedded-preflight.sh | 2 +- e2e/scripts/install-with-disabled-addons.sh | 2 +- .../interactive-multi-node-install.exp | 4 +- e2e/scripts/single-node-install.sh | 2 +- e2e/scripts/wait-for-ready-nodes.sh | 2 +- e2e/version_test.go | 12 +-- pkg/defaults/defaults.go | 20 ++--- pkg/defaults/provider.go | 22 ++--- pkg/defaults/provider_test.go | 6 +- pkg/goods/goods.go | 2 +- pkg/hembed/hembed.go | 6 +- pkg/logging/logging.go | 2 +- pkg/metrics/sender.go | 6 +- pkg/preflights/preflights.go | 4 +- pkg/prompts/prompts.go | 4 +- 25 files changed, 131 insertions(+), 128 deletions(-) diff --git a/README.md b/README.md index 73286faf0..98dba571d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ -# HelmVM platform +# Embedded Cluster platform -This repository houses a cluster installation prototype that utilizes the k0s and k0sctl platforms. It showcases an alternative approach to deploying clusters and serves as a starting point for further exploration and advancement. In HelmVM, all components and functionalities are consolidated into a single binary, this binary facilitates a streamlined cluster installation process, removing the need for external dependencies (rpms, debs, etc). Remote hosts are managed using SSH. +This repository houses a cluster installation prototype that utilizes the k0s and k0sctl platforms. +It showcases an alternative approach to deploying clusters and serves as a starting point for further exploration and advancement. +In Embedded Cluster, all components and functionalities are consolidated into a single binary, this binary facilitates a streamlined cluster installation process, removing the need for external dependencies (rpms, debs, etc). +Remote hosts are managed using SSH. -HelmVM includes by default the Kots Admin Console and the OpenEBS Storage provisioner, you can very easily embed your own Helm Chart to the binary. +Embedded Cluster includes by default the Kots Admin Console and the OpenEBS Storage provisioner, you can very easily embed your own Helm Chart to the binary. ## Building and running @@ -17,7 +20,7 @@ You can also build binaries for other architectures with the following targets: ## Single node deployment -To create a single node deployment you can upload the HelmVM binary to a Linux x86_64 machine and run: +To create a single node deployment you can upload the Embedded Cluster binary to a Linux x86_64 machine and run: ``` $ ./embedded-cluster install @@ -35,7 +38,7 @@ In this case, it's not necessary to execute this command exclusively on a Linux ## Deploying Individual Nodes -HelmVM also facilitates deploying individual nodes through the use of tokens, deviating from the centralized approach. +Embedded Cluster also facilitates deploying individual nodes through the use of tokens, deviating from the centralized approach. To follow this path, you need to exclude yourself from the centralized management facilitated via SSH. ### Installing a Multi-Node Setup using Token-Based Deployment @@ -73,18 +76,18 @@ Copy the command provided and run it on the server you wish to join to the clust server-1# embedded-cluster node join --role "controller" "" ``` -For this to function, you must ensure that the HelmVM binary is present on all nodes within the cluster. +For this to function, you must ensure that the Embedded Cluster binary is present on all nodes within the cluster. ### Upgrading clusters -If your installation employs centralized management, simply download the newer version of HelmVM and execute: +If your installation employs centralized management, simply download the newer version of Embedded Cluster and execute: ``` $ embedded-cluster apply ``` -For installations without centralized management, download HelmVM, upload it to each server in your cluster, and execute the following command as **root** on each server: +For installations without centralized management, download Embedded Cluster, upload it to each server in your cluster, and execute the following command as **root** on each server: ``` # embedded-cluster node upgrade @@ -116,14 +119,14 @@ ubuntu@ip-172-16-10-242:~/.embedded-cluster/etc$ ## Embedding your own Helm Chart -HelmVM allows you to embed your own Helm Charts so they are installed by default when the cluster is installed or updated. For sake of documenting this let's create a hypothetical scenario: you have a software called `rocks` that is packaged as a Helm Chart and is ready to be installed in any Kubernetes Cluster. +Embedded Cluster allows you to embed your own Helm Charts so they are installed by default when the cluster is installed or updated. For sake of documenting this let's create a hypothetical scenario: you have a software called `rocks` that is packaged as a Helm Chart and is ready to be installed in any Kubernetes Cluster. -Your Helm Chart is in a file called `rocks-1.0.0.tgz` and you already have a copy of HelmVM binary in your $PATH. To embed your Chart you can run: +Your Helm Chart is in a file called `rocks-1.0.0.tgz` and you already have a copy of mbedded Cluster binary in your $PATH. To embed your Chart you can run: ``` $ embedded-cluster embed --chart rocks-1.0.0.tgz --output rocks ``` -This command will create a binary called `rocks` in the current directory, this command is a copy of HelmVM binary with your Helm Chart embedded into it. You can then use the `rocks` binary to install a cluster that automatically deploys your `rocks-1.0.0.tgz` Helm Chart. +This command will create a binary called `rocks` in the current directory, this command is a copy of mbedded Cluster binary with your Helm Chart embedded into it. You can then use the `rocks` binary to install a cluster that automatically deploys your `rocks-1.0.0.tgz` Helm Chart. If you want to provide a customised `values.yaml` during the Helm Chart installation you can also embed it into the binary. You can do that with the following command: @@ -148,7 +151,7 @@ $ embedded-cluster embed \ ## Miscellaneous -HelmVM stores its data under `$HOME/.embedded-cluster` directory, you may want to create a backup of the directory, specially the `$HOME/.embedded-cluster/etc` directory. Inside the `$HOME/.embedded-cluster/etc` directory you will find the `k0sctl.yaml` and the `kubeconfig` files, the first is used when installing or upgrading a cluster and the latter is used when accessing the cluster with `kubectl` (a copy of `kubectl` is also kept under `$HOME/.embedded-cluster/bin` directory and you may want to include it into your PATH). +mbedded Cluster stores its data under `$HOME/.embedded-cluster` directory, you may want to create a backup of the directory, specially the `$HOME/.embedded-cluster/etc` directory. Inside the `$HOME/.embedded-cluster/etc` directory you will find the `k0sctl.yaml` and the `kubeconfig` files, the first is used when installing or upgrading a cluster and the latter is used when accessing the cluster with `kubectl` (a copy of `kubectl` is also kept under `$HOME/.embedded-cluster/bin` directory and you may want to include it into your PATH). If you want to use an already existing `k0sctl.yaml` configuration during the `install` command you can do so by using the `--config` flag. diff --git a/cmd/embedded-cluster/install.go b/cmd/embedded-cluster/install.go index 49c4ad1e8..88d028bc9 100644 --- a/cmd/embedded-cluster/install.go +++ b/cmd/embedded-cluster/install.go @@ -301,7 +301,7 @@ func runK0sctlApply(ctx context.Context) error { message = fmt.Sprintf("Phase: %s", message) return message } - bin := defaults.PathToHelmVMBinary("k0sctl") + bin := defaults.PathToEmbeddedClusterBinary("k0sctl") loading := pb.Start(pb.WithMask(mask)) defer func() { loading.Closef("Finished applying cluster configuration") @@ -317,7 +317,7 @@ func runK0sctlApply(ctx context.Context) error { // under a file called "kubeconfig" inside defaults.ConfigSubDir(). XXX File // is overwritten, no questions asked. func runK0sctlKubeconfig(ctx context.Context) error { - bin := defaults.PathToHelmVMBinary("k0sctl") + bin := defaults.PathToEmbeddedClusterBinary("k0sctl") cfgpath := defaults.PathToConfig("k0sctl.yaml") if _, err := os.Stat(cfgpath); err != nil { return fmt.Errorf("cluster configuration not found") diff --git a/cmd/embedded-cluster/node.go b/cmd/embedded-cluster/node.go index b2586d33b..748a17958 100644 --- a/cmd/embedded-cluster/node.go +++ b/cmd/embedded-cluster/node.go @@ -32,7 +32,7 @@ var nodeStopCommand = &cli.Command{ } kcfg := defaults.PathToConfig("kubeconfig") os.Setenv("KUBECONFIG", kcfg) - bin := defaults.PathToHelmVMBinary("kubectl") + bin := defaults.PathToEmbeddedClusterBinary("kubectl") cmd := exec.Command(bin, "drain", "--ignore-daemonsets", node) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr @@ -51,7 +51,7 @@ var nodeStartCommand = &cli.Command{ } kcfg := defaults.PathToConfig("kubeconfig") os.Setenv("KUBECONFIG", kcfg) - bin := defaults.PathToHelmVMBinary("kubectl") + bin := defaults.PathToEmbeddedClusterBinary("kubectl") cmd := exec.Command(bin, "uncordon", node) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr @@ -66,7 +66,7 @@ var nodeListCommand = &cli.Command{ Action: func(c *cli.Context) error { kcfg := defaults.PathToConfig("kubeconfig") os.Setenv("KUBECONFIG", kcfg) - bin := defaults.PathToHelmVMBinary("kubectl") + bin := defaults.PathToEmbeddedClusterBinary("kubectl") cmd := exec.Command(bin, "get", "nodes", "-o", "wide") cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr diff --git a/cmd/embedded-cluster/shell.go b/cmd/embedded-cluster/shell.go index 3d7c81347..cfb453e23 100644 --- a/cmd/embedded-cluster/shell.go +++ b/cmd/embedded-cluster/shell.go @@ -72,7 +72,7 @@ var shellCommand = &cli.Command{ config := fmt.Sprintf("export KUBECONFIG=%q\n", kcpath) _, _ = shellpty.WriteString(config) _, _ = io.CopyN(io.Discard, shellpty, int64(len(config)+1)) - bindir := defaults.HelmVMBinsSubDir() + bindir := defaults.EmbeddedClusterBinsSubDir() config = fmt.Sprintf("export PATH=\"$PATH:%s\"\n", bindir) _, _ = shellpty.WriteString(config) _, _ = io.CopyN(io.Discard, shellpty, int64(len(config)+1)) diff --git a/cmd/embedded-cluster/upgrade.go b/cmd/embedded-cluster/upgrade.go index 835b425f5..9d6583839 100644 --- a/cmd/embedded-cluster/upgrade.go +++ b/cmd/embedded-cluster/upgrade.go @@ -18,7 +18,7 @@ import ( "github.com/replicatedhq/embedded-cluster/pkg/prompts" ) -func stopHelmVM() error { +func stopEmbeddedCluster() error { cmd := exec.Command("k0s", "stop") stdout := bytes.NewBuffer(nil) stderr := bytes.NewBuffer(nil) @@ -121,7 +121,7 @@ var upgradeCommand = &cli.Command{ return err } logrus.Infof("Stopping %s", defaults.BinaryName()) - if err := stopHelmVM(); err != nil { + if err := stopEmbeddedCluster(); err != nil { err := fmt.Errorf("unable to stop: %w", err) metrics.ReportNodeUpgradeFailed(c.Context, err) return err diff --git a/e2e/cluster/cluster.go b/e2e/cluster/cluster.go index 5318ae80e..218043b01 100644 --- a/e2e/cluster/cluster.go +++ b/e2e/cluster/cluster.go @@ -43,14 +43,14 @@ func init() { // Input are the options passed in to the cluster creation plus some data // for internal consumption only. type Input struct { - Nodes int - SSHPublicKey string - SSHPrivateKey string - HelmVMPath string - Image string - network string - T *testing.T - id string + Nodes int + SSHPublicKey string + SSHPrivateKey string + EmbeddedClusterPath string + Image string + network string + T *testing.T + id string } // File holds information about a file that must be uploaded to a node. @@ -192,7 +192,7 @@ func CopyFilesToNode(in *Input, node string) { Mode: 0600, }, { - SourcePath: in.HelmVMPath, + SourcePath: in.EmbeddedClusterPath, DestPath: "/usr/local/bin/embedded-cluster", Mode: 0755, }, @@ -407,7 +407,7 @@ func CreateProfile(in *Input) { request := api.ProfilesPost{ Name: fmt.Sprintf("profile-%s", in.id), ProfilePut: api.ProfilePut{ - Description: fmt.Sprintf("HelmVM test cluster (%s)", in.id), + Description: fmt.Sprintf("Embedded Cluster test cluster (%s)", in.id), Config: map[string]string{ "raw.lxc": profileConfig, }, diff --git a/e2e/embed_test.go b/e2e/embed_test.go index ce59e96a4..719171690 100644 --- a/e2e/embed_test.go +++ b/e2e/embed_test.go @@ -9,12 +9,12 @@ import ( func AndInstall(t *testing.T) { t.Parallel() tc := cluster.NewTestCluster(&cluster.Input{ - T: t, - Nodes: 1, - Image: "ubuntu/jammy", - SSHPublicKey: "../output/tmp/id_rsa.pub", - SSHPrivateKey: "../output/tmp/id_rsa", - HelmVMPath: "../output/bin/embedded-cluster", + T: t, + Nodes: 1, + Image: "ubuntu/jammy", + SSHPublicKey: "../output/tmp/id_rsa.pub", + SSHPrivateKey: "../output/tmp/id_rsa", + EmbeddedClusterPath: "../output/bin/embedded-cluster", }) defer tc.Destroy() t.Log("installing ssh in node 0") diff --git a/e2e/install_test.go b/e2e/install_test.go index a66d5af5d..9c1aff978 100644 --- a/e2e/install_test.go +++ b/e2e/install_test.go @@ -9,12 +9,12 @@ import ( func TestSingleNodeInstallation(t *testing.T) { t.Parallel() tc := cluster.NewTestCluster(&cluster.Input{ - T: t, - Nodes: 1, - Image: "ubuntu/jammy", - SSHPublicKey: "../output/tmp/id_rsa.pub", - SSHPrivateKey: "../output/tmp/id_rsa", - HelmVMPath: "../output/bin/embedded-cluster", + T: t, + Nodes: 1, + Image: "ubuntu/jammy", + SSHPublicKey: "../output/tmp/id_rsa.pub", + SSHPrivateKey: "../output/tmp/id_rsa", + EmbeddedClusterPath: "../output/bin/embedded-cluster", }) defer tc.Destroy() t.Log("installing ssh on node 0") @@ -35,12 +35,12 @@ func TestSingleNodeInstallation(t *testing.T) { func TestSingleNodeInstallationRockyLinux8(t *testing.T) { t.Parallel() tc := cluster.NewTestCluster(&cluster.Input{ - T: t, - Nodes: 1, - Image: "rockylinux/8", - SSHPublicKey: "../output/tmp/id_rsa.pub", - SSHPrivateKey: "../output/tmp/id_rsa", - HelmVMPath: "../output/bin/embedded-cluster", + T: t, + Nodes: 1, + Image: "rockylinux/8", + SSHPublicKey: "../output/tmp/id_rsa.pub", + SSHPrivateKey: "../output/tmp/id_rsa", + EmbeddedClusterPath: "../output/bin/embedded-cluster", }) defer tc.Destroy() t.Log("installing ssh on node 0") @@ -62,12 +62,12 @@ func TestSingleNodeInstallationRockyLinux8(t *testing.T) { func TestSingleNodeInstallationDebian12(t *testing.T) { t.Parallel() tc := cluster.NewTestCluster(&cluster.Input{ - T: t, - Nodes: 1, - Image: "debian/12", - SSHPublicKey: "../output/tmp/id_rsa.pub", - SSHPrivateKey: "../output/tmp/id_rsa", - HelmVMPath: "../output/bin/embedded-cluster", + T: t, + Nodes: 1, + Image: "debian/12", + SSHPublicKey: "../output/tmp/id_rsa.pub", + SSHPrivateKey: "../output/tmp/id_rsa", + EmbeddedClusterPath: "../output/bin/embedded-cluster", }) defer tc.Destroy() t.Log("installing ssh on node 0") @@ -89,12 +89,12 @@ func TestSingleNodeInstallationDebian12(t *testing.T) { func TestSingleNodeInstallationCentos8Stream(t *testing.T) { t.Parallel() tc := cluster.NewTestCluster(&cluster.Input{ - T: t, - Nodes: 1, - Image: "centos/8-Stream", - SSHPublicKey: "../output/tmp/id_rsa.pub", - SSHPrivateKey: "../output/tmp/id_rsa", - HelmVMPath: "../output/bin/embedded-cluster", + T: t, + Nodes: 1, + Image: "centos/8-Stream", + SSHPublicKey: "../output/tmp/id_rsa.pub", + SSHPrivateKey: "../output/tmp/id_rsa", + EmbeddedClusterPath: "../output/bin/embedded-cluster", }) defer tc.Destroy() t.Log("installing ssh on node 0") @@ -117,12 +117,12 @@ func TestMultiNodeInteractiveInstallation(t *testing.T) { t.Parallel() t.Log("creating cluster") tc := cluster.NewTestCluster(&cluster.Input{ - T: t, - Nodes: 3, - Image: "ubuntu/jammy", - SSHPublicKey: "../output/tmp/id_rsa.pub", - SSHPrivateKey: "../output/tmp/id_rsa", - HelmVMPath: "../output/bin/embedded-cluster", + T: t, + Nodes: 3, + Image: "ubuntu/jammy", + SSHPublicKey: "../output/tmp/id_rsa.pub", + SSHPrivateKey: "../output/tmp/id_rsa", + EmbeddedClusterPath: "../output/bin/embedded-cluster", }) defer tc.Destroy() for i := range tc.Nodes { @@ -155,12 +155,12 @@ func TestMultiNodeInteractiveInstallation(t *testing.T) { func TestInstallWithDisabledAddons(t *testing.T) { t.Parallel() tc := cluster.NewTestCluster(&cluster.Input{ - T: t, - Nodes: 1, - Image: "ubuntu/jammy", - SSHPublicKey: "../output/tmp/id_rsa.pub", - SSHPrivateKey: "../output/tmp/id_rsa", - HelmVMPath: "../output/bin/embedded-cluster", + T: t, + Nodes: 1, + Image: "ubuntu/jammy", + SSHPublicKey: "../output/tmp/id_rsa.pub", + SSHPrivateKey: "../output/tmp/id_rsa", + EmbeddedClusterPath: "../output/bin/embedded-cluster", }) defer tc.Destroy() t.Log("installing ssh in node 0") @@ -181,12 +181,12 @@ func TestInstallWithDisabledAddons(t *testing.T) { func TestHostPreflight(t *testing.T) { t.Parallel() tc := cluster.NewTestCluster(&cluster.Input{ - T: t, - Nodes: 1, - Image: "centos/8-Stream", - SSHPublicKey: "../output/tmp/id_rsa.pub", - SSHPrivateKey: "../output/tmp/id_rsa", - HelmVMPath: "../output/bin/embedded-cluster", + T: t, + Nodes: 1, + Image: "centos/8-Stream", + SSHPublicKey: "../output/tmp/id_rsa.pub", + SSHPrivateKey: "../output/tmp/id_rsa", + EmbeddedClusterPath: "../output/bin/embedded-cluster", }) defer tc.Destroy() t.Log("installing ssh and binutils on node 0") diff --git a/e2e/scripts/addons-only.sh b/e2e/scripts/addons-only.sh index 6d8265def..7732dd7df 100644 --- a/e2e/scripts/addons-only.sh +++ b/e2e/scripts/addons-only.sh @@ -105,7 +105,7 @@ main() { fi } -export HELMVM_METRICS_BASEURL="https://staging.replicated.app" +export EMBEDDED_CLUSTER_METRICS_BASEURL="https://staging.replicated.app" export KUBECONFIG=/root/.config/.embedded-cluster/etc/kubeconfig export PATH=$PATH:/root/.config/.embedded-cluster/bin main diff --git a/e2e/scripts/embed-and-install.sh b/e2e/scripts/embed-and-install.sh index ff64d4a76..a588cb2e3 100644 --- a/e2e/scripts/embed-and-install.sh +++ b/e2e/scripts/embed-and-install.sh @@ -138,7 +138,7 @@ main() { fi } -export HELMVM_METRICS_BASEURL="https://staging.replicated.app" +export EMBEDDED_CLUSTER_METRICS_BASEURL="https://staging.replicated.app" export KUBECONFIG=/root/.config/.embedded-cluster/etc/kubeconfig export PATH=$PATH:/root/.config/.embedded-cluster/bin main diff --git a/e2e/scripts/embedded-preflight.sh b/e2e/scripts/embedded-preflight.sh index d27389597..8f31e8f2c 100644 --- a/e2e/scripts/embedded-preflight.sh +++ b/e2e/scripts/embedded-preflight.sh @@ -184,7 +184,7 @@ main() { fi } -export HELMVM_METRICS_BASEURL="https://staging.replicated.app" +export EMBEDDED_CLUSTER_METRICS_BASEURL="https://staging.replicated.app" export KUBECONFIG=/root/.config/.embedded-cluster/etc/kubeconfig export PATH=$PATH:/root/.config/.embedded-cluster/bin main diff --git a/e2e/scripts/install-with-disabled-addons.sh b/e2e/scripts/install-with-disabled-addons.sh index 7dbfad79d..a090c30e8 100644 --- a/e2e/scripts/install-with-disabled-addons.sh +++ b/e2e/scripts/install-with-disabled-addons.sh @@ -89,7 +89,7 @@ main() { fi } -export HELMVM_METRICS_BASEURL="https://staging.replicated.app" +export EMBEDDED_CLUSTER_METRICS_BASEURL="https://staging.replicated.app" export KUBECONFIG=/root/.config/.embedded-cluster/etc/kubeconfig export PATH=$PATH:/root/.config/.embedded-cluster/bin main diff --git a/e2e/scripts/interactive-multi-node-install.exp b/e2e/scripts/interactive-multi-node-install.exp index 0d172bb95..d3603d3b9 100644 --- a/e2e/scripts/interactive-multi-node-install.exp +++ b/e2e/scripts/interactive-multi-node-install.exp @@ -9,8 +9,8 @@ proc configure_node {address} { expect "Type one of the options above:" { send "/root/.ssh/id_rsa\r" } } -set env(HELMVM_METRICS_BASEURL) "https://staging.replicated.app" -set env(HELMVM_PLAIN_PROMPTS) "true" +set env(EMBEDDED_CLUSTER_METRICS_BASEURL) "https://staging.replicated.app" +set env(EMBEDDED_CLUSTER_PLAIN_PROMPTS) "true" spawn embedded-cluster install --multi-node configure_node "10.0.0.2" expect -re "Add another node?.*:" { send "y\r" } diff --git a/e2e/scripts/single-node-install.sh b/e2e/scripts/single-node-install.sh index fe4c088e7..48a6726ea 100644 --- a/e2e/scripts/single-node-install.sh +++ b/e2e/scripts/single-node-install.sh @@ -65,7 +65,7 @@ main() { fi } -export HELMVM_METRICS_BASEURL="https://staging.replicated.app" +export EMBEDDED_CLUSTER_METRICS_BASEURL="https://staging.replicated.app" export KUBECONFIG=/root/.config/.embedded-cluster/etc/kubeconfig export PATH=$PATH:/root/.config/.embedded-cluster/bin main diff --git a/e2e/scripts/wait-for-ready-nodes.sh b/e2e/scripts/wait-for-ready-nodes.sh index dfa895e08..3e172f610 100644 --- a/e2e/scripts/wait-for-ready-nodes.sh +++ b/e2e/scripts/wait-for-ready-nodes.sh @@ -21,7 +21,7 @@ main() { exit 0 } -export HELMVM_METRICS_BASEURL="https://staging.replicated.app" +export EMBEDDED_CLUSTER_METRICS_BASEURL="https://staging.replicated.app" export KUBECONFIG=/root/.config/.embedded-cluster/etc/kubeconfig export PATH=$PATH:/root/.config/.embedded-cluster/bin main "$@" diff --git a/e2e/version_test.go b/e2e/version_test.go index fbc4817d8..d6e4dad5a 100644 --- a/e2e/version_test.go +++ b/e2e/version_test.go @@ -11,12 +11,12 @@ import ( func TestVersion(t *testing.T) { t.Parallel() tc := cluster.NewTestCluster(&cluster.Input{ - T: t, - Nodes: 1, - Image: "ubuntu/jammy", - SSHPublicKey: "../output/tmp/id_rsa.pub", - SSHPrivateKey: "../output/tmp/id_rsa", - HelmVMPath: "../output/bin/embedded-cluster", + T: t, + Nodes: 1, + Image: "ubuntu/jammy", + SSHPublicKey: "../output/tmp/id_rsa.pub", + SSHPrivateKey: "../output/tmp/id_rsa", + EmbeddedClusterPath: "../output/bin/embedded-cluster", }) defer tc.Destroy() t.Log("validating embedded-cluster version in node 0") diff --git a/pkg/defaults/defaults.go b/pkg/defaults/defaults.go index 9c1abc985..961b5b286 100644 --- a/pkg/defaults/defaults.go +++ b/pkg/defaults/defaults.go @@ -4,7 +4,7 @@ package defaults var ( - // Version holds the HelmVM version. + // Version holds the EmbeddedCluster version. Version = "v0.0.0" // K0sVersion holds the version of k0s binary we are embedding. this is // set at compile time via ldflags. @@ -32,14 +32,14 @@ func K0sctlBinsSubDir() string { return def().K0sctlBinsSubDir() } -// HelmVMBinsSubDir calls HelmVMBinsSubDir on the default provider. -func HelmVMBinsSubDir() string { - return def().HelmVMBinsSubDir() +// EmbeddedClusterBinsSubDir calls EmbeddedClusterBinsSubDir on the default provider. +func EmbeddedClusterBinsSubDir() string { + return def().EmbeddedClusterBinsSubDir() } -// HelmVMLogsSubDir calls HelmVMLogsSubDir on the default provider. -func HelmVMLogsSubDir() string { - return def().HelmVMLogsSubDir() +// EmbeddedClusterLogsSubDir calls EmbeddedClusterLogsSubDir on the default provider. +func EmbeddedClusterLogsSubDir() string { + return def().EmbeddedClusterLogsSubDir() } // K0sctlApplyLogPath calls K0sctlApplyLogPath on the default provider. @@ -72,9 +72,9 @@ func PathToK0sctlBinary(name string) string { return def().PathToK0sctlBinary(name) } -// PathToHelmVMBinary calls PathToHelmVMBinary on the default provider. -func PathToHelmVMBinary(name string) string { - return def().PathToHelmVMBinary(name) +// PathToEmbeddedClusterBinary calls PathToEmbeddedClusterBinary on the default provider. +func PathToEmbeddedClusterBinary(name string) string { + return def().PathToEmbeddedClusterBinary(name) } // PathToLog calls PathToLog on the default provider. diff --git a/pkg/defaults/provider.go b/pkg/defaults/provider.go index 589f724d9..99c79e8f5 100644 --- a/pkg/defaults/provider.go +++ b/pkg/defaults/provider.go @@ -30,7 +30,7 @@ func NewProvider(base string) *Provider { } // Provider is an entity that provides default values used during -// HelmVM installation. +// EmbeddedCluster installation. type Provider struct { Base string } @@ -43,10 +43,10 @@ func (d *Provider) Init() { if err := os.MkdirAll(d.ConfigSubDir(), 0755); err != nil { logrus.Fatalf("unable to create config dir: %s", err) } - if err := os.MkdirAll(d.HelmVMBinsSubDir(), 0755); err != nil { + if err := os.MkdirAll(d.EmbeddedClusterBinsSubDir(), 0755); err != nil { logrus.Fatalf("unable to create embedded-cluster bin dir: %s", err) } - if err := os.MkdirAll(d.HelmVMLogsSubDir(), 0755); err != nil { + if err := os.MkdirAll(d.EmbeddedClusterLogsSubDir(), 0755); err != nil { panic(fmt.Errorf("unable to create embedded-cluster logs dir: %w", err)) } if err := os.MkdirAll(d.SSHConfigSubDir(), 0700); err != nil { @@ -119,9 +119,9 @@ func (d *Provider) BinaryName() string { return slug.Make(base) } -// HelmVMLogsSubDir returns the path to the directory where embedded-cluster logs are +// EmbeddedClusterLogsSubDir returns the path to the directory where embedded-cluster logs are // stored. This is a subdirectory of the user's home directory. -func (d *Provider) HelmVMLogsSubDir() string { +func (d *Provider) EmbeddedClusterLogsSubDir() string { hidden := fmt.Sprintf(".%s", d.BinaryName()) return filepath.Join(d.Base, d.state(), hidden, "logs") } @@ -129,7 +129,7 @@ func (d *Provider) HelmVMLogsSubDir() string { // PathToLog returns the full path to a log file. This function does not check // if the file exists. func (d *Provider) PathToLog(name string) string { - return filepath.Join(d.HelmVMLogsSubDir(), name) + return filepath.Join(d.EmbeddedClusterLogsSubDir(), name) } // K0sctlBinsSubDir returns the path to the directory where k0sctl binaries @@ -148,9 +148,9 @@ func (d *Provider) HelmChartSubDir() string { return filepath.Join(d.Base, d.home(), hidden, "charts") } -// HelmVMBinsSubDir returns the path to the directory where embedded-cluster binaries +// EmbeddedClusterBinsSubDir returns the path to the directory where embedded-cluster binaries // are stored. This is a subdirectory of the user's home directory. -func (d *Provider) HelmVMBinsSubDir() string { +func (d *Provider) EmbeddedClusterBinsSubDir() string { hidden := fmt.Sprintf(".%s", d.BinaryName()) return filepath.Join(d.Base, d.config(), hidden, "bin") } @@ -196,11 +196,11 @@ func (d *Provider) PathToK0sctlBinary(name string) string { return filepath.Join(d.K0sctlBinsSubDir(), name) } -// PathToHelmVMBinary is an utility function that returns the full path to a +// PathToEmbeddedClusterBinary is an utility function that returns the full path to a // materialized binary that belongs to embedded-cluster (do not confuse with binaries // belonging to k0sctl). This function does not check if the file exists. -func (d *Provider) PathToHelmVMBinary(name string) string { - return filepath.Join(d.HelmVMBinsSubDir(), name) +func (d *Provider) PathToEmbeddedClusterBinary(name string) string { + return filepath.Join(d.EmbeddedClusterBinsSubDir(), name) } // PathToHelmChart returns the path to a materialized helm chart. diff --git a/pkg/defaults/provider_test.go b/pkg/defaults/provider_test.go index c608b6ab3..0437baa32 100644 --- a/pkg/defaults/provider_test.go +++ b/pkg/defaults/provider_test.go @@ -27,7 +27,7 @@ func TestInit(t *testing.T) { def := NewProvider(tmpdir) assert.DirExists(t, def.K0sctlBinsSubDir(), "k0s binary dir should exist") assert.DirExists(t, def.ConfigSubDir(), "config dir should exist") - assert.DirExists(t, def.HelmVMBinsSubDir(), "embedded-cluster binary dir should exist") + assert.DirExists(t, def.EmbeddedClusterBinsSubDir(), "embedded-cluster binary dir should exist") } func TestDecentralizedInstall(t *testing.T) { @@ -76,8 +76,8 @@ func TestEnsureAllDirectoriesAreInsideBase(t *testing.T) { def := NewProvider(tmpdir) for _, fn := range []func() string{ def.K0sctlBinsSubDir, - def.HelmVMBinsSubDir, - def.HelmVMLogsSubDir, + def.EmbeddedClusterBinsSubDir, + def.EmbeddedClusterLogsSubDir, def.K0sctlApplyLogPath, def.SSHKeyPath, def.SSHAuthorizedKeysPath, diff --git a/pkg/goods/goods.go b/pkg/goods/goods.go index 47ea8bac7..3817c4bd7 100644 --- a/pkg/goods/goods.go +++ b/pkg/goods/goods.go @@ -54,7 +54,7 @@ func Materialize() error { return fmt.Errorf("unable to read asset: %w", err) } fname := strings.TrimSuffix(entry.Name(), suffix) - dstpath := fmt.Sprintf("%s/%s", defaults.HelmVMBinsSubDir(), fname) + dstpath := fmt.Sprintf("%s/%s", defaults.EmbeddedClusterBinsSubDir(), fname) if err := os.WriteFile(dstpath, srcfile, 0755); err != nil { return fmt.Errorf("unable to write file: %w", err) } diff --git a/pkg/hembed/hembed.go b/pkg/hembed/hembed.go index 83ce026c1..ebbc52bbd 100644 --- a/pkg/hembed/hembed.go +++ b/pkg/hembed/hembed.go @@ -1,6 +1,6 @@ // Package hembed manages the helm chart embedding mechanism. It is used when the user // wants to embed a custom helm chart into the embedded-cluster binary. Writes the chart and adds -// a mark to the end of the file. The mark is on the format HELMVMCHARTS0000000000 where +// a mark to the end of the file. The mark is on the format EMBEDDEDCLUSTERCHARTS0000000000 where // the number is the length of the embedded data. package hembed @@ -20,7 +20,7 @@ import ( const ( // EndMark is a string that is used to mark the end of the binary. - EndMark = "HELMVMCHARTS" + EndMark = "EMBEDDEDCLUSTERCHARTS" ) // Binary is a helpes struct that holds a closer and a reader separately. Reads happen @@ -100,7 +100,7 @@ func CalculateRewind(fpath string) (int64, int64, error) { // ReadEmbeddedData reads the embedded data from the binary. It reads the binary from // the disk and looks for a mark at the end of the file. If the mark is found, it reads // the data that is embedded in the binary and returns it. The mark is on the format -// HELMVMCHARTS0000000000 where the number is the length of the embedded data. +// EMBEDDEDCLUSTERCHARTS0000000000 where the number is the length of the embedded data. func ReadEmbeddedData(fpath string) ([]byte, error) { fp, err := os.Open(fpath) if err != nil { diff --git a/pkg/logging/logging.go b/pkg/logging/logging.go index 7e7a34312..8ee0c58ef 100644 --- a/pkg/logging/logging.go +++ b/pkg/logging/logging.go @@ -97,7 +97,7 @@ func SetupLogging() { now := time.Now().Format("20060102150405") - dir := defaults.HelmVMLogsSubDir() + dir := defaults.EmbeddedClusterLogsSubDir() path := filepath.Join(dir, "embedded-cluster-"+now+".log") fileHook, err := NewLogrusFileHook(path, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0666) diff --git a/pkg/metrics/sender.go b/pkg/metrics/sender.go index e45ad8144..1c41d6f1c 100644 --- a/pkg/metrics/sender.go +++ b/pkg/metrics/sender.go @@ -15,8 +15,8 @@ import ( // BaseURL determines the base url to be used when sending metrics over. func BaseURL() string { - if os.Getenv("HELMVM_METRICS_BASEURL") != "" { - return os.Getenv("HELMVM_METRICS_BASEURL") + if os.Getenv("EMBEDDED_CLUSTER_METRICS_BASEURL") != "" { + return os.Getenv("EMBEDDED_CLUSTER_METRICS_BASEURL") } license, _ := customization.AdminConsole{}.License() if license == nil || license.Spec.Endpoint == "" { @@ -27,7 +27,7 @@ func BaseURL() string { // Send is a helper function that sends an event to the metrics endpoint. // Metrics endpoint can be overwritten by the license.spec.endpoint field -// or by the HELMVM_METRICS_BASEURL environment variable, the latter has +// or by the EMBEDDED_CLUSTER_METRICS_BASEURL environment variable, the latter has // precedence over the former. func Send(ctx context.Context, ev Event) { sender := Sender{BaseURL()} diff --git a/pkg/preflights/preflights.go b/pkg/preflights/preflights.go index 382ad43c5..c751195a0 100644 --- a/pkg/preflights/preflights.go +++ b/pkg/preflights/preflights.go @@ -70,7 +70,7 @@ func RunLocal(ctx context.Context, spec *v1beta2.HostPreflightSpec) (*Output, er return nil, fmt.Errorf("unable to save preflight locally: %w", err) } defer os.Remove(fpath) - binpath := defaults.PathToHelmVMBinary("kubectl-preflight") + binpath := defaults.PathToEmbeddedClusterBinary("kubectl-preflight") stdout := bytes.NewBuffer(nil) cmd := exec.Command(binpath, "--interactive=false", "--format=json", fpath) cmd.Stdout, cmd.Stderr = stdout, io.Discard @@ -99,7 +99,7 @@ func Run(ctx context.Context, host *cluster.Host, spec *v1beta2.HostPreflightSpe if err := uploadFile(host, fpath, "/tmp/embedded-cluster-preflight.yaml", 0600); err != nil { return nil, err } - src := defaults.PathToHelmVMBinary("kubectl-preflight") + src := defaults.PathToEmbeddedClusterBinary("kubectl-preflight") dst := path.Join("/tmp", filepath.Base(src)) if err := uploadFile(host, src, dst, 0755); err != nil { return nil, err diff --git a/pkg/prompts/prompts.go b/pkg/prompts/prompts.go index bcf1fc84b..909f403f4 100644 --- a/pkg/prompts/prompts.go +++ b/pkg/prompts/prompts.go @@ -1,6 +1,6 @@ // Package prompts provides tooling around asking users for questions. This // package chooses between "decorative" or "plain" prompts based on the -// environment variable HELMVM_PLAIN_PROMPTS. See 'decorative' and 'plain' +// environment variable EMBEDDED_CLUSTER_PLAIN_PROMPTS. See 'decorative' and 'plain' // packages for more information. package prompts @@ -22,7 +22,7 @@ type Prompt interface { // New returns a new Prompt. func New() Prompt { - if os.Getenv("HELMVM_PLAIN_PROMPTS") == "true" { + if os.Getenv("EMBEDDED_CLUSTER_PLAIN_PROMPTS") == "true" { return plain.Plain{} } return decorative.Decorative{}