Skip to content

Commit

Permalink
feat: consolidate data directories for ec, k0s, and openebs (#1238)
Browse files Browse the repository at this point in the history
* feat: consolidate data directories for ec, k0s, and openebs

* f

* comment explaining empty ExecStart

* metadata command should not need sudo

* defer tryRemoveTmpDirContents

* whitelist spelling

* we dont support using data dir different from snapshot

* always try to get the runtime config from the installation

* do not change registry chart defaults

* e2e runs-on ubuntu-22.04

* change runner

* change runner

* Trigger Build
  • Loading branch information
emosbaugh authored Oct 9, 2024
1 parent da29804 commit 5349947
Show file tree
Hide file tree
Showing 111 changed files with 2,301 additions and 1,832 deletions.
26 changes: 17 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ jobs:
e2e:
name: E2E
runs-on: ${{ matrix.runner || 'ubuntu-latest' }}
runs-on: ${{ matrix.runner || 'ubuntu-22.04' }}
needs:
- build-current
- build-previous-k0s
Expand All @@ -503,8 +503,6 @@ jobs:
- TestHostPreflightCustomSpec
- TestHostPreflightInBuiltSpec
- TestUnsupportedOverrides
- TestMultiNodeInstallation
- TestMultiNodeReset
- TestCommandsRequireSudo
- TestInstallWithoutEmbed
- TestInstallFromReplicatedApp
Expand All @@ -520,19 +518,29 @@ jobs:
- TestSingleNodeAirgapUpgradeFromEC18
- TestSingleNodeAirgapUpgradeCustomCIDR
- TestInstallSnapshotFromReplicatedApp
- TestMultiNodeAirgapUpgrade
- TestSingleNodeDisasterRecovery
- TestSingleNodeDisasterRecoveryWithProxy
- TestSingleNodeResumeDisasterRecovery
- TestProxiedEnvironment
- TestMultiNodeHAInstallation
- TestMultiNodeHADisasterRecovery
- TestCustomCIDR
- TestProxiedCustomCIDR
- TestSingleNodeInstallationNoopUpgrade
- TestInstallWithPrivateCAs
- TestInstallWithMITMProxy
include:
- test: TestCustomCIDR
runner: embedded-cluster
- test: TestProxiedEnvironment
runner: embedded-cluster
- test: TestProxiedCustomCIDR
runner: embedded-cluster
- test: TestMultiNodeInstallation
runner: embedded-cluster
- test: TestMultiNodeReset
runner: embedded-cluster
- test: TestMultiNodeAirgapUpgrade
runner: embedded-cluster
- test: TestMultiNodeHAInstallation
runner: embedded-cluster
- test: TestMultiNodeHADisasterRecovery
runner: embedded-cluster
- test: TestMultiNodeAirgapUpgrade
runner: embedded-cluster
- test: TestMultiNodeAirgapUpgradeSameK0s
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,22 @@ static: pkg/goods/bins/k0s \
pkg/goods/internal/bins/kubectl-kots

.PHONY: embedded-cluster-linux-amd64
embedded-cluster-linux-amd64: OS = linux
embedded-cluster-linux-amd64: ARCH = amd64
embedded-cluster-linux-amd64: export OS = linux
embedded-cluster-linux-amd64: export ARCH = amd64
embedded-cluster-linux-amd64: static go.mod embedded-cluster
mkdir -p ./output/bin
cp ./build/embedded-cluster-$(OS)-$(ARCH) ./output/bin/$(APP_NAME)

.PHONY: embedded-cluster-linux-arm64
embedded-cluster-linux-arm64: OS = linux
embedded-cluster-linux-arm64: ARCH = arm64
embedded-cluster-linux-arm64: export OS = linux
embedded-cluster-linux-arm64: export ARCH = arm64
embedded-cluster-linux-arm64: static go.mod embedded-cluster
mkdir -p ./output/bin
cp ./build/embedded-cluster-$(OS)-$(ARCH) ./output/bin/$(APP_NAME)

.PHONY: embedded-cluster-darwin-arm64
embedded-cluster-darwin-arm64: OS = darwin
embedded-cluster-darwin-arm64: ARCH = arm64
embedded-cluster-darwin-arm64: export OS = darwin
embedded-cluster-darwin-arm64: export ARCH = arm64
embedded-cluster-darwin-arm64: go.mod embedded-cluster
mkdir -p ./output/bin
cp ./build/embedded-cluster-$(OS)-$(ARCH) ./output/bin/$(APP_NAME)
Expand Down Expand Up @@ -291,7 +291,7 @@ list-distros:
.PHONY: create-node%
create-node%: DISTRO = debian-bookworm
create-node%: NODE_PORT = 30000
create-node%: K0S_DATA_DIR = /var/lib/k0s
create-node%: K0S_DATA_DIR = /var/lib/embedded-cluster/k0s
create-node%:
@docker run -d \
--name node$* \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ $ output/bin/embedded-cluster shell
((____!___/) Type 'exit' (or CTRL+d) to exit.
\0\0\0\0\/ Happy hacking.
~~~~~~~~~~~
$ export KUBECONFIG="/var/lib/k0s/pki/admin.conf"
$ export KUBECONFIG="/var/lib/embedded-cluster/k0s/pki/admin.conf"
$ export PATH="$PATH:/var/lib/embedded-cluster/bin"
$ source <(kubectl completion bash)
$ source /etc/bash_completion
Expand Down
11 changes: 6 additions & 5 deletions cmd/buildtools/openebs.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ var updateOpenEBSAddonCommand = &cli.Command{
current := openebs.Metadata
if current.Version == nextChartVersion && !c.Bool("force") {
logrus.Infof("openebs chart version is already up-to-date")
} else {
logrus.Infof("mirroring openebs chart version %s", nextChartVersion)
if err := MirrorChart(openebsRepo, "openebs", nextChartVersion); err != nil {
return fmt.Errorf("failed to mirror openebs chart: %v", err)
}
return nil
}

logrus.Infof("mirroring openebs chart version %s", nextChartVersion)
if err := MirrorChart(openebsRepo, "openebs", nextChartVersion); err != nil {
return fmt.Errorf("failed to mirror openebs chart: %v", err)
}

upstream := fmt.Sprintf("%s/openebs", os.Getenv("CHARTS_DESTINATION"))
Expand Down
11 changes: 6 additions & 5 deletions cmd/buildtools/seaweedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ var updateSeaweedFSAddonCommand = &cli.Command{
current := seaweedfs.Metadata
if current.Version == nextChartVersion && !c.Bool("force") {
logrus.Infof("seaweedfs chart version is already up-to-date")
} else {
logrus.Infof("mirroring seaweedfs chart version %s", nextChartVersion)
if err := MirrorChart(seaweedfsRepo, "seaweedfs", nextChartVersion); err != nil {
return fmt.Errorf("failed to mirror seaweedfs chart: %v", err)
}
return nil
}

logrus.Infof("mirroring seaweedfs chart version %s", nextChartVersion)
if err := MirrorChart(seaweedfsRepo, "seaweedfs", nextChartVersion); err != nil {
return fmt.Errorf("failed to mirror seaweedfs chart: %v", err)
}

upstream := fmt.Sprintf("%s/seaweedfs", os.Getenv("CHARTS_DESTINATION"))
Expand Down
82 changes: 50 additions & 32 deletions cmd/embedded-cluster/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,73 @@ import (
"fmt"
"strconv"

"github.com/replicatedhq/embedded-cluster/pkg/defaults"
ecv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
k8snet "k8s.io/utils/net"
)

func getAdminColsolePortFlag() cli.Flag {
func getAdminConsolePortFlag(runtimeConfig *ecv1beta1.RuntimeConfigSpec) cli.Flag {
return &cli.StringFlag{
Name: "admin-console-port",
Usage: "Port on which the Admin Console will be served",
Value: strconv.Itoa(defaults.AdminConsolePort),
Value: strconv.Itoa(ecv1beta1.DefaultAdminConsolePort),
Hidden: false,
Action: func(c *cli.Context, s string) error {
if s == "" {
return nil
}
// TODO: add first class support for service node port range and validate the port
port, err := k8snet.ParsePort(s, false)
if err != nil {
return fmt.Errorf("invalid port: %w", err)
}
logrus.Debugf("Setting admin console port to %d from flag", port)
runtimeConfig.AdminConsole.Port = port
return nil
},
}
}

func getAdminConsolePortFromFlag(c *cli.Context) (int, error) {
portStr := c.String("admin-console-port")
if portStr == "" {
return defaults.AdminConsolePort, nil
}
// TODO: add first class support for service node port range and validate the port
port, err := k8snet.ParsePort(portStr, false)
if err != nil {
return 0, fmt.Errorf("invalid admin console port: %w", err)
}
return port, nil
}

func getLocalArtifactMirrorPortFlag() cli.Flag {
func getLocalArtifactMirrorPortFlag(runtimeConfig *ecv1beta1.RuntimeConfigSpec) cli.Flag {
return &cli.StringFlag{
Name: "local-artifact-mirror-port",
Usage: "Port on which the Local Artifact Mirror will be served",
Value: strconv.Itoa(defaults.LocalArtifactMirrorPort),
Value: strconv.Itoa(ecv1beta1.DefaultLocalArtifactMirrorPort),
Hidden: false,
Action: func(c *cli.Context, s string) error {
if s == "" {
return nil
}
// TODO: add first class support for service node port range and validate the port does not
// conflict with this range
port, err := k8snet.ParsePort(s, false)
if err != nil {
return fmt.Errorf("invalid local artifact mirror port: %w", err)
}
if s == c.String("admin-console-port") {
return fmt.Errorf("local artifact mirror port cannot be the same as admin console port")
}
logrus.Debugf("Setting local artifact mirror port to %d from flag", port)
runtimeConfig.LocalArtifactMirror.Port = port
return nil
},
}
}

func getLocalArtifactMirrorPortFromFlag(c *cli.Context) (int, error) {
portStr := c.String("local-artifact-mirror-port")
if portStr == "" {
return defaults.LocalArtifactMirrorPort, nil
}
// TODO: add first class support for service node port range and validate the port does not
// conflict with this range
port, err := k8snet.ParsePort(portStr, false)
if err != nil {
return 0, fmt.Errorf("invalid local artifact mirror port: %w", err)
}
if portStr == c.String("admin-console-port") {
return 0, fmt.Errorf("local artifact mirror port cannot be the same as admin console port")
func getDataDirFlag(runtimeConfig *ecv1beta1.RuntimeConfigSpec) cli.Flag {
return &cli.StringFlag{
Name: "data-dir",
Usage: "Path to the data directory",
Value: ecv1beta1.DefaultDataDir,
Hidden: false,
Action: func(c *cli.Context, s string) error {
if s == "" {
return nil
}
logrus.Debugf("Setting data dir to %s from flag", s)
runtimeConfig.DataDir = s
return nil
},
}
return port, nil
}
Loading

0 comments on commit 5349947

Please sign in to comment.