mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
vendor updates
This commit is contained in:
8
vendor/k8s.io/kubernetes/cmd/kubelet/BUILD
generated
vendored
8
vendor/k8s.io/kubernetes/cmd/kubelet/BUILD
generated
vendored
@ -9,8 +9,7 @@ load("//pkg/version:def.bzl", "version_x_defs")
|
||||
|
||||
go_binary(
|
||||
name = "kubelet",
|
||||
importpath = "k8s.io/kubernetes/cmd/kubelet",
|
||||
library = ":go_default_library",
|
||||
embed = [":go_default_library"],
|
||||
x_defs = version_x_defs(),
|
||||
)
|
||||
|
||||
@ -20,13 +19,8 @@ go_library(
|
||||
importpath = "k8s.io/kubernetes/cmd/kubelet",
|
||||
deps = [
|
||||
"//cmd/kubelet/app:go_default_library",
|
||||
"//cmd/kubelet/app/options:go_default_library",
|
||||
"//pkg/client/metrics/prometheus:go_default_library",
|
||||
"//pkg/version/prometheus:go_default_library",
|
||||
"//pkg/version/verflag:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/flag:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/logs:go_default_library",
|
||||
],
|
||||
)
|
||||
|
44
vendor/k8s.io/kubernetes/cmd/kubelet/app/BUILD
generated
vendored
44
vendor/k8s.io/kubernetes/cmd/kubelet/app/BUILD
generated
vendored
@ -9,8 +9,7 @@ load(
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["server_test.go"],
|
||||
importpath = "k8s.io/kubernetes/cmd/kubelet/app",
|
||||
library = ":go_default_library",
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
@ -19,11 +18,40 @@ go_library(
|
||||
"auth.go",
|
||||
"plugins.go",
|
||||
"server.go",
|
||||
"server_unsupported.go",
|
||||
] + select({
|
||||
"@io_bazel_rules_go//go/platform:linux_amd64": [
|
||||
"@io_bazel_rules_go//go/platform:android": [
|
||||
"server_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:darwin": [
|
||||
"server_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:dragonfly": [
|
||||
"server_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:freebsd": [
|
||||
"server_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:linux": [
|
||||
"server_linux.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:nacl": [
|
||||
"server_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:netbsd": [
|
||||
"server_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:openbsd": [
|
||||
"server_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:plan9": [
|
||||
"server_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:solaris": [
|
||||
"server_unsupported.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:windows": [
|
||||
"server_unsupported.go",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
importpath = "k8s.io/kubernetes/cmd/kubelet/app",
|
||||
@ -44,7 +72,7 @@ go_library(
|
||||
"//pkg/kubelet:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig/scheme:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig/v1alpha1:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig/v1beta1:go_default_library",
|
||||
"//pkg/kubelet/cadvisor:go_default_library",
|
||||
"//pkg/kubelet/certificate:go_default_library",
|
||||
"//pkg/kubelet/certificate/bootstrap:go_default_library",
|
||||
@ -56,6 +84,7 @@ go_library(
|
||||
"//pkg/kubelet/eviction:go_default_library",
|
||||
"//pkg/kubelet/eviction/api:go_default_library",
|
||||
"//pkg/kubelet/kubeletconfig:go_default_library",
|
||||
"//pkg/kubelet/kubeletconfig/configfiles:go_default_library",
|
||||
"//pkg/kubelet/network:go_default_library",
|
||||
"//pkg/kubelet/network/cni:go_default_library",
|
||||
"//pkg/kubelet/network/kubenet:go_default_library",
|
||||
@ -63,6 +92,8 @@ go_library(
|
||||
"//pkg/kubelet/server/streaming:go_default_library",
|
||||
"//pkg/kubelet/types:go_default_library",
|
||||
"//pkg/util/configz:go_default_library",
|
||||
"//pkg/util/filesystem:go_default_library",
|
||||
"//pkg/util/flag:go_default_library",
|
||||
"//pkg/util/flock:go_default_library",
|
||||
"//pkg/util/io:go_default_library",
|
||||
"//pkg/util/mount:go_default_library",
|
||||
@ -70,6 +101,7 @@ go_library(
|
||||
"//pkg/util/oom:go_default_library",
|
||||
"//pkg/util/rlimit:go_default_library",
|
||||
"//pkg/version:go_default_library",
|
||||
"//pkg/version/verflag:go_default_library",
|
||||
"//pkg/volume:go_default_library",
|
||||
"//pkg/volume/aws_ebs:go_default_library",
|
||||
"//pkg/volume/azure_dd:go_default_library",
|
||||
@ -126,7 +158,7 @@ go_library(
|
||||
"//vendor/k8s.io/client-go/util/cert:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/certificate:go_default_library",
|
||||
] + select({
|
||||
"@io_bazel_rules_go//go/platform:linux_amd64": [
|
||||
"@io_bazel_rules_go//go/platform:linux": [
|
||||
"//vendor/golang.org/x/exp/inotify:go_default_library",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
|
63
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/BUILD
generated
vendored
63
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/BUILD
generated
vendored
@ -10,25 +10,79 @@ go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"container_runtime.go",
|
||||
"globalflags.go",
|
||||
"options.go",
|
||||
],
|
||||
] + select({
|
||||
"@io_bazel_rules_go//go/platform:android": [
|
||||
"globalflags_other.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:darwin": [
|
||||
"globalflags_other.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:dragonfly": [
|
||||
"globalflags_other.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:freebsd": [
|
||||
"globalflags_other.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:linux": [
|
||||
"globalflags_linux.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:nacl": [
|
||||
"globalflags_other.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:netbsd": [
|
||||
"globalflags_other.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:openbsd": [
|
||||
"globalflags_other.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:plan9": [
|
||||
"globalflags_other.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:solaris": [
|
||||
"globalflags_other.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:windows": [
|
||||
"globalflags_other.go",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
importpath = "k8s.io/kubernetes/cmd/kubelet/app/options",
|
||||
deps = [
|
||||
"//pkg/apis/componentconfig:go_default_library",
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/credentialprovider/azure:go_default_library",
|
||||
"//pkg/credentialprovider/gcp:go_default_library",
|
||||
"//pkg/features:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig/scheme:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig/v1alpha1:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig/v1beta1:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig/validation:go_default_library",
|
||||
"//pkg/kubelet/config:go_default_library",
|
||||
"//pkg/kubelet/types:go_default_library",
|
||||
"//pkg/master/ports:go_default_library",
|
||||
"//pkg/util/taints:go_default_library",
|
||||
"//pkg/version/verflag:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/validation:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/flag:go_default_library",
|
||||
],
|
||||
"//vendor/k8s.io/apiserver/pkg/util/logs:go_default_library",
|
||||
] + select({
|
||||
"@io_bazel_rules_go//go/platform:linux": [
|
||||
"//vendor/github.com/google/cadvisor/container/common:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/container/containerd:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/container/docker:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/container/raw:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/machine:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/manager:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/storage:go_default_library",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)
|
||||
|
||||
filegroup(
|
||||
@ -47,8 +101,7 @@ filegroup(
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["options_test.go"],
|
||||
importpath = "k8s.io/kubernetes/cmd/kubelet/app/options",
|
||||
library = ":go_default_library",
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
|
||||
|
4
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/container_runtime.go
generated
vendored
4
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/container_runtime.go
generated
vendored
@ -27,8 +27,8 @@ import (
|
||||
|
||||
const (
|
||||
// When these values are updated, also update test/e2e/framework/util.go
|
||||
defaultPodSandboxImageName = "gcr.io/google_containers/pause"
|
||||
defaultPodSandboxImageVersion = "3.0"
|
||||
defaultPodSandboxImageName = "k8s.gcr.io/pause"
|
||||
defaultPodSandboxImageVersion = "3.1"
|
||||
// From pkg/kubelet/rkt/rkt.go to avoid circular import
|
||||
defaultRktAPIServiceEndpoint = "localhost:15441"
|
||||
)
|
||||
|
118
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/globalflags.go
generated
vendored
Normal file
118
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/globalflags.go
generated
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package options
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
// libs that provide registration functions
|
||||
"k8s.io/apiserver/pkg/util/logs"
|
||||
"k8s.io/kubernetes/pkg/version/verflag"
|
||||
|
||||
// ensure libs have a chance to globally register their flags
|
||||
_ "github.com/golang/glog"
|
||||
_ "k8s.io/kubernetes/pkg/credentialprovider/azure"
|
||||
_ "k8s.io/kubernetes/pkg/credentialprovider/gcp"
|
||||
)
|
||||
|
||||
// AddGlobalFlags explicitly registers flags that libraries (glog, verflag, etc.) register
|
||||
// against the global flagsets from "flag" and "github.com/spf13/pflag".
|
||||
// We do this in order to prevent unwanted flags from leaking into the Kubelet's flagset.
|
||||
func AddGlobalFlags(fs *pflag.FlagSet) {
|
||||
addGlogFlags(fs)
|
||||
addCadvisorFlags(fs)
|
||||
addCredentialProviderFlags(fs)
|
||||
verflag.AddFlags(fs)
|
||||
logs.AddFlags(fs)
|
||||
}
|
||||
|
||||
// normalize replaces underscores with hyphens
|
||||
// we should always use hyphens instead of underscores when registering kubelet flags
|
||||
func normalize(s string) string {
|
||||
return strings.Replace(s, "_", "-", -1)
|
||||
}
|
||||
|
||||
// register adds a flag to local that targets the Value associated with the Flag named globalName in global
|
||||
func register(global *flag.FlagSet, local *pflag.FlagSet, globalName string) {
|
||||
if f := global.Lookup(globalName); f != nil {
|
||||
pflagFlag := pflag.PFlagFromGoFlag(f)
|
||||
pflagFlag.Name = normalize(pflagFlag.Name)
|
||||
local.AddFlag(pflagFlag)
|
||||
} else {
|
||||
panic(fmt.Sprintf("failed to find flag in global flagset (flag): %s", globalName))
|
||||
}
|
||||
}
|
||||
|
||||
// pflagRegister adds a flag to local that targets the Value associated with the Flag named globalName in global
|
||||
func pflagRegister(global, local *pflag.FlagSet, globalName string) {
|
||||
if f := global.Lookup(globalName); f != nil {
|
||||
f.Name = normalize(f.Name)
|
||||
local.AddFlag(f)
|
||||
} else {
|
||||
panic(fmt.Sprintf("failed to find flag in global flagset (pflag): %s", globalName))
|
||||
}
|
||||
}
|
||||
|
||||
// registerDeprecated registers the flag with register, and then marks it deprecated
|
||||
func registerDeprecated(global *flag.FlagSet, local *pflag.FlagSet, globalName, deprecated string) {
|
||||
register(global, local, globalName)
|
||||
local.Lookup(normalize(globalName)).Deprecated = deprecated
|
||||
}
|
||||
|
||||
// pflagRegisterDeprecated registers the flag with pflagRegister, and then marks it deprecated
|
||||
func pflagRegisterDeprecated(global, local *pflag.FlagSet, globalName, deprecated string) {
|
||||
pflagRegister(global, local, globalName)
|
||||
local.Lookup(normalize(globalName)).Deprecated = deprecated
|
||||
}
|
||||
|
||||
// addCredentialProviderFlags adds flags from k8s.io/kubernetes/pkg/credentialprovider
|
||||
func addCredentialProviderFlags(fs *pflag.FlagSet) {
|
||||
// lookup flags in global flag set and re-register the values with our flagset
|
||||
global := pflag.CommandLine
|
||||
local := pflag.NewFlagSet(os.Args[0], pflag.ExitOnError)
|
||||
|
||||
// Note this is deprecated in the library that provides it, so we just allow that deprecation
|
||||
// notice to pass through our registration here.
|
||||
pflagRegister(global, local, "google-json-key")
|
||||
// TODO(#58034): This is not a static file, so it's not quite as straightforward as --google-json-key.
|
||||
// We need to figure out how ACR users can dynamically provide pull credentials before we can deprecate this.
|
||||
pflagRegister(global, local, "azure-container-registry-config")
|
||||
|
||||
fs.AddFlagSet(local)
|
||||
}
|
||||
|
||||
// addGlogFlags adds flags from github.com/golang/glog
|
||||
func addGlogFlags(fs *pflag.FlagSet) {
|
||||
// lookup flags in global flag set and re-register the values with our flagset
|
||||
global := flag.CommandLine
|
||||
local := pflag.NewFlagSet(os.Args[0], pflag.ExitOnError)
|
||||
|
||||
register(global, local, "logtostderr")
|
||||
register(global, local, "alsologtostderr")
|
||||
register(global, local, "v")
|
||||
register(global, local, "stderrthreshold")
|
||||
register(global, local, "vmodule")
|
||||
register(global, local, "log_backtrace_at")
|
||||
register(global, local, "log_dir")
|
||||
|
||||
fs.AddFlagSet(local)
|
||||
}
|
79
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/globalflags_linux.go
generated
vendored
Normal file
79
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/globalflags_linux.go
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
// +build linux
|
||||
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package options
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
// ensure libs have a chance to globally register their flags
|
||||
_ "github.com/google/cadvisor/container/common"
|
||||
_ "github.com/google/cadvisor/container/containerd"
|
||||
_ "github.com/google/cadvisor/container/docker"
|
||||
_ "github.com/google/cadvisor/container/raw"
|
||||
_ "github.com/google/cadvisor/machine"
|
||||
_ "github.com/google/cadvisor/manager"
|
||||
_ "github.com/google/cadvisor/storage"
|
||||
)
|
||||
|
||||
// addCadvisorFlags adds flags from cadvisor
|
||||
func addCadvisorFlags(fs *pflag.FlagSet) {
|
||||
// lookup flags in global flag set and re-register the values with our flagset
|
||||
global := flag.CommandLine
|
||||
local := pflag.NewFlagSet(os.Args[0], pflag.ExitOnError)
|
||||
|
||||
// These flags were also implicit from cadvisor, but are actually used by something in the core repo:
|
||||
// TODO(mtaufen): This one is stil used by our salt, but for heaven's sake it's even deprecated in cadvisor
|
||||
register(global, local, "docker_root")
|
||||
// e2e node tests rely on this
|
||||
register(global, local, "housekeeping_interval")
|
||||
|
||||
// These flags were implicit from cadvisor, and are mistakes that should be registered deprecated:
|
||||
const deprecated = "This is a cadvisor flag that was mistakenly registered with the Kubelet. Due to legacy concerns, it will follow the standard CLI deprecation timeline before being removed."
|
||||
|
||||
registerDeprecated(global, local, "application_metrics_count_limit", deprecated)
|
||||
registerDeprecated(global, local, "boot_id_file", deprecated)
|
||||
registerDeprecated(global, local, "container_hints", deprecated)
|
||||
registerDeprecated(global, local, "containerd", deprecated)
|
||||
registerDeprecated(global, local, "docker", deprecated)
|
||||
registerDeprecated(global, local, "docker_env_metadata_whitelist", deprecated)
|
||||
registerDeprecated(global, local, "docker_only", deprecated)
|
||||
registerDeprecated(global, local, "docker-tls", deprecated)
|
||||
registerDeprecated(global, local, "docker-tls-ca", deprecated)
|
||||
registerDeprecated(global, local, "docker-tls-cert", deprecated)
|
||||
registerDeprecated(global, local, "docker-tls-key", deprecated)
|
||||
registerDeprecated(global, local, "enable_load_reader", deprecated)
|
||||
registerDeprecated(global, local, "event_storage_age_limit", deprecated)
|
||||
registerDeprecated(global, local, "event_storage_event_limit", deprecated)
|
||||
registerDeprecated(global, local, "global_housekeeping_interval", deprecated)
|
||||
registerDeprecated(global, local, "log_cadvisor_usage", deprecated)
|
||||
registerDeprecated(global, local, "machine_id_file", deprecated)
|
||||
registerDeprecated(global, local, "storage_driver_user", deprecated)
|
||||
registerDeprecated(global, local, "storage_driver_password", deprecated)
|
||||
registerDeprecated(global, local, "storage_driver_host", deprecated)
|
||||
registerDeprecated(global, local, "storage_driver_db", deprecated)
|
||||
registerDeprecated(global, local, "storage_driver_table", deprecated)
|
||||
registerDeprecated(global, local, "storage_driver_secure", deprecated)
|
||||
registerDeprecated(global, local, "storage_driver_buffer_duration", deprecated)
|
||||
|
||||
// finally, add cadvisor flags to the provided flagset
|
||||
fs.AddFlagSet(local)
|
||||
}
|
26
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/globalflags_other.go
generated
vendored
Normal file
26
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/globalflags_other.go
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
// +build !linux
|
||||
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package options
|
||||
|
||||
import (
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
func addCadvisorFlags(fs *pflag.FlagSet) {
|
||||
}
|
152
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/options.go
generated
vendored
152
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/options.go
generated
vendored
@ -27,6 +27,7 @@ import (
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
utilvalidation "k8s.io/apimachinery/pkg/util/validation"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/apiserver/pkg/util/flag"
|
||||
"k8s.io/kubernetes/pkg/apis/componentconfig"
|
||||
@ -34,12 +35,16 @@ import (
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
|
||||
kubeletscheme "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/scheme"
|
||||
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1alpha1"
|
||||
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1beta1"
|
||||
kubeletconfigvalidation "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/validation"
|
||||
"k8s.io/kubernetes/pkg/kubelet/config"
|
||||
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
|
||||
"k8s.io/kubernetes/pkg/master/ports"
|
||||
utiltaints "k8s.io/kubernetes/pkg/util/taints"
|
||||
)
|
||||
|
||||
const defaultRootDir = "/var/lib/kubelet"
|
||||
|
||||
// A configuration field should go in KubeletFlags instead of KubeletConfiguration if any of these are true:
|
||||
// - its value will never, or cannot safely be changed during the lifetime of a node
|
||||
// - its value cannot be safely shared between nodes at the same time (e.g. a hostname)
|
||||
@ -47,7 +52,7 @@ import (
|
||||
// In general, please try to avoid adding flags or configuration fields,
|
||||
// we already have a confusingly large amount of them.
|
||||
type KubeletFlags struct {
|
||||
KubeConfig flag.StringFlag
|
||||
KubeConfig string
|
||||
BootstrapKubeconfig string
|
||||
RotateCertificates bool
|
||||
|
||||
@ -60,9 +65,12 @@ type KubeletFlags struct {
|
||||
// Kubelet's runonce mode anymore, so it may be a candidate
|
||||
// for deprecation and removal.
|
||||
// If runOnce is true, the Kubelet will check the API server once for pods,
|
||||
// run those in addition to the pods specified by the local manifest, and exit.
|
||||
// run those in addition to the pods specified by static pod files, and exit.
|
||||
RunOnce bool
|
||||
|
||||
// enableServer enables the Kubelet's server
|
||||
EnableServer bool
|
||||
|
||||
// HostnameOverride is the hostname used to identify the kubelet instead
|
||||
// of the actual hostname.
|
||||
HostnameOverride string
|
||||
@ -101,11 +109,10 @@ type KubeletFlags struct {
|
||||
// To use this flag, the DynamicKubeletConfig feature gate must be enabled.
|
||||
DynamicConfigDir flag.StringFlag
|
||||
|
||||
// The Kubelet will look in this directory for an init configuration.
|
||||
// The Kubelet will load its initial configuration from this file.
|
||||
// The path may be absolute or relative; relative paths are under the Kubelet's current working directory.
|
||||
// Omit this flag to use the combination of built-in default configuration values and flags.
|
||||
// To use this flag, the KubeletConfigFile feature gate must be enabled.
|
||||
InitConfigDir flag.StringFlag
|
||||
KubeletConfigFile string
|
||||
|
||||
// registerNode enables automatic registration with the apiserver.
|
||||
RegisterNode bool
|
||||
@ -115,6 +122,9 @@ type KubeletFlags struct {
|
||||
// is true and upon the initial registration of the node.
|
||||
RegisterWithTaints []core.Taint
|
||||
|
||||
// cAdvisorPort is the port of the localhost cAdvisor endpoint (set to 0 to disable)
|
||||
CAdvisorPort int32
|
||||
|
||||
// EXPERIMENTAL FLAGS
|
||||
// Whitelist of unsafe sysctls or sysctl patterns (ending in *).
|
||||
// +optional
|
||||
@ -178,8 +188,6 @@ type KubeletFlags struct {
|
||||
// schedulable. Won't have any effect if register-node is false.
|
||||
// DEPRECATED: use registerWithTaints instead
|
||||
RegisterSchedulable bool
|
||||
// RequireKubeConfig is deprecated! A valid KubeConfig is now required if --kubeconfig is provided.
|
||||
RequireKubeConfig bool
|
||||
// nonMasqueradeCIDR configures masquerading: traffic to IPs outside this range will use IP masquerade.
|
||||
NonMasqueradeCIDR string
|
||||
// This flag, if set, instructs the kubelet to keep volumes from terminated pods mounted to the node.
|
||||
@ -187,6 +195,19 @@ type KubeletFlags struct {
|
||||
KeepTerminatedPodVolumes bool
|
||||
// enable gathering custom metrics.
|
||||
EnableCustomMetrics bool
|
||||
// allowPrivileged enables containers to request privileged mode.
|
||||
// Defaults to false.
|
||||
AllowPrivileged bool
|
||||
// hostNetworkSources is a comma-separated list of sources from which the
|
||||
// Kubelet allows pods to use of host network. Defaults to "*". Valid
|
||||
// options are "file", "http", "api", and "*" (all sources).
|
||||
HostNetworkSources []string
|
||||
// hostPIDSources is a comma-separated list of sources from which the
|
||||
// Kubelet allows pods to use the host pid namespace. Defaults to "*".
|
||||
HostPIDSources []string
|
||||
// hostIPCSources is a comma-separated list of sources from which the
|
||||
// Kubelet allows pods to use the host ipc namespace. Defaults to "*".
|
||||
HostIPCSources []string
|
||||
}
|
||||
|
||||
// NewKubeletFlags will create a new KubeletFlags with default values
|
||||
@ -199,12 +220,10 @@ func NewKubeletFlags() *KubeletFlags {
|
||||
}
|
||||
|
||||
return &KubeletFlags{
|
||||
// TODO(#41161:v1.10.0): Remove the default kubeconfig path and --require-kubeconfig.
|
||||
RequireKubeConfig: false,
|
||||
KubeConfig: flag.NewStringFlag("/var/lib/kubelet/kubeconfig"),
|
||||
EnableServer: true,
|
||||
ContainerRuntimeOptions: *NewContainerRuntimeOptions(),
|
||||
CertDirectory: "/var/lib/kubelet/pki",
|
||||
RootDirectory: v1alpha1.DefaultRootDir,
|
||||
RootDirectory: defaultRootDir,
|
||||
MasterServiceNamespace: metav1.NamespaceDefault,
|
||||
MaxContainerCount: -1,
|
||||
MaxPerPodContainerCount: 1,
|
||||
@ -220,7 +239,12 @@ func NewKubeletFlags() *KubeletFlags {
|
||||
NodeLabels: make(map[string]string),
|
||||
VolumePluginDir: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec/",
|
||||
RegisterNode: true,
|
||||
SeccompProfileRoot: filepath.Join(v1alpha1.DefaultRootDir, "seccomp"),
|
||||
SeccompProfileRoot: filepath.Join(defaultRootDir, "seccomp"),
|
||||
HostNetworkSources: []string{kubetypes.AllSource},
|
||||
HostPIDSources: []string{kubetypes.AllSource},
|
||||
HostIPCSources: []string{kubetypes.AllSource},
|
||||
// TODO(#56523): default CAdvisorPort to 0 (disabled) and deprecate it
|
||||
CAdvisorPort: 4194,
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,9 +253,8 @@ func ValidateKubeletFlags(f *KubeletFlags) error {
|
||||
if f.DynamicConfigDir.Provided() && !utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) {
|
||||
return fmt.Errorf("the DynamicKubeletConfig feature gate must be enabled in order to use the --dynamic-config-dir flag")
|
||||
}
|
||||
// ensure that nobody sets InitConfigDir if the KubeletConfigFile feature gate is turned off
|
||||
if f.InitConfigDir.Provided() && !utilfeature.DefaultFeatureGate.Enabled(features.KubeletConfigFile) {
|
||||
return fmt.Errorf("the KubeletConfigFile feature gate must be enabled in order to use the --init-config-dir flag")
|
||||
if f.CAdvisorPort != 0 && utilvalidation.IsValidPortNum(int(f.CAdvisorPort)) != nil {
|
||||
return fmt.Errorf("invalid configuration: CAdvisorPort (--cadvisor-port) %v must be between 0 and 65535, inclusive", f.CAdvisorPort)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -242,15 +265,30 @@ func NewKubeletConfiguration() (*kubeletconfig.KubeletConfiguration, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
versioned := &v1alpha1.KubeletConfiguration{}
|
||||
versioned := &v1beta1.KubeletConfiguration{}
|
||||
scheme.Default(versioned)
|
||||
config := &kubeletconfig.KubeletConfiguration{}
|
||||
if err := scheme.Convert(versioned, config, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
applyLegacyDefaults(config)
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// applyLegacyDefaults applies legacy default values to the KubeletConfiguration in order to
|
||||
// preserve the command line API. This is used to construct the baseline default KubeletConfiguration
|
||||
// before the first round of flag parsing.
|
||||
func applyLegacyDefaults(kc *kubeletconfig.KubeletConfiguration) {
|
||||
// --anonymous-auth
|
||||
kc.Authentication.Anonymous.Enabled = true
|
||||
// --authentication-token-webhook
|
||||
kc.Authentication.Webhook.Enabled = false
|
||||
// --authorization-mode
|
||||
kc.Authorization.Mode = kubeletconfig.KubeletAuthorizationModeAlwaysAllow
|
||||
// --read-only-port
|
||||
kc.ReadOnlyPort = ports.KubeletReadOnlyPort
|
||||
}
|
||||
|
||||
// KubeletServer encapsulates all of the parameters necessary for starting up
|
||||
// a kubelet. These can either be set via command line or directly.
|
||||
type KubeletServer struct {
|
||||
@ -292,10 +330,8 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
|
||||
func (f *KubeletFlags) AddFlags(fs *pflag.FlagSet) {
|
||||
f.ContainerRuntimeOptions.AddFlags(fs)
|
||||
|
||||
fs.Var(&f.KubeConfig, "kubeconfig", "Path to a kubeconfig file, specifying how to connect to the API server.")
|
||||
// TODO(#41161:v1.10.0): Remove the default kubeconfig path and --require-kubeconfig.
|
||||
fs.BoolVar(&f.RequireKubeConfig, "require-kubeconfig", f.RequireKubeConfig, "This flag is no longer necessary. It has been deprecated and will be removed in a future version.")
|
||||
fs.MarkDeprecated("require-kubeconfig", "You no longer need to use --require-kubeconfig. This will be removed in a future version. Providing --kubeconfig enables API server mode, omitting --kubeconfig enables standalone mode unless --require-kubeconfig=true is also set. In the latter case, the legacy default kubeconfig path will be used until --require-kubeconfig is removed.")
|
||||
fs.StringVar(&f.KubeletConfigFile, "config", f.KubeletConfigFile, "The Kubelet will load its initial configuration from this file. The path may be absolute or relative; relative paths start at the Kubelet's current working directory. Omit this flag to use the built-in default configuration values. Command-line flags override configuration from this file.")
|
||||
fs.StringVar(&f.KubeConfig, "kubeconfig", f.KubeConfig, "Path to a kubeconfig file, specifying how to connect to the API server. Providing --kubeconfig enables API server mode, omitting --kubeconfig enables standalone mode.")
|
||||
|
||||
fs.MarkDeprecated("experimental-bootstrap-kubeconfig", "Use --bootstrap-kubeconfig")
|
||||
fs.StringVar(&f.BootstrapKubeconfig, "experimental-bootstrap-kubeconfig", f.BootstrapKubeconfig, "deprecated: use --bootstrap-kubeconfig")
|
||||
@ -308,7 +344,8 @@ func (f *KubeletFlags) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.BoolVar(&f.ReallyCrashForTesting, "really-crash-for-testing", f.ReallyCrashForTesting, "If true, when panics occur crash. Intended for testing.")
|
||||
fs.Float64Var(&f.ChaosChance, "chaos-chance", f.ChaosChance, "If > 0.0, introduce random client errors and latency. Intended for testing.")
|
||||
|
||||
fs.BoolVar(&f.RunOnce, "runonce", f.RunOnce, "If true, exit after spawning pods from local manifests or remote urls. Exclusive with --enable-server")
|
||||
fs.BoolVar(&f.RunOnce, "runonce", f.RunOnce, "If true, exit after spawning pods from static pod files or remote urls. Exclusive with --enable-server")
|
||||
fs.BoolVar(&f.EnableServer, "enable-server", f.EnableServer, "Enable the Kubelet's server")
|
||||
|
||||
fs.StringVar(&f.HostnameOverride, "hostname-override", f.HostnameOverride, "If non-empty, will use this string as identification instead of the actual hostname.")
|
||||
|
||||
@ -325,30 +362,31 @@ func (f *KubeletFlags) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.StringVar(&f.RootDirectory, "root-dir", f.RootDirectory, "Directory path for managing kubelet files (volume mounts,etc).")
|
||||
|
||||
fs.Var(&f.DynamicConfigDir, "dynamic-config-dir", "The Kubelet will use this directory for checkpointing downloaded configurations and tracking configuration health. The Kubelet will create this directory if it does not already exist. The path may be absolute or relative; relative paths start at the Kubelet's current working directory. Providing this flag enables dynamic Kubelet configuration. Presently, you must also enable the DynamicKubeletConfig feature gate to pass this flag.")
|
||||
fs.Var(&f.InitConfigDir, "init-config-dir", "The Kubelet will look in this directory for the init configuration. The path may be absolute or relative; relative paths start at the Kubelet's current working directory. Omit this argument to use the built-in default configuration values. Presently, you must also enable the KubeletConfigFile feature gate to pass this flag.")
|
||||
|
||||
fs.BoolVar(&f.RegisterNode, "register-node", f.RegisterNode, "Register the node with the apiserver. If --kubeconfig is not provided, this flag is irrelevant, as the Kubelet won't have an apiserver to register with. Default=true.")
|
||||
fs.Var(utiltaints.NewTaintsVar(&f.RegisterWithTaints), "register-with-taints", "Register the node with the given list of taints (comma separated \"<key>=<value>:<effect>\"). No-op if register-node is false.")
|
||||
fs.BoolVar(&f.Containerized, "containerized", f.Containerized, "Running kubelet in a container.")
|
||||
|
||||
// EXPERIMENTAL FLAGS
|
||||
fs.StringVar(&f.ExperimentalMounterPath, "experimental-mounter-path", f.ExperimentalMounterPath, "[Experimental] Path of mounter binary. Leave empty to use the default mount.")
|
||||
fs.StringSliceVar(&f.AllowedUnsafeSysctls, "experimental-allowed-unsafe-sysctls", f.AllowedUnsafeSysctls, "Comma-separated whitelist of unsafe sysctls or unsafe sysctl patterns (ending in *). Use these at your own risk.")
|
||||
fs.BoolVar(&f.Containerized, "containerized", f.Containerized, "Experimental support for running kubelet in a container. Intended for testing.")
|
||||
fs.BoolVar(&f.ExperimentalKernelMemcgNotification, "experimental-kernel-memcg-notification", f.ExperimentalKernelMemcgNotification, "If enabled, the kubelet will integrate with the kernel memcg notification to determine if memory eviction thresholds are crossed rather than polling.")
|
||||
fs.StringVar(&f.RemoteRuntimeEndpoint, "container-runtime-endpoint", f.RemoteRuntimeEndpoint, "[Experimental] The endpoint of remote runtime service. Currently unix socket is supported on Linux, and tcp is supported on windows. Examples:'unix:///var/run/dockershim.sock', 'tcp://localhost:3735'")
|
||||
fs.StringVar(&f.RemoteImageEndpoint, "image-service-endpoint", f.RemoteImageEndpoint, "[Experimental] The endpoint of remote image service. If not specified, it will be the same with container-runtime-endpoint by default. Currently unix socket is supported on Linux, and tcp is supported on windows. Examples:'unix:///var/run/dockershim.sock', 'tcp://localhost:3735'")
|
||||
fs.BoolVar(&f.ExperimentalCheckNodeCapabilitiesBeforeMount, "experimental-check-node-capabilities-before-mount", f.ExperimentalCheckNodeCapabilitiesBeforeMount, "[Experimental] if set true, the kubelet will check the underlying node for required componenets (binaries, etc.) before performing the mount")
|
||||
fs.BoolVar(&f.ExperimentalCheckNodeCapabilitiesBeforeMount, "experimental-check-node-capabilities-before-mount", f.ExperimentalCheckNodeCapabilitiesBeforeMount, "[Experimental] if set true, the kubelet will check the underlying node for required components (binaries, etc.) before performing the mount")
|
||||
fs.BoolVar(&f.ExperimentalNodeAllocatableIgnoreEvictionThreshold, "experimental-allocatable-ignore-eviction", f.ExperimentalNodeAllocatableIgnoreEvictionThreshold, "When set to 'true', Hard Eviction Thresholds will be ignored while calculating Node Allocatable. See https://kubernetes.io/docs/tasks/administer-cluster/reserve-compute-resources/ for more details. [default=false]")
|
||||
fs.Var(flag.NewMapStringString(&f.ExperimentalQOSReserved), "experimental-qos-reserved", "A set of ResourceName=Percentage (e.g. memory=50%) pairs that describe how pod resource requests are reserved at the QoS level. Currently only memory is supported. [default=none]")
|
||||
bindableNodeLabels := flag.ConfigurationMap(f.NodeLabels)
|
||||
fs.Var(&bindableNodeLabels, "node-labels", "<Warning: Alpha feature> Labels to add when registering the node in the cluster. Labels must be key=value pairs separated by ','.")
|
||||
fs.StringVar(&f.VolumePluginDir, "volume-plugin-dir", f.VolumePluginDir, "<Warning: Alpha feature> The full path of the directory in which to search for additional third party volume plugins")
|
||||
fs.StringVar(&f.VolumePluginDir, "volume-plugin-dir", f.VolumePluginDir, "The full path of the directory in which to search for additional third party volume plugins")
|
||||
fs.StringVar(&f.LockFilePath, "lock-file", f.LockFilePath, "<Warning: Alpha feature> The path to file for kubelet to use as a lock file.")
|
||||
fs.BoolVar(&f.ExitOnLockContention, "exit-on-lock-contention", f.ExitOnLockContention, "Whether kubelet should exit upon lock-file contention.")
|
||||
fs.StringVar(&f.SeccompProfileRoot, "seccomp-profile-root", f.SeccompProfileRoot, "<Warning: Alpha feature> Directory path for seccomp profiles.")
|
||||
fs.StringVar(&f.BootstrapCheckpointPath, "bootstrap-checkpoint-path", f.BootstrapCheckpointPath, "<Warning: Alpha feature> Path to to the directory where the checkpoints are stored")
|
||||
|
||||
// DEPRECATED FLAGS
|
||||
fs.Int32Var(&f.CAdvisorPort, "cadvisor-port", f.CAdvisorPort, "The port of the localhost cAdvisor endpoint (set to 0 to disable)")
|
||||
fs.MarkDeprecated("cadvisor-port", "The default will change to 0 (disabled) in 1.12, and the cadvisor port will be removed entirely in 1.13")
|
||||
fs.DurationVar(&f.MinimumGCAge.Duration, "minimum-container-ttl-duration", f.MinimumGCAge.Duration, "Minimum age for a finished container before it is garbage collected. Examples: '300ms', '10s' or '2h45m'")
|
||||
fs.MarkDeprecated("minimum-container-ttl-duration", "Use --eviction-hard or --eviction-soft instead. Will be removed in a future version.")
|
||||
fs.Int32Var(&f.MaxPerPodContainerCount, "maximum-dead-containers-per-container", f.MaxPerPodContainerCount, "Maximum number of old instances to retain per container. Each container takes up some disk space.")
|
||||
@ -366,22 +404,48 @@ func (f *KubeletFlags) AddFlags(fs *pflag.FlagSet) {
|
||||
// TODO(#54161:v1.11.0): Remove --enable-custom-metrics flag, it is deprecated.
|
||||
fs.BoolVar(&f.EnableCustomMetrics, "enable-custom-metrics", f.EnableCustomMetrics, "Support for gathering custom metrics.")
|
||||
fs.MarkDeprecated("enable-custom-metrics", "will be removed in a future version")
|
||||
// TODO(#58010:v1.12.0): Remove --allow-privileged, it is deprecated
|
||||
fs.BoolVar(&f.AllowPrivileged, "allow-privileged", f.AllowPrivileged, "If true, allow containers to request privileged mode.")
|
||||
fs.MarkDeprecated("allow-privileged", "will be removed in a future version")
|
||||
// TODO(#58010:v1.12.0): Remove --host-network-sources, it is deprecated
|
||||
fs.StringSliceVar(&f.HostNetworkSources, "host-network-sources", f.HostNetworkSources, "Comma-separated list of sources from which the Kubelet allows pods to use of host network.")
|
||||
fs.MarkDeprecated("host-network-sources", "will be removed in a future version")
|
||||
// TODO(#58010:v1.12.0): Remove --host-pid-sources, it is deprecated
|
||||
fs.StringSliceVar(&f.HostPIDSources, "host-pid-sources", f.HostPIDSources, "Comma-separated list of sources from which the Kubelet allows pods to use the host pid namespace.")
|
||||
fs.MarkDeprecated("host-pid-sources", "will be removed in a future version")
|
||||
// TODO(#58010:v1.12.0): Remove --host-ipc-sources, it is deprecated
|
||||
fs.StringSliceVar(&f.HostIPCSources, "host-ipc-sources", f.HostIPCSources, "Comma-separated list of sources from which the Kubelet allows pods to use the host ipc namespace.")
|
||||
fs.MarkDeprecated("host-ipc-sources", "will be removed in a future version")
|
||||
|
||||
}
|
||||
|
||||
// AddKubeletConfigFlags adds flags for a specific kubeletconfig.KubeletConfiguration to the specified FlagSet
|
||||
func AddKubeletConfigFlags(fs *pflag.FlagSet, c *kubeletconfig.KubeletConfiguration) {
|
||||
fs.BoolVar(&c.FailSwapOn, "fail-swap-on", true, "Makes the Kubelet fail to start if swap is enabled on the node. ")
|
||||
fs.BoolVar(&c.FailSwapOn, "experimental-fail-swap-on", true, "DEPRECATED: please use --fail-swap-on instead.")
|
||||
func AddKubeletConfigFlags(mainfs *pflag.FlagSet, c *kubeletconfig.KubeletConfiguration) {
|
||||
fs := pflag.NewFlagSet("", pflag.ExitOnError)
|
||||
defer func() {
|
||||
// All KubeletConfiguration flags are now deprecated, and any new flags that point to
|
||||
// KubeletConfiguration fields are deprecated-on-creation. When removing flags at the end
|
||||
// of their deprecation period, be careful to check that they have *actually* been deprecated
|
||||
// members of the KubeletConfiguration for the entire deprecation period:
|
||||
// e.g. if a flag was added after this deprecation function, it may not be at the end
|
||||
// of its lifetime yet, even if the rest are.
|
||||
deprecated := "This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information."
|
||||
fs.VisitAll(func(f *pflag.Flag) {
|
||||
f.Deprecated = deprecated
|
||||
})
|
||||
mainfs.AddFlagSet(fs)
|
||||
}()
|
||||
|
||||
fs.BoolVar(&c.FailSwapOn, "fail-swap-on", c.FailSwapOn, "Makes the Kubelet fail to start if swap is enabled on the node. ")
|
||||
fs.BoolVar(&c.FailSwapOn, "experimental-fail-swap-on", c.FailSwapOn, "DEPRECATED: please use --fail-swap-on instead.")
|
||||
fs.MarkDeprecated("experimental-fail-swap-on", "This flag is deprecated and will be removed in future releases. please use --fail-swap-on instead.")
|
||||
|
||||
fs.StringVar(&c.PodManifestPath, "pod-manifest-path", c.PodManifestPath, "Path to the directory containing pod manifest files to run, or the path to a single pod manifest file. Files starting with dots will be ignored.")
|
||||
fs.StringVar(&c.StaticPodPath, "pod-manifest-path", c.StaticPodPath, "Path to the directory containing static pod files to run, or the path to a single static pod file. Files starting with dots will be ignored.")
|
||||
fs.DurationVar(&c.SyncFrequency.Duration, "sync-frequency", c.SyncFrequency.Duration, "Max period between synchronizing running containers and config")
|
||||
fs.DurationVar(&c.FileCheckFrequency.Duration, "file-check-frequency", c.FileCheckFrequency.Duration, "Duration between checking config files for new data")
|
||||
fs.DurationVar(&c.HTTPCheckFrequency.Duration, "http-check-frequency", c.HTTPCheckFrequency.Duration, "Duration between checking http for new data")
|
||||
fs.StringVar(&c.ManifestURL, "manifest-url", c.ManifestURL, "URL for accessing the container manifest")
|
||||
fs.Var(flag.NewColonSeparatedMultimapStringString(&c.ManifestURLHeader), "manifest-url-header", "Comma-separated list of HTTP headers to use when accessing the manifest URL. Multiple headers with the same name will be added in the same order provided. This flag can be repeatedly invoked. For example: `--manifest-url-header 'a:hello,b:again,c:world' --manifest-url-header 'b:beautiful'`")
|
||||
fs.BoolVar(&c.EnableServer, "enable-server", c.EnableServer, "Enable the Kubelet's server")
|
||||
fs.StringVar(&c.StaticPodURL, "manifest-url", c.StaticPodURL, "URL for accessing additional Pod specifications to run")
|
||||
fs.Var(flag.NewColonSeparatedMultimapStringString(&c.StaticPodURLHeader), "manifest-url-header", "Comma-separated list of HTTP headers to use when accessing the url provided to --manifest-url. Multiple headers with the same name will be added in the same order provided. This flag can be repeatedly invoked. For example: `--manifest-url-header 'a:hello,b:again,c:world' --manifest-url-header 'b:beautiful'`")
|
||||
fs.Var(componentconfig.IPVar{Val: &c.Address}, "address", "The IP address for the Kubelet to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
|
||||
fs.Int32Var(&c.Port, "port", c.Port, "The port for the Kubelet to serve on.")
|
||||
fs.Int32Var(&c.ReadOnlyPort, "read-only-port", c.ReadOnlyPort, "The read-only port for the Kubelet to serve on with no authentication/authorization (set to 0 to disable)")
|
||||
@ -413,19 +477,21 @@ func AddKubeletConfigFlags(fs *pflag.FlagSet, c *kubeletconfig.KubeletConfigurat
|
||||
"If --tls-cert-file and --tls-private-key-file are not provided, a self-signed certificate and key "+
|
||||
"are generated for the public address and saved to the directory passed to --cert-dir.")
|
||||
fs.StringVar(&c.TLSPrivateKeyFile, "tls-private-key-file", c.TLSPrivateKeyFile, "File containing x509 private key matching --tls-cert-file.")
|
||||
fs.StringSliceVar(&c.TLSCipherSuites, "tls-cipher-suites", c.TLSCipherSuites,
|
||||
"Comma-separated list of cipher suites for the server. "+
|
||||
"Values are from tls package constants (https://golang.org/pkg/crypto/tls/#pkg-constants). "+
|
||||
"If omitted, the default Go cipher suites will be used")
|
||||
fs.StringVar(&c.TLSMinVersion, "tls-min-version", c.TLSMinVersion,
|
||||
"Minimum TLS version supported. "+
|
||||
"Value must match version names from https://golang.org/pkg/crypto/tls/#pkg-constants.")
|
||||
|
||||
fs.BoolVar(&c.AllowPrivileged, "allow-privileged", c.AllowPrivileged, "If true, allow containers to request privileged mode.")
|
||||
fs.StringSliceVar(&c.HostNetworkSources, "host-network-sources", c.HostNetworkSources, "Comma-separated list of sources from which the Kubelet allows pods to use of host network.")
|
||||
fs.StringSliceVar(&c.HostPIDSources, "host-pid-sources", c.HostPIDSources, "Comma-separated list of sources from which the Kubelet allows pods to use the host pid namespace.")
|
||||
fs.StringSliceVar(&c.HostIPCSources, "host-ipc-sources", c.HostIPCSources, "Comma-separated list of sources from which the Kubelet allows pods to use the host ipc namespace.")
|
||||
fs.Int32Var(&c.RegistryPullQPS, "registry-qps", c.RegistryPullQPS, "If > 0, limit registry pull QPS to this value. If 0, unlimited.")
|
||||
fs.Int32Var(&c.RegistryBurst, "registry-burst", c.RegistryBurst, "Maximum size of a bursty pulls, temporarily allows pulls to burst to this number, while still not exceeding registry-qps. Only used if --registry-qps > 0")
|
||||
fs.Int32Var(&c.EventRecordQPS, "event-qps", c.EventRecordQPS, "If > 0, limit event creations per second to this value. If 0, unlimited.")
|
||||
fs.Int32Var(&c.EventBurst, "event-burst", c.EventBurst, "Maximum size of a bursty event records, temporarily allows event records to burst to this number, while still not exceeding event-qps. Only used if --event-qps > 0")
|
||||
|
||||
fs.BoolVar(&c.EnableDebuggingHandlers, "enable-debugging-handlers", c.EnableDebuggingHandlers, "Enables server endpoints for log collection and local running of containers and commands")
|
||||
fs.BoolVar(&c.EnableContentionProfiling, "contention-profiling", false, "Enable lock contention profiling, if profiling is enabled")
|
||||
fs.Int32Var(&c.CAdvisorPort, "cadvisor-port", c.CAdvisorPort, "The port of the localhost cAdvisor endpoint (set to 0 to disable)")
|
||||
fs.BoolVar(&c.EnableContentionProfiling, "contention-profiling", c.EnableContentionProfiling, "Enable lock contention profiling, if profiling is enabled")
|
||||
fs.Int32Var(&c.HealthzPort, "healthz-port", c.HealthzPort, "The port of the localhost healthz endpoint (set to 0 to disable)")
|
||||
fs.Var(componentconfig.IPVar{Val: &c.HealthzBindAddress}, "healthz-bind-address", "The IP address for the healthz server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
|
||||
fs.Int32Var(&c.OOMScoreAdj, "oom-score-adj", c.OOMScoreAdj, "The oom-score-adj value for kubelet process. Values must be within the range [-1000, 1000]")
|
||||
@ -452,13 +518,17 @@ func AddKubeletConfigFlags(fs *pflag.FlagSet, c *kubeletconfig.KubeletConfigurat
|
||||
fs.StringVar(&c.HairpinMode, "hairpin-mode", c.HairpinMode, "How should the kubelet setup hairpin NAT. This allows endpoints of a Service to loadbalance back to themselves if they should try to access their own Service. Valid values are \"promiscuous-bridge\", \"hairpin-veth\" and \"none\".")
|
||||
fs.Int32Var(&c.MaxPods, "max-pods", c.MaxPods, "Number of Pods that can run on this Kubelet.")
|
||||
|
||||
fs.StringVar(&c.PodCIDR, "pod-cidr", "", "The CIDR to use for pod IP addresses, only used in standalone mode. In cluster mode, this is obtained from the master.")
|
||||
fs.StringVar(&c.PodCIDR, "pod-cidr", c.PodCIDR, "The CIDR to use for pod IP addresses, only used in standalone mode. In cluster mode, this is obtained from the master. For IPv6, the minimum length of the cluster or pod CIDR is /66.")
|
||||
fs.Int64Var(&c.PodPidsLimit, "pod-max-pids", c.PodPidsLimit, "<Warning: Alpha feature> Set the maximum number of processes per pod.")
|
||||
|
||||
fs.StringVar(&c.ResolverConfig, "resolv-conf", c.ResolverConfig, "Resolver configuration file used as the basis for the container DNS resolution configuration.")
|
||||
fs.BoolVar(&c.CPUCFSQuota, "cpu-cfs-quota", c.CPUCFSQuota, "Enable CPU CFS quota enforcement for containers that specify CPU limits")
|
||||
fs.BoolVar(&c.EnableControllerAttachDetach, "enable-controller-attach-detach", c.EnableControllerAttachDetach, "Enables the Attach/Detach controller to manage attachment/detachment of volumes scheduled to this node, and disables kubelet from executing any attach/detach operations")
|
||||
fs.BoolVar(&c.MakeIPTablesUtilChains, "make-iptables-util-chains", c.MakeIPTablesUtilChains, "If true, kubelet will ensure iptables utility rules are present on host.")
|
||||
fs.Int32Var(&c.IPTablesMasqueradeBit, "iptables-masquerade-bit", c.IPTablesMasqueradeBit, "The bit of the fwmark space to mark packets for SNAT. Must be within the range [0, 31]. Please match this parameter with corresponding parameter in kube-proxy.")
|
||||
fs.Int32Var(&c.IPTablesDropBit, "iptables-drop-bit", c.IPTablesDropBit, "The bit of the fwmark space to mark packets for dropping. Must be within the range [0, 31].")
|
||||
fs.StringVar(&c.ContainerLogMaxSize, "container-log-max-size", c.ContainerLogMaxSize, "<Warning: Alpha feature> Set the maximum size (e.g. 10Mi) of container log file before it is rotated.")
|
||||
fs.Int32Var(&c.ContainerLogMaxFiles, "container-log-max-files", c.ContainerLogMaxFiles, "<Warning: Alpha feature> Set the maximum number of container log files that can be present for a container. The number must be >= 2.")
|
||||
|
||||
// Flags intended for testing, not recommended used in production environments.
|
||||
fs.Int64Var(&c.MaxOpenFiles, "max-open-files", c.MaxOpenFiles, "Number of files that can be opened by Kubelet process.")
|
||||
@ -480,7 +550,7 @@ func AddKubeletConfigFlags(fs *pflag.FlagSet, c *kubeletconfig.KubeletConfigurat
|
||||
// Node Allocatable Flags
|
||||
fs.Var(flag.NewMapStringString(&c.SystemReserved), "system-reserved", "A set of ResourceName=ResourceQuantity (e.g. cpu=200m,memory=500Mi,ephemeral-storage=1Gi) pairs that describe resources reserved for non-kubernetes components. Currently only cpu and memory are supported. See http://kubernetes.io/docs/user-guide/compute-resources for more detail. [default=none]")
|
||||
fs.Var(flag.NewMapStringString(&c.KubeReserved), "kube-reserved", "A set of ResourceName=ResourceQuantity (e.g. cpu=200m,memory=500Mi,ephemeral-storage=1Gi) pairs that describe resources reserved for kubernetes system components. Currently cpu, memory and local ephemeral storage for root file system are supported. See http://kubernetes.io/docs/user-guide/compute-resources for more detail. [default=none]")
|
||||
fs.StringSliceVar(&c.EnforceNodeAllocatable, "enforce-node-allocatable", c.EnforceNodeAllocatable, "A comma separated list of levels of node allocatable enforcement to be enforced by kubelet. Acceptible options are 'pods', 'system-reserved' & 'kube-reserved'. If the latter two options are specified, '--system-reserved-cgroup' & '--kube-reserved-cgroup' must also be set respectively. See https://kubernetes.io/docs/tasks/administer-cluster/reserve-compute-resources/ for more details.")
|
||||
fs.StringSliceVar(&c.EnforceNodeAllocatable, "enforce-node-allocatable", c.EnforceNodeAllocatable, "A comma separated list of levels of node allocatable enforcement to be enforced by kubelet. Acceptable options are 'none', 'pods', 'system-reserved', and 'kube-reserved'. If the latter two options are specified, '--system-reserved-cgroup' and '--kube-reserved-cgroup' must also be set, respectively. If 'none' is specified, no additional options should be set. See https://kubernetes.io/docs/tasks/administer-cluster/reserve-compute-resources/ for more details.")
|
||||
fs.StringVar(&c.SystemReservedCgroup, "system-reserved-cgroup", c.SystemReservedCgroup, "Absolute name of the top level cgroup that is used to manage non-kubernetes components for which compute resources were reserved via '--system-reserved' flag. Ex. '/system-reserved'. [default='']")
|
||||
fs.StringVar(&c.KubeReservedCgroup, "kube-reserved-cgroup", c.KubeReservedCgroup, "Absolute name of the top level cgroup that is used to manage kubernetes components for which compute resources were reserved via '--kube-reserved' flag. Ex. '/kube-reserved'. [default='']")
|
||||
}
|
||||
|
2
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/options_test.go
generated
vendored
2
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/options_test.go
generated
vendored
@ -36,9 +36,7 @@ func newKubeletServerOrDie() *KubeletServer {
|
||||
}
|
||||
|
||||
func cleanFlags(s *KubeletServer) {
|
||||
s.KubeConfig = utilflag.NewStringFlag(s.KubeConfig.Value())
|
||||
s.DynamicConfigDir = utilflag.NewStringFlag(s.DynamicConfigDir.Value())
|
||||
s.InitConfigDir = utilflag.NewStringFlag(s.InitConfigDir.Value())
|
||||
}
|
||||
|
||||
// TestRoundTrip ensures that flag values from the Kubelet can be serialized
|
||||
|
411
vendor/k8s.io/kubernetes/cmd/kubelet/app/server.go
generated
vendored
411
vendor/k8s.io/kubernetes/cmd/kubelet/app/server.go
generated
vendored
@ -18,6 +18,7 @@ limitations under the License.
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -64,7 +65,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/kubelet"
|
||||
kubeletconfiginternal "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
|
||||
kubeletscheme "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/scheme"
|
||||
kubeletconfigv1alpha1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1alpha1"
|
||||
kubeletconfigv1beta1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1beta1"
|
||||
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
|
||||
kubeletcertificate "k8s.io/kubernetes/pkg/kubelet/certificate"
|
||||
"k8s.io/kubernetes/pkg/kubelet/certificate/bootstrap"
|
||||
@ -75,11 +76,14 @@ import (
|
||||
dockerremote "k8s.io/kubernetes/pkg/kubelet/dockershim/remote"
|
||||
"k8s.io/kubernetes/pkg/kubelet/eviction"
|
||||
evictionapi "k8s.io/kubernetes/pkg/kubelet/eviction/api"
|
||||
"k8s.io/kubernetes/pkg/kubelet/kubeletconfig"
|
||||
dynamickubeletconfig "k8s.io/kubernetes/pkg/kubelet/kubeletconfig"
|
||||
"k8s.io/kubernetes/pkg/kubelet/kubeletconfig/configfiles"
|
||||
"k8s.io/kubernetes/pkg/kubelet/server"
|
||||
"k8s.io/kubernetes/pkg/kubelet/server/streaming"
|
||||
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
|
||||
"k8s.io/kubernetes/pkg/util/configz"
|
||||
utilfs "k8s.io/kubernetes/pkg/util/filesystem"
|
||||
utilflag "k8s.io/kubernetes/pkg/util/flag"
|
||||
"k8s.io/kubernetes/pkg/util/flock"
|
||||
kubeio "k8s.io/kubernetes/pkg/util/io"
|
||||
"k8s.io/kubernetes/pkg/util/mount"
|
||||
@ -87,6 +91,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/util/oom"
|
||||
"k8s.io/kubernetes/pkg/util/rlimit"
|
||||
"k8s.io/kubernetes/pkg/version"
|
||||
"k8s.io/kubernetes/pkg/version/verflag"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -96,9 +101,14 @@ const (
|
||||
|
||||
// NewKubeletCommand creates a *cobra.Command object with default parameters
|
||||
func NewKubeletCommand() *cobra.Command {
|
||||
// ignore the error, as this is just for generating docs and the like
|
||||
s, _ := options.NewKubeletServer()
|
||||
s.AddFlags(pflag.CommandLine)
|
||||
cleanFlagSet := pflag.NewFlagSet(componentKubelet, pflag.ContinueOnError)
|
||||
kubeletFlags := options.NewKubeletFlags()
|
||||
kubeletConfig, err := options.NewKubeletConfiguration()
|
||||
// programmer error
|
||||
if err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: componentKubelet,
|
||||
Long: `The kubelet is the primary "node agent" that runs on each
|
||||
@ -120,13 +130,194 @@ is checked every 20 seconds (also configurable with a flag).
|
||||
|
||||
HTTP server: The kubelet can also listen for HTTP and respond to a simple API
|
||||
(underspec'd currently) to submit a new manifest.`,
|
||||
// The Kubelet has special flag parsing requirements to enforce flag precedence rules,
|
||||
// so we do all our parsing manually in Run, below.
|
||||
// DisableFlagParsing=true provides the full set of flags passed to the kubelet in the
|
||||
// `args` arg to Run, without Cobra's interference.
|
||||
DisableFlagParsing: true,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// initial flag parse, since we disable cobra's flag parsing
|
||||
if err := cleanFlagSet.Parse(args); err != nil {
|
||||
cmd.Usage()
|
||||
glog.Fatal(err)
|
||||
}
|
||||
|
||||
// short-circuit on help
|
||||
help, err := cleanFlagSet.GetBool("help")
|
||||
if err != nil {
|
||||
glog.Fatal(`"help" flag is non-bool, programmer error, please correct`)
|
||||
}
|
||||
if help {
|
||||
cmd.Help()
|
||||
return
|
||||
}
|
||||
|
||||
// short-circuit on verflag
|
||||
verflag.PrintAndExitIfRequested()
|
||||
utilflag.PrintFlags(cleanFlagSet)
|
||||
|
||||
// set feature gates from initial flags-based config
|
||||
if err := utilfeature.DefaultFeatureGate.SetFromMap(kubeletConfig.FeatureGates); err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
|
||||
// validate the initial KubeletFlags
|
||||
if err := options.ValidateKubeletFlags(kubeletFlags); err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
|
||||
// load kubelet config file, if provided
|
||||
if configFile := kubeletFlags.KubeletConfigFile; len(configFile) > 0 {
|
||||
kubeletConfig, err = loadConfigFile(configFile)
|
||||
if err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
// We must enforce flag precedence by re-parsing the command line into the new object.
|
||||
// This is necessary to preserve backwards-compatibility across binary upgrades.
|
||||
// See issue #56171 for more details.
|
||||
if err := kubeletConfigFlagPrecedence(kubeletConfig, args); err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
// update feature gates based on new config
|
||||
if err := utilfeature.DefaultFeatureGate.SetFromMap(kubeletConfig.FeatureGates); err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// use dynamic kubelet config, if enabled
|
||||
var kubeletConfigController *dynamickubeletconfig.Controller
|
||||
if dynamicConfigDir := kubeletFlags.DynamicConfigDir.Value(); len(dynamicConfigDir) > 0 {
|
||||
kubeletConfig, kubeletConfigController, err = BootstrapKubeletConfigController(kubeletConfig, dynamicConfigDir)
|
||||
if err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
// We must enforce flag precedence by re-parsing the command line into the new object.
|
||||
// This is necessary to preserve backwards-compatibility across binary upgrades.
|
||||
// See issue #56171 for more details.
|
||||
if err := kubeletConfigFlagPrecedence(kubeletConfig, args); err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
// update feature gates based on new config
|
||||
if err := utilfeature.DefaultFeatureGate.SetFromMap(kubeletConfig.FeatureGates); err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// construct a KubeletServer from kubeletFlags and kubeletConfig
|
||||
kubeletServer := &options.KubeletServer{
|
||||
KubeletFlags: *kubeletFlags,
|
||||
KubeletConfiguration: *kubeletConfig,
|
||||
}
|
||||
|
||||
// use kubeletServer to construct the default KubeletDeps
|
||||
kubeletDeps, err := UnsecuredDependencies(kubeletServer)
|
||||
if err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
|
||||
// add the kubelet config controller to kubeletDeps
|
||||
kubeletDeps.KubeletConfigController = kubeletConfigController
|
||||
|
||||
// start the experimental docker shim, if enabled
|
||||
if kubeletServer.KubeletFlags.ExperimentalDockershim {
|
||||
if err := RunDockershim(&kubeletServer.KubeletFlags, kubeletConfig); err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// run the kubelet
|
||||
if err := Run(kubeletServer, kubeletDeps); err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// keep cleanFlagSet separate, so Cobra doesn't pollute it with the global flags
|
||||
kubeletFlags.AddFlags(cleanFlagSet)
|
||||
options.AddKubeletConfigFlags(cleanFlagSet, kubeletConfig)
|
||||
options.AddGlobalFlags(cleanFlagSet)
|
||||
cleanFlagSet.BoolP("help", "h", false, fmt.Sprintf("help for %s", cmd.Name()))
|
||||
|
||||
// ugly, but necessary, because Cobra's default UsageFunc and HelpFunc pollute the flagset with global flags
|
||||
const usageFmt = "Usage:\n %s\n\nFlags:\n%s"
|
||||
cmd.SetUsageFunc(func(cmd *cobra.Command) error {
|
||||
fmt.Fprintf(cmd.OutOrStderr(), usageFmt, cmd.UseLine(), cleanFlagSet.FlagUsagesWrapped(2))
|
||||
return nil
|
||||
})
|
||||
cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) {
|
||||
fmt.Fprintf(cmd.OutOrStdout(), "%s\n\n"+usageFmt, cmd.Long, cmd.UseLine(), cleanFlagSet.FlagUsagesWrapped(2))
|
||||
})
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// newFlagSetWithGlobals constructs a new pflag.FlagSet with global flags registered
|
||||
// on it.
|
||||
func newFlagSetWithGlobals() *pflag.FlagSet {
|
||||
fs := pflag.NewFlagSet("", pflag.ExitOnError)
|
||||
// set the normalize func, similar to k8s.io/apiserver/pkg/util/flag/flags.go:InitFlags
|
||||
fs.SetNormalizeFunc(flag.WordSepNormalizeFunc)
|
||||
// explicitly add flags from libs that register global flags
|
||||
options.AddGlobalFlags(fs)
|
||||
return fs
|
||||
}
|
||||
|
||||
// newFakeFlagSet constructs a pflag.FlagSet with the same flags as fs, but where
|
||||
// all values have noop Set implementations
|
||||
func newFakeFlagSet(fs *pflag.FlagSet) *pflag.FlagSet {
|
||||
ret := pflag.NewFlagSet("", pflag.ExitOnError)
|
||||
ret.SetNormalizeFunc(fs.GetNormalizeFunc())
|
||||
fs.VisitAll(func(f *pflag.Flag) {
|
||||
ret.VarP(flag.NoOp{}, f.Name, f.Shorthand, f.Usage)
|
||||
})
|
||||
return ret
|
||||
}
|
||||
|
||||
// kubeletConfigFlagPrecedence re-parses flags over the KubeletConfiguration object.
|
||||
// We must enforce flag precedence by re-parsing the command line into the new object.
|
||||
// This is necessary to preserve backwards-compatibility across binary upgrades.
|
||||
// See issue #56171 for more details.
|
||||
func kubeletConfigFlagPrecedence(kc *kubeletconfiginternal.KubeletConfiguration, args []string) error {
|
||||
// We use a throwaway kubeletFlags and a fake global flagset to avoid double-parses,
|
||||
// as some Set implementations accumulate values from multiple flag invocations.
|
||||
fs := newFakeFlagSet(newFlagSetWithGlobals())
|
||||
// register throwaway KubeletFlags
|
||||
options.NewKubeletFlags().AddFlags(fs)
|
||||
// register new KubeletConfiguration
|
||||
options.AddKubeletConfigFlags(fs, kc)
|
||||
// Remember original feature gates, so we can merge with flag gates later
|
||||
original := kc.FeatureGates
|
||||
// re-parse flags
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
// Add back feature gates that were set in the original kc, but not in flags
|
||||
for k, v := range original {
|
||||
if _, ok := kc.FeatureGates[k]; !ok {
|
||||
kc.FeatureGates[k] = v
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadConfigFile(name string) (*kubeletconfiginternal.KubeletConfiguration, error) {
|
||||
const errFmt = "failed to load Kubelet config file %s, error %v"
|
||||
// compute absolute path based on current working dir
|
||||
kubeletConfigFile, err := filepath.Abs(name)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(errFmt, name, err)
|
||||
}
|
||||
loader, err := configfiles.NewFsLoader(utilfs.DefaultFs{}, kubeletConfigFile)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(errFmt, name, err)
|
||||
}
|
||||
kc, err := loader.Load()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(errFmt, name, err)
|
||||
}
|
||||
return kc, err
|
||||
}
|
||||
|
||||
// UnsecuredDependencies returns a Dependencies suitable for being run, or an error if the server setup
|
||||
// is not valid. It will not start any background processes, and does not include authentication/authorization
|
||||
func UnsecuredDependencies(s *options.KubeletServer) (*kubelet.Dependencies, error) {
|
||||
@ -139,7 +330,7 @@ func UnsecuredDependencies(s *options.KubeletServer) (*kubelet.Dependencies, err
|
||||
mounter := mount.New(s.ExperimentalMounterPath)
|
||||
var writer kubeio.Writer = &kubeio.StdWriter{}
|
||||
if s.Containerized {
|
||||
glog.V(2).Info("Running kubelet in containerized mode (experimental)")
|
||||
glog.V(2).Info("Running kubelet in containerized mode")
|
||||
mounter = mount.NewNsenterMounter()
|
||||
writer = &kubeio.NsenterWriter{}
|
||||
}
|
||||
@ -200,7 +391,7 @@ func setConfigz(cz *configz.Config, kc *kubeletconfiginternal.KubeletConfigurati
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
versioned := kubeletconfigv1alpha1.KubeletConfiguration{}
|
||||
versioned := kubeletconfigv1beta1.KubeletConfiguration{}
|
||||
if err := scheme.Convert(kc, &versioned, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -274,11 +465,7 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies) (err error) {
|
||||
|
||||
// About to get clients and such, detect standaloneMode
|
||||
standaloneMode := true
|
||||
switch {
|
||||
case s.RequireKubeConfig == true:
|
||||
standaloneMode = false
|
||||
glog.Warningf("--require-kubeconfig is deprecated. Set --kubeconfig without using --require-kubeconfig.")
|
||||
case s.KubeConfig.Provided():
|
||||
if len(s.KubeConfig) > 0 {
|
||||
standaloneMode = false
|
||||
}
|
||||
|
||||
@ -289,12 +476,8 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
if s.CloudProvider == kubeletconfigv1alpha1.AutoDetectCloudProvider {
|
||||
glog.Warning("--cloud-provider=auto-detect is deprecated. The desired cloud provider should be set explicitly")
|
||||
}
|
||||
|
||||
if kubeDeps.Cloud == nil {
|
||||
if !cloudprovider.IsExternal(s.CloudProvider) && s.CloudProvider != kubeletconfigv1alpha1.AutoDetectCloudProvider {
|
||||
if !cloudprovider.IsExternal(s.CloudProvider) {
|
||||
cloud, err := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -314,7 +497,7 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies) (err error) {
|
||||
}
|
||||
|
||||
if s.BootstrapKubeconfig != "" {
|
||||
if err := bootstrap.LoadClientCert(s.KubeConfig.Value(), s.BootstrapKubeconfig, s.CertDirectory, nodeName); err != nil {
|
||||
if err := bootstrap.LoadClientCert(s.KubeConfig, s.BootstrapKubeconfig, s.CertDirectory, nodeName); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -333,59 +516,55 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies) (err error) {
|
||||
var heartbeatClient v1core.CoreV1Interface
|
||||
var externalKubeClient clientset.Interface
|
||||
|
||||
clientConfig, err := CreateAPIServerClientConfig(s)
|
||||
clientConfig, err := createAPIServerClientConfig(s)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid kubeconfig: %v", err)
|
||||
}
|
||||
|
||||
var clientCertificateManager certificate.Manager
|
||||
if err == nil {
|
||||
if s.RotateCertificates && utilfeature.DefaultFeatureGate.Enabled(features.RotateKubeletClientCertificate) {
|
||||
clientCertificateManager, err = kubeletcertificate.NewKubeletClientCertificateManager(s.CertDirectory, nodeName, clientConfig.CertData, clientConfig.KeyData, clientConfig.CertFile, clientConfig.KeyFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// we set exitIfExpired to true because we use this client configuration to request new certs - if we are unable
|
||||
// to request new certs, we will be unable to continue normal operation
|
||||
if err := kubeletcertificate.UpdateTransport(wait.NeverStop, clientConfig, clientCertificateManager, true); err != nil {
|
||||
return err
|
||||
}
|
||||
if s.RotateCertificates && utilfeature.DefaultFeatureGate.Enabled(features.RotateKubeletClientCertificate) {
|
||||
clientCertificateManager, err = kubeletcertificate.NewKubeletClientCertificateManager(s.CertDirectory, nodeName, clientConfig.CertData, clientConfig.KeyData, clientConfig.CertFile, clientConfig.KeyFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
kubeClient, err = clientset.NewForConfig(clientConfig)
|
||||
if err != nil {
|
||||
glog.Warningf("New kubeClient from clientConfig error: %v", err)
|
||||
} else if kubeClient.CertificatesV1beta1() != nil && clientCertificateManager != nil {
|
||||
glog.V(2).Info("Starting client certificate rotation.")
|
||||
clientCertificateManager.SetCertificateSigningRequestClient(kubeClient.CertificatesV1beta1().CertificateSigningRequests())
|
||||
clientCertificateManager.Start()
|
||||
}
|
||||
externalKubeClient, err = clientset.NewForConfig(clientConfig)
|
||||
if err != nil {
|
||||
glog.Warningf("New kubeClient from clientConfig error: %v", err)
|
||||
// we set exitAfter to five minutes because we use this client configuration to request new certs - if we are unable
|
||||
// to request new certs, we will be unable to continue normal operation. Exiting the process allows a wrapper
|
||||
// or the bootstrapping credentials to potentially lay down new initial config.
|
||||
if err := kubeletcertificate.UpdateTransport(wait.NeverStop, clientConfig, clientCertificateManager, 5*time.Minute); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// make a separate client for events
|
||||
eventClientConfig := *clientConfig
|
||||
eventClientConfig.QPS = float32(s.EventRecordQPS)
|
||||
eventClientConfig.Burst = int(s.EventBurst)
|
||||
eventClient, err = v1core.NewForConfig(&eventClientConfig)
|
||||
if err != nil {
|
||||
glog.Warningf("Failed to create API Server client for Events: %v", err)
|
||||
}
|
||||
kubeClient, err = clientset.NewForConfig(clientConfig)
|
||||
if err != nil {
|
||||
glog.Warningf("New kubeClient from clientConfig error: %v", err)
|
||||
} else if kubeClient.CertificatesV1beta1() != nil && clientCertificateManager != nil {
|
||||
glog.V(2).Info("Starting client certificate rotation.")
|
||||
clientCertificateManager.SetCertificateSigningRequestClient(kubeClient.CertificatesV1beta1().CertificateSigningRequests())
|
||||
clientCertificateManager.Start()
|
||||
}
|
||||
externalKubeClient, err = clientset.NewForConfig(clientConfig)
|
||||
if err != nil {
|
||||
glog.Warningf("New kubeClient from clientConfig error: %v", err)
|
||||
}
|
||||
|
||||
// make a separate client for heartbeat with throttling disabled and a timeout attached
|
||||
heartbeatClientConfig := *clientConfig
|
||||
heartbeatClientConfig.Timeout = s.KubeletConfiguration.NodeStatusUpdateFrequency.Duration
|
||||
heartbeatClientConfig.QPS = float32(-1)
|
||||
heartbeatClient, err = v1core.NewForConfig(&heartbeatClientConfig)
|
||||
if err != nil {
|
||||
glog.Warningf("Failed to create API Server client for heartbeat: %v", err)
|
||||
}
|
||||
} else {
|
||||
switch {
|
||||
case s.RequireKubeConfig:
|
||||
return fmt.Errorf("invalid kubeconfig: %v", err)
|
||||
case s.KubeConfig.Provided():
|
||||
glog.Warningf("invalid kubeconfig: %v", err)
|
||||
}
|
||||
// make a separate client for events
|
||||
eventClientConfig := *clientConfig
|
||||
eventClientConfig.QPS = float32(s.EventRecordQPS)
|
||||
eventClientConfig.Burst = int(s.EventBurst)
|
||||
eventClient, err = v1core.NewForConfig(&eventClientConfig)
|
||||
if err != nil {
|
||||
glog.Warningf("Failed to create API Server client for Events: %v", err)
|
||||
}
|
||||
|
||||
// make a separate client for heartbeat with throttling disabled and a timeout attached
|
||||
heartbeatClientConfig := *clientConfig
|
||||
heartbeatClientConfig.Timeout = s.KubeletConfiguration.NodeStatusUpdateFrequency.Duration
|
||||
heartbeatClientConfig.QPS = float32(-1)
|
||||
heartbeatClient, err = v1core.NewForConfig(&heartbeatClientConfig)
|
||||
if err != nil {
|
||||
glog.Warningf("Failed to create API Server client for heartbeat: %v", err)
|
||||
}
|
||||
|
||||
kubeDeps.KubeClient = kubeClient
|
||||
@ -398,10 +577,10 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Alpha Dynamic Configuration Implementation;
|
||||
// if the kubelet config controller is available, inject the latest to start the config and status sync loops
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) && kubeDeps.KubeletConfigController != nil && !standaloneMode && !s.RunOnce {
|
||||
kubeDeps.KubeletConfigController.StartSync(kubeDeps.KubeClient, string(nodeName))
|
||||
// If the kubelet config controller is available, and dynamic config is enabled, start the config and status sync loops
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) && len(s.DynamicConfigDir.Value()) > 0 &&
|
||||
kubeDeps.KubeletConfigController != nil && !standaloneMode && !s.RunOnce {
|
||||
kubeDeps.KubeletConfigController.StartSync(kubeDeps.KubeClient, kubeDeps.EventClient, string(nodeName))
|
||||
}
|
||||
|
||||
if kubeDeps.Auth == nil {
|
||||
@ -475,6 +654,7 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies) (err error) {
|
||||
ExperimentalQOSReserved: *experimentalQOSReserved,
|
||||
ExperimentalCPUManagerPolicy: s.CPUManagerPolicy,
|
||||
ExperimentalCPUManagerReconcilePeriod: s.CPUManagerReconcilePeriod.Duration,
|
||||
ExperimentalPodPidsLimit: s.PodPidsLimit,
|
||||
},
|
||||
s.FailSwapOn,
|
||||
devicePluginEnabled,
|
||||
@ -533,7 +713,7 @@ func getNodeName(cloud cloudprovider.Interface, hostname string) (types.NodeName
|
||||
return "", fmt.Errorf("failed to get instances from cloud provider")
|
||||
}
|
||||
|
||||
nodeName, err := instances.CurrentNodeName(hostname)
|
||||
nodeName, err := instances.CurrentNodeName(context.TODO(), hostname)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error fetching current node name from cloud provider: %v", err)
|
||||
}
|
||||
@ -571,12 +751,21 @@ func InitializeTLS(kf *options.KubeletFlags, kc *kubeletconfiginternal.KubeletCo
|
||||
glog.V(4).Infof("Using self-signed cert (%s, %s)", kc.TLSCertFile, kc.TLSPrivateKeyFile)
|
||||
}
|
||||
}
|
||||
|
||||
tlsCipherSuites, err := flag.TLSCipherSuites(kc.TLSCipherSuites)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
minTLSVersion, err := flag.TLSVersion(kc.TLSMinVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tlsOptions := &server.TLSOptions{
|
||||
Config: &tls.Config{
|
||||
// Can't use SSLv3 because of POODLE and BEAST
|
||||
// Can't use TLSv1.0 because of POODLE and BEAST using CBC cipher
|
||||
// Can't use TLSv1.1 because of RC4 cipher usage
|
||||
MinVersion: tls.VersionTLS12,
|
||||
MinVersion: minTLSVersion,
|
||||
CipherSuites: tlsCipherSuites,
|
||||
},
|
||||
CertFile: kc.TLSCertFile,
|
||||
KeyFile: kc.TLSPrivateKeyFile,
|
||||
@ -598,29 +787,24 @@ func InitializeTLS(kf *options.KubeletFlags, kc *kubeletconfiginternal.KubeletCo
|
||||
|
||||
func kubeconfigClientConfig(s *options.KubeletServer) (*restclient.Config, error) {
|
||||
return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
||||
&clientcmd.ClientConfigLoadingRules{ExplicitPath: s.KubeConfig.Value()},
|
||||
&clientcmd.ClientConfigLoadingRules{ExplicitPath: s.KubeConfig},
|
||||
&clientcmd.ConfigOverrides{},
|
||||
).ClientConfig()
|
||||
}
|
||||
|
||||
// createClientConfig creates a client configuration from the command line arguments.
|
||||
// If --kubeconfig is explicitly set, it will be used. If it is not set but
|
||||
// --require-kubeconfig=true, we attempt to load the default kubeconfig file.
|
||||
// If --kubeconfig is explicitly set, it will be used.
|
||||
func createClientConfig(s *options.KubeletServer) (*restclient.Config, error) {
|
||||
// If --kubeconfig was not provided, it will have a default path set in cmd/kubelet/app/options/options.go.
|
||||
// We only use that default path when --require-kubeconfig=true. The default path is temporary until --require-kubeconfig is removed.
|
||||
// TODO(#41161:v1.10.0): Remove the default kubeconfig path and --require-kubeconfig.
|
||||
if s.BootstrapKubeconfig != "" || s.KubeConfig.Provided() || s.RequireKubeConfig == true {
|
||||
if s.BootstrapKubeconfig != "" || len(s.KubeConfig) > 0 {
|
||||
return kubeconfigClientConfig(s)
|
||||
} else {
|
||||
return nil, fmt.Errorf("createClientConfig called in standalone mode")
|
||||
}
|
||||
}
|
||||
|
||||
// CreateAPIServerClientConfig generates a client.Config from command line flags
|
||||
// createAPIServerClientConfig generates a client.Config from command line flags
|
||||
// via createClientConfig and then injects chaos into the configuration via addChaosToClientConfig.
|
||||
// This func is exported to support integration with third party kubelet extensions (e.g. kubernetes-mesos).
|
||||
func CreateAPIServerClientConfig(s *options.KubeletServer) (*restclient.Config, error) {
|
||||
func createAPIServerClientConfig(s *options.KubeletServer) (*restclient.Config, error) {
|
||||
clientConfig, err := createClientConfig(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -667,17 +851,17 @@ func RunKubelet(kubeFlags *options.KubeletFlags, kubeCfg *kubeletconfiginternal.
|
||||
// prefer this to be done as part of an independent validation step on the
|
||||
// KubeletConfiguration. But as far as I can tell, we don't have an explicit
|
||||
// place for validation of the KubeletConfiguration yet.
|
||||
hostNetworkSources, err := kubetypes.GetValidatedSources(kubeCfg.HostNetworkSources)
|
||||
hostNetworkSources, err := kubetypes.GetValidatedSources(kubeFlags.HostNetworkSources)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
hostPIDSources, err := kubetypes.GetValidatedSources(kubeCfg.HostPIDSources)
|
||||
hostPIDSources, err := kubetypes.GetValidatedSources(kubeFlags.HostPIDSources)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
hostIPCSources, err := kubetypes.GetValidatedSources(kubeCfg.HostIPCSources)
|
||||
hostIPCSources, err := kubetypes.GetValidatedSources(kubeFlags.HostIPCSources)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -687,20 +871,16 @@ func RunKubelet(kubeFlags *options.KubeletFlags, kubeCfg *kubeletconfiginternal.
|
||||
HostPIDSources: hostPIDSources,
|
||||
HostIPCSources: hostIPCSources,
|
||||
}
|
||||
capabilities.Setup(kubeCfg.AllowPrivileged, privilegedSources, 0)
|
||||
capabilities.Setup(kubeFlags.AllowPrivileged, privilegedSources, 0)
|
||||
|
||||
credentialprovider.SetPreferredDockercfgPath(kubeFlags.RootDirectory)
|
||||
glog.V(2).Infof("Using root directory: %v", kubeFlags.RootDirectory)
|
||||
|
||||
builder := kubeDeps.Builder
|
||||
if builder == nil {
|
||||
builder = CreateAndInitKubelet
|
||||
}
|
||||
if kubeDeps.OSInterface == nil {
|
||||
kubeDeps.OSInterface = kubecontainer.RealOS{}
|
||||
}
|
||||
|
||||
k, err := builder(kubeCfg,
|
||||
k, err := CreateAndInitKubelet(kubeCfg,
|
||||
kubeDeps,
|
||||
&kubeFlags.ContainerRuntimeOptions,
|
||||
kubeFlags.ContainerRuntime,
|
||||
@ -714,7 +894,6 @@ func RunKubelet(kubeFlags *options.KubeletFlags, kubeCfg *kubeletconfiginternal.
|
||||
kubeFlags.RegisterNode,
|
||||
kubeFlags.RegisterWithTaints,
|
||||
kubeFlags.AllowedUnsafeSysctls,
|
||||
kubeFlags.Containerized,
|
||||
kubeFlags.RemoteRuntimeEndpoint,
|
||||
kubeFlags.RemoteImageEndpoint,
|
||||
kubeFlags.ExperimentalMounterPath,
|
||||
@ -751,18 +930,18 @@ func RunKubelet(kubeFlags *options.KubeletFlags, kubeCfg *kubeletconfiginternal.
|
||||
}
|
||||
glog.Infof("Started kubelet as runonce")
|
||||
} else {
|
||||
startKubelet(k, podCfg, kubeCfg, kubeDeps)
|
||||
startKubelet(k, podCfg, kubeCfg, kubeDeps, kubeFlags.EnableServer)
|
||||
glog.Infof("Started kubelet")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func startKubelet(k kubelet.Bootstrap, podCfg *config.PodConfig, kubeCfg *kubeletconfiginternal.KubeletConfiguration, kubeDeps *kubelet.Dependencies) {
|
||||
func startKubelet(k kubelet.Bootstrap, podCfg *config.PodConfig, kubeCfg *kubeletconfiginternal.KubeletConfiguration, kubeDeps *kubelet.Dependencies, enableServer bool) {
|
||||
// start the kubelet
|
||||
go wait.Until(func() { k.Run(podCfg.Updates()) }, 0, wait.NeverStop)
|
||||
|
||||
// start the kubelet server
|
||||
if kubeCfg.EnableServer {
|
||||
if enableServer {
|
||||
go wait.Until(func() {
|
||||
k.ListenAndServe(net.ParseIP(kubeCfg.Address), uint(kubeCfg.Port), kubeDeps.TLSOptions, kubeDeps.Auth, kubeCfg.EnableDebuggingHandlers, kubeCfg.EnableContentionProfiling)
|
||||
}, 0, wait.NeverStop)
|
||||
@ -788,7 +967,6 @@ func CreateAndInitKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
|
||||
registerNode bool,
|
||||
registerWithTaints []api.Taint,
|
||||
allowedUnsafeSysctls []string,
|
||||
containerized bool,
|
||||
remoteRuntimeEndpoint string,
|
||||
remoteImageEndpoint string,
|
||||
experimentalMounterPath string,
|
||||
@ -822,7 +1000,6 @@ func CreateAndInitKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
|
||||
registerNode,
|
||||
registerWithTaints,
|
||||
allowedUnsafeSysctls,
|
||||
containerized,
|
||||
remoteRuntimeEndpoint,
|
||||
remoteImageEndpoint,
|
||||
experimentalMounterPath,
|
||||
@ -878,36 +1055,26 @@ func parseResourceList(m map[string]string) (v1.ResourceList, error) {
|
||||
|
||||
// BootstrapKubeletConfigController constructs and bootstrap a configuration controller
|
||||
func BootstrapKubeletConfigController(defaultConfig *kubeletconfiginternal.KubeletConfiguration,
|
||||
initConfigDirFlag flag.StringFlag,
|
||||
dynamicConfigDirFlag flag.StringFlag) (*kubeletconfiginternal.KubeletConfiguration, *kubeletconfig.Controller, error) {
|
||||
var err error
|
||||
// Alpha Dynamic Configuration Implementation; this section only loads config from disk, it does not contact the API server
|
||||
// compute absolute paths based on current working dir
|
||||
initConfigDir := ""
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.KubeletConfigFile) && initConfigDirFlag.Provided() {
|
||||
initConfigDir, err = filepath.Abs(initConfigDirFlag.Value())
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to get absolute path for --init-config-dir")
|
||||
}
|
||||
dynamicConfigDir string) (*kubeletconfiginternal.KubeletConfiguration, *dynamickubeletconfig.Controller, error) {
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) {
|
||||
return nil, nil, fmt.Errorf("failed to bootstrap Kubelet config controller, you must enable the DynamicKubeletConfig feature gate")
|
||||
}
|
||||
dynamicConfigDir := ""
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) && dynamicConfigDirFlag.Provided() {
|
||||
dynamicConfigDir, err = filepath.Abs(dynamicConfigDirFlag.Value())
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to get absolute path for --dynamic-config-dir")
|
||||
}
|
||||
if len(dynamicConfigDir) == 0 {
|
||||
return nil, nil, fmt.Errorf("cannot bootstrap Kubelet config controller, --dynamic-config-dir was not provided")
|
||||
}
|
||||
|
||||
// get the latest KubeletConfiguration checkpoint from disk, or load the init or default config if no valid checkpoints exist
|
||||
kubeletConfigController, err := kubeletconfig.NewController(defaultConfig, initConfigDir, dynamicConfigDir)
|
||||
// compute absolute path and bootstrap controller
|
||||
dir, err := filepath.Abs(dynamicConfigDir)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to construct controller, error: %v", err)
|
||||
return nil, nil, fmt.Errorf("failed to get absolute path for --dynamic-config-dir=%s", dynamicConfigDir)
|
||||
}
|
||||
kubeletConfig, err := kubeletConfigController.Bootstrap()
|
||||
// get the latest KubeletConfiguration checkpoint from disk, or return the default config if no valid checkpoints exist
|
||||
c := dynamickubeletconfig.NewController(defaultConfig, dir)
|
||||
kc, err := c.Bootstrap()
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to determine a valid configuration, error: %v", err)
|
||||
}
|
||||
return kubeletConfig, kubeletConfigController, nil
|
||||
return kc, c, nil
|
||||
}
|
||||
|
||||
// RunDockershim only starts the dockershim in current process. This is only used for cri validate testing purpose
|
||||
@ -949,10 +1116,6 @@ func RunDockershim(f *options.KubeletFlags, c *kubeletconfiginternal.KubeletConf
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ds.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
glog.V(2).Infof("Starting the GRPC server for the docker CRI shim.")
|
||||
server := dockerremote.NewDockerServer(f.RemoteRuntimeEndpoint, ds)
|
||||
if err := server.Start(); err != nil {
|
||||
|
77
vendor/k8s.io/kubernetes/cmd/kubelet/kubelet.go
generated
vendored
77
vendor/k8s.io/kubernetes/cmd/kubelet/kubelet.go
generated
vendored
@ -22,88 +22,25 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/apiserver/pkg/util/flag"
|
||||
"k8s.io/apiserver/pkg/util/logs"
|
||||
"k8s.io/kubernetes/cmd/kubelet/app"
|
||||
"k8s.io/kubernetes/cmd/kubelet/app/options"
|
||||
_ "k8s.io/kubernetes/pkg/client/metrics/prometheus" // for client metric registration
|
||||
_ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration
|
||||
"k8s.io/kubernetes/pkg/version/verflag"
|
||||
)
|
||||
|
||||
func die(err error) {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
// construct KubeletFlags object and register command line flags mapping
|
||||
kubeletFlags := options.NewKubeletFlags()
|
||||
kubeletFlags.AddFlags(pflag.CommandLine)
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
|
||||
// construct KubeletConfiguration object and register command line flags mapping
|
||||
defaultConfig, err := options.NewKubeletConfiguration()
|
||||
if err != nil {
|
||||
die(err)
|
||||
}
|
||||
options.AddKubeletConfigFlags(pflag.CommandLine, defaultConfig)
|
||||
|
||||
// parse the command line flags into the respective objects
|
||||
flag.InitFlags()
|
||||
|
||||
// initialize logging and defer flush
|
||||
command := app.NewKubeletCommand()
|
||||
logs.InitLogs()
|
||||
defer logs.FlushLogs()
|
||||
|
||||
// short-circuit on verflag
|
||||
verflag.PrintAndExitIfRequested()
|
||||
|
||||
// TODO(mtaufen): won't need this this once dynamic config is GA
|
||||
// set feature gates so we can check if dynamic config is enabled
|
||||
if err := utilfeature.DefaultFeatureGate.SetFromMap(defaultConfig.FeatureGates); err != nil {
|
||||
die(err)
|
||||
}
|
||||
// validate the initial KubeletFlags, to make sure the dynamic-config-related flags aren't used unless the feature gate is on
|
||||
if err := options.ValidateKubeletFlags(kubeletFlags); err != nil {
|
||||
die(err)
|
||||
}
|
||||
// bootstrap the kubelet config controller, app.BootstrapKubeletConfigController will check
|
||||
// feature gates and only turn on relevant parts of the controller
|
||||
kubeletConfig, kubeletConfigController, err := app.BootstrapKubeletConfigController(
|
||||
defaultConfig, kubeletFlags.InitConfigDir, kubeletFlags.DynamicConfigDir)
|
||||
if err != nil {
|
||||
die(err)
|
||||
}
|
||||
|
||||
// construct a KubeletServer from kubeletFlags and kubeletConfig
|
||||
kubeletServer := &options.KubeletServer{
|
||||
KubeletFlags: *kubeletFlags,
|
||||
KubeletConfiguration: *kubeletConfig,
|
||||
}
|
||||
|
||||
// use kubeletServer to construct the default KubeletDeps
|
||||
kubeletDeps, err := app.UnsecuredDependencies(kubeletServer)
|
||||
if err != nil {
|
||||
die(err)
|
||||
}
|
||||
|
||||
// add the kubelet config controller to kubeletDeps
|
||||
kubeletDeps.KubeletConfigController = kubeletConfigController
|
||||
|
||||
// start the experimental docker shim, if enabled
|
||||
if kubeletFlags.ExperimentalDockershim {
|
||||
if err := app.RunDockershim(kubeletFlags, kubeletConfig); err != nil {
|
||||
die(err)
|
||||
}
|
||||
}
|
||||
|
||||
// run the kubelet
|
||||
if err := app.Run(kubeletServer, kubeletDeps); err != nil {
|
||||
die(err)
|
||||
if err := command.Execute(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user