Skip to content

Commit

Permalink
Add option for using ramdisk for etcd
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Chacin <[email protected]>
  • Loading branch information
pablochacin committed Jul 21, 2023
1 parent 9f56de7 commit 79ff481
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
25 changes: 24 additions & 1 deletion e2e/cluster/cluster_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,30 @@ func Test_DefaultConfig(t *testing.T) {
cluster.Delete()
}

func Test_UseEtcdRamDisk(t *testing.T) {
// create cluster with default configuration
config, err := cluster.NewConfig(
"e2e-etcdramdisk-cluster",
cluster.Options{
Wait: time.Second * 60,
UseEtcdRAMDisk: true,
},
)
if err != nil {
t.Errorf("failed creating cluster configuration: %v", err)
return
}

cluster, err := config.Create()
if err != nil {
t.Errorf("failed to create cluster: %v", err)
return
}

// delete cluster
cluster.Delete()
}

func getKubernetesClient(kubeconfig string) (kubernetes.Interface, error) {
config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
if err != nil {
Expand Down Expand Up @@ -126,7 +150,6 @@ func Test_PreloadImages(t *testing.T) {
}
}


func Test_KubernetesVersion(t *testing.T) {
// create cluster with default configuration
config, err := cluster.NewConfig(
Expand Down
14 changes: 14 additions & 0 deletions pkg/testutils/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane`

const etcdPatch = `
kubeadmConfigPatches:
- |
kind: ClusterConfiguration
etcd:
local:
dataDir: /tmp/etcd`

const kindPortMapping = `
- containerPort: %d
hostPort: %d
Expand Down Expand Up @@ -62,6 +70,8 @@ type Options struct {
Version string
// Path to Kubeconfig
Kubeconfig string
// UseEtcdRAMDisk
UseEtcdRAMDisk bool
}

// Config contains the configuration for creating a cluster
Expand Down Expand Up @@ -117,6 +127,10 @@ func (c *Config) Render() (string, error) {
fmt.Fprintf(&config, "\n- role: worker")
}

if c.options.UseEtcdRAMDisk {
fmt.Fprintf(&config, "\n%s", etcdPatch)
}

return config.String(), nil
}

Expand Down

0 comments on commit 79ff481

Please sign in to comment.