Skip to content
Closed
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
1 change: 1 addition & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ spec:
| `etcd.ca.expiresAfter` | The expiration duration of the CA certificate (default: 87600h) |
| `etcd.ca.certificatesExpireAfter` | The expiration duration of the server certificate (default: 8760h) |
| `kine.dataSource` | [kine](https://github.com/k3s-io/kine) datasource URL. |
| `kine.extraArgs` | Map of key-values (strings) for any extra arguments to pass down to kine process. Any behavior triggered by these parameters is outside k0s support. |
| `etcd.externalCluster` | Configuration when etcd is externally managed, i.e. running on dedicated nodes. See [`spec.storage.etcd.externalCluster`](#specstorageetcdexternalcluster) |

#### `spec.storage.etcd.externalCluster`
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/k0s/v1beta1/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ const (
type KineConfig struct {
// kine datasource URL
DataSource string `json:"dataSource,omitempty"`

// Map of key-values (strings) for any extra arguments you want to pass down to the kine process
ExtraArgs map[string]string `json:"extraArgs,omitempty"`
}

// DefaultStorageSpec creates StorageSpec with sane defaults
Expand Down
13 changes: 13 additions & 0 deletions pkg/apis/k0s/v1beta1/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ func TestStorageSpec_IsJoinable(t *testing.T) {
},
want: true,
},
{
name: "kine-mysql-extra-args",
storage: StorageSpec{
Type: "kine",
Kine: &KineConfig{
DataSource: "mysql://foobar",
ExtraArgs: map[string]string{
"datastore-max-open-connections": "10",
},
},
},
want: true,
},
{
name: "kine-postgres",
storage: StorageSpec{
Expand Down
34 changes: 23 additions & 11 deletions pkg/component/controller/kine.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/sirupsen/logrus"

"github.com/k0sproject/k0s/internal/pkg/dir"
"github.com/k0sproject/k0s/internal/pkg/stringmap"
"github.com/k0sproject/k0s/internal/pkg/users"
"github.com/k0sproject/k0s/pkg/assets"
"github.com/k0sproject/k0s/pkg/constant"
Expand Down Expand Up @@ -113,22 +114,33 @@ func (k *Kine) Init(_ context.Context) error {
func (k *Kine) Start(ctx context.Context) error {
logrus.Info("Starting kine")

args := stringmap.StringMap{
"--endpoint": k.Config.DataSource,
// NB: kine doesn't parse URLs properly, so construct potentially
// invalid URLs that are understood by kine.
// https://github.com/k3s-io/kine/blob/v0.13.12/pkg/util/network.go#L5-L13
"--listen-address": "unix://" + k.K0sVars.KineSocketPath,
// Enable metrics on port 2380. The default is 8080, which clashes with kube-router.
"--metrics-bind-address": ":2380",
}

// Add custom flags from the config if provided via kine.extraArgs
for name, value := range k.Config.ExtraArgs {
argName := "--" + name
if _, ok := args[argName]; ok {
logrus.Warnf("overriding kine flag with user provided value: %s", argName)
}
args[argName] = value
}

k.supervisor = supervisor.Supervisor{
Name: "kine",
BinPath: assets.BinPath("kine", k.K0sVars.BinDir),
DataDir: k.K0sVars.DataDir,
RunDir: k.K0sVars.RunDir,
Args: []string{
"--endpoint=" + k.Config.DataSource,
// NB: kine doesn't parse URLs properly, so construct potentially
// invalid URLs that are understood by kine.
// https://github.com/k3s-io/kine/blob/v0.13.12/pkg/util/network.go#L5-L13
"--listen-address=unix://" + k.K0sVars.KineSocketPath,
// Enable metrics on port 2380. The default is 8080, which clashes with kube-router.
"--metrics-bind-address=:2380",
},
UID: k.uid,
GID: k.gid,
Args: args.ToArgs(),
UID: k.uid,
GID: k.gid,
}

return k.supervisor.Supervise()
Expand Down