Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/howto_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ apiServer:
- ""
debugging:
logLevel: ""
etcd:
quotaBackendSize: ""
defragCheckFreq: ""
doStartupDefrag: false
minDefragSize: ""
maxFragmentedPercentage: 0
```

## Default Settings
Expand All @@ -42,6 +48,12 @@ apiServer:
subjectAltNames: []
debugging:
logLevel: "Normal"
etcd:
quotaBackendSize: "2Gi"
defragCheckFreq: "5m"
doStartupDefrag: true
minDefragSize: "100Mi"
maxFragmentedPercentage: 45
```

## Service NodePort range
Expand Down
17 changes: 17 additions & 0 deletions packaging/microshift/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,20 @@ apiServer:
debugging:
# Log verbosity ('Normal', 'Debug', 'Trace', 'TraceAll'):
#logLevel: 'Normal'

etcd:
# The limit on the size of the etcd database; the etcd server will start failing writes if its size on disk reaches this value. (Default: 2GB)
#quotaBackendSize: '2Gi'

# How often to check the conditions for defragmenting the etcd database (0 means no defrags, except for a single on startup if `doStartupDefrag` is set). (Default: 5 minutes)
#defragCheckFreq: '5m'

# Whether or not to defragment the etcd database when the etcd server finishes starting. (Default: true)
#doStartupDefrag: true

# Defragment conditions: if both of the following are true when the condition check (controlled by the DefragCheckFreq) runs, defragment the etcd database.
# The minimum size of the etcd database, if the database is smaller than this value, defragmenting will not occur. (Default: 100MB)
#minDefragSize: '100Mi'

# The maximum allowed fragmented percentage, if the database is fragmented less than this value, defragmenting will not occur. (Default: 45)
#maxFragmentedPercentage: 45
63 changes: 54 additions & 9 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/mitchellh/go-homedir"
"github.com/spf13/pflag"

"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/component-base/logs"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -58,7 +59,7 @@ type IngressConfig struct {
ServingKey []byte
}

type EtcdConfig struct {
type InternalEtcdConfig struct {
// The limit on the size of the etcd database; etcd will start failing writes if its size on disk reaches this value
QuotaBackendBytes int64
// If the backend is fragmented more than `maxFragmentedPercentage`
Expand All @@ -71,6 +72,19 @@ type EtcdConfig struct {
DoStartupDefrag bool
}

type EtcdConfig struct {
// The limit on the size of the etcd database; etcd will start failing writes if its size on disk reaches this value
QuotaBackendSize string
// If the backend is fragmented more than `maxFragmentedPercentage`
// and the database size is greater than `minDefragSize`, do a defrag.
MinDefragSize string
MaxFragmentedPercentage float64
// How often to check the conditions for defragging (0 means no defrags, except for a single on startup if `doStartupDefrag` is set).
DefragCheckFreq string
// Whether or not to do a defrag when the server finishes starting
DoStartupDefrag bool
}

type MicroshiftConfig struct {
LogVLevel int `json:"logVLevel"`

Expand All @@ -89,17 +103,18 @@ type MicroshiftConfig struct {
BaseDomain string `json:"baseDomain"`
Cluster ClusterConfig `json:"cluster"`

Ingress IngressConfig `json:"-"`
Etcd EtcdConfig `json:"etcd"`
Ingress IngressConfig `json:"-"`
Etcd InternalEtcdConfig `json:"etcd"`
}

// Top level config file
type Config struct {
DNS DNS `json:"dns"`
Network Network `json:"network"`
Node Node `json:"node"`
ApiServer ApiServer `json:"apiServer"`
Debugging Debugging `json:"debugging"`
DNS DNS `json:"dns"`
Network Network `json:"network"`
Node Node `json:"node"`
ApiServer ApiServer `json:"apiServer"`
Debugging Debugging `json:"debugging"`
Etcd EtcdConfig `json:"etcd"`
}

type Network struct {
Expand Down Expand Up @@ -238,7 +253,7 @@ func NewMicroshiftConfig() *MicroshiftConfig {
ServiceCIDR: "10.43.0.0/16",
ServiceNodePortRange: "30000-32767",
},
Etcd: EtcdConfig{
Etcd: InternalEtcdConfig{
MinDefragBytes: 100 * 1024 * 1024, // 100MB
MaxFragmentedPercentage: 45, // percent
DefragCheckFreq: 5 * time.Minute,
Expand Down Expand Up @@ -402,6 +417,36 @@ func (c *MicroshiftConfig) ReadFromConfigFile(configFile string) error {
c.KASAdvertiseAddress = config.ApiServer.AdvertiseAddress
}

if config.Etcd.DefragCheckFreq != "" {
d, err := time.ParseDuration(config.Etcd.DefragCheckFreq)
if err != nil {
return fmt.Errorf("failed to parse etcd defragCheckFreq: %v", err)
}
c.Etcd.DefragCheckFreq = d
}
if config.Etcd.MinDefragSize != "" {
q, err := resource.ParseQuantity(config.Etcd.MinDefragSize)
if err != nil {
return fmt.Errorf("failed to parse etcd minDefragSize: %v", err)
}
if !q.IsZero() {
c.Etcd.MinDefragBytes = q.Value()
}
}
if config.Etcd.MaxFragmentedPercentage > 0 {
c.Etcd.MaxFragmentedPercentage = config.Etcd.MaxFragmentedPercentage
}
if config.Etcd.QuotaBackendSize != "" {
q, err := resource.ParseQuantity(config.Etcd.QuotaBackendSize)
if err != nil {
return fmt.Errorf("failed to parse etcd quotaBackendSize: %v", err)
}
if !q.IsZero() {
c.Etcd.QuotaBackendBytes = q.Value()
}
}
c.Etcd.DoStartupDefrag = config.Etcd.DoStartupDefrag

return nil
}

Expand Down
18 changes: 16 additions & 2 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ func TestConfigFile(t *testing.T) {
Debugging: Debugging{
LogLevel: "Debug",
},
Etcd: EtcdConfig{
QuotaBackendSize: "2Gi",
MinDefragSize: "100Mi",
MaxFragmentedPercentage: 45,
DefragCheckFreq: "5m",
DoStartupDefrag: true,
},
},
expected: MicroshiftConfig{
LogVLevel: 4,
Expand All @@ -71,7 +78,7 @@ func TestConfigFile(t *testing.T) {
ServiceCIDR: "40.30.20.10/16",
ServiceNodePortRange: "1024-32767",
},
Etcd: EtcdConfig{
Etcd: InternalEtcdConfig{
QuotaBackendBytes: 2 * 1024 * 1024 * 1024,
MinDefragBytes: 100 * 1024 * 1024,
MaxFragmentedPercentage: 45,
Expand Down Expand Up @@ -150,6 +157,13 @@ func TestMicroshiftConfigReadAndValidate(t *testing.T) {
Debugging: Debugging{
LogLevel: "Debug",
},
Etcd: EtcdConfig{
QuotaBackendSize: "2Gi",
MinDefragSize: "100Mi",
MaxFragmentedPercentage: 45,
DefragCheckFreq: "5m",
DoStartupDefrag: true,
},
},
expected: MicroshiftConfig{
LogVLevel: 4,
Expand All @@ -166,7 +180,7 @@ func TestMicroshiftConfigReadAndValidate(t *testing.T) {
ServiceNodePortRange: "1024-32767",
DNS: "40.30.0.10",
},
Etcd: EtcdConfig{
Etcd: InternalEtcdConfig{
QuotaBackendBytes: 2 * 1024 * 1024 * 1024,
MinDefragBytes: 100 * 1024 * 1024,
MaxFragmentedPercentage: 45,
Expand Down