Skip to content

Commit

Permalink
Make etcd the default data storage (#169)
Browse files Browse the repository at this point in the history
* make etcd the default data storage

Signed-off-by: Jussi Nummelin <[email protected]>

* mark etcd as the default in docs

Signed-off-by: Jussi Nummelin <[email protected]>
  • Loading branch information
jnummelin authored Sep 8, 2020
1 parent 82a6f86 commit b2c0afe
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 31 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ See more in [architecture docs](docs/architecture.md)
- Kubernetes 1.19
- Containerd 1.4
- Control plane storage options:
- sqlite (in-cluster, default)
- etcd (in-cluster, managed)
- sqlite (in-cluster)
- etcd (in-cluster, managed, default)
- mysql (external)
- postgresql (external)
- CNI providers
Expand Down
6 changes: 3 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ metadata:
name: mke
spec:
storage:
type: kine
kine:
dataSource: sqlite:///var/lib/mke/db/state.db?more=rwc&_journal=WAL&cache=shared
type: etcd
etcd:
peerAddress: 1.2.3.4 # Defaults to first non-local address found on the node.
api:
address: 172.17.0.3 # Address where the k8s API is accessed at.
sans: # If you want to incorporate multiple addresses into the generates api server certs
Expand Down
14 changes: 0 additions & 14 deletions mke.yaml

This file was deleted.

6 changes: 4 additions & 2 deletions pkg/apis/v1beta1/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ metadata:

c, err := fromYaml(t, yamlData)
assert.NoError(t, err)
assert.Equal(t, "kine", c.Spec.Storage.Type)
assert.Equal(t, DefaultKineDataSource, c.Spec.Storage.Kine.DataSource)
assert.Equal(t, "etcd", c.Spec.Storage.Type)
addr, err := util.FirstPublicAddress()
assert.NoError(t, err)
assert.Equal(t, addr, c.Spec.Storage.Etcd.PeerAddress)
}

func TestEtcdDefaults(t *testing.T) {
Expand Down
22 changes: 12 additions & 10 deletions pkg/apis/v1beta1/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,15 @@ const DefaultKineDataSource = "sqlite:///var/lib/mke/db/state.db?more=rwc&_journ

func DefaultStorageSpec() *StorageSpec {
return &StorageSpec{
Type: "kine",
Kine: &KineConfig{
DataSource: DefaultKineDataSource,
},
Type: "etcd",
Etcd: DefaultEtcdConfig(),
}
}

// UnmarshalYAML sets in some sane defaults when unmarshaling the data from yaml
func (s *StorageSpec) UnmarshalYAML(unmarshal func(interface{}) error) error {
s.Type = "kine"
s.Kine = &KineConfig{
DataSource: DefaultKineDataSource,
}
s.Type = "etcd"
s.Etcd = DefaultEtcdConfig()

type ystorageconfig StorageSpec
yc := (*ystorageconfig)(s)
Expand All @@ -40,8 +36,8 @@ func (s *StorageSpec) UnmarshalYAML(unmarshal func(interface{}) error) error {
return err
}

if s.Type == "etcd" && s.Etcd == nil {
s.Etcd = DefaultEtcdConfig()
if s.Type == "kine" && s.Kine == nil {
s.Kine = DefaultKineConfig()
}

return nil
Expand All @@ -61,3 +57,9 @@ func DefaultEtcdConfig() *EtcdConfig {
PeerAddress: addr,
}
}

func DefaultKineConfig() *KineConfig {
return &KineConfig{
DataSource: DefaultKineDataSource,
}
}

0 comments on commit b2c0afe

Please sign in to comment.