Skip to content

Added ExtraArgs to kine #5871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ spec:
| `etcd.extraArgs` | Map of key-values (strings) for any extra arguments to pass down to etcd process. Any behavior triggered by these parameters is outside k0s support. |
| `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. |
| `etcd.externalCluster` | Configuration when etcd is externally managed, i.e. running on dedicated nodes. See [`spec.storage.etcd.externalCluster`](#specstorageetcdexternalcluster) |
| `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. |

#### `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,8 @@ 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 Kine
ExtraArgs map[string]string `json:"extraArgs,omitempty"`
}

// DefaultStorageSpec creates StorageSpec with sane defaults
Expand Down Expand Up @@ -209,6 +211,7 @@ func DefaultKineConfig(dataDir string) *KineConfig {
Path: filepath.ToSlash(filepath.Join(dataDir, "db", "state.db")),
RawQuery: "mode=rwc&_journal=WAL",
}),
ExtraArgs: make(map[string]string),
}
}

Expand Down
9 changes: 8 additions & 1 deletion pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 21 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,31 @@ 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",
}
for name, value := range k.Config.ExtraArgs {
argName := "--" + name
if _, ok := args[argName]; ok {
logrus.Warnf("ignoring provided value for: %s", name)
continue
}
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
6 changes: 6 additions & 0 deletions static/_crds/k0s/k0s.k0sproject.io_clusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,12 @@ spec:
dataSource:
description: kine datasource URL
type: string
extraArgs:
additionalProperties:
type: string
description: Map of key-values (strings) for any extra arguments
you want to pass down to Kine
type: object
type: object
type:
default: etcd
Expand Down